User Tools

Site Tools


mooengine

MooEngine

Overview

MooEngine was my attempt at creating a 100% scriptable game engine. I was able to integrate all the necessary features by creating a new scripting language called MooScript.

The basic features of MooScript are:

  • syntax similar to c, only less complicated
  • built-in datatypes: bool, int, float, string
  • object-oriented scripting language including inheritance and the like
  • loops, vectors, maps…
  • one thread per script

The obligatory Hello World code:

log("Hello World")

Not very exciting, right? :)

Let's make it slightly more interesting:

main : 1000
{
  log("Hello World")
}

The (optional) main function is now automatically called every 1000ms.

Same example, but this time the “Hello World” string is generated by a function:

Function getMessage() : String
{
  return "Hello World"
}

main : 1000
{
  log(getMessage())
}

If you ever wanted to simulate a cow:

Function getMoo(Integer num) : String
{
  return "M" + "o" * num
}

main : 1000
{
  log(getMoo(2 + rand(10)))
}

The output will be:

Moooo
Moo
Moooooo
...

Rather straightforward. Using classes is not very complicated either:

Class Animal
{
  String name
  
  Method talk()
  {
    log("I can't talk")
  }
}

Class Cow : Animal
{
  Bool happy = TRUE
  
  // constructor
  Cow(String n)
  {
    name = n
  }
  
  Method talk()
  {
    if (happy)
      log(name + " 3:-)")
    else
      log(name + " 3:-(")
  }
  
  Method tip()
  {
    happy = FALSE
  }
}

Cow cow1("MadCow"), cow2("BadCow")

cow1.talk()
cow2.tip()
cow2.talk()

The output will be:

MadCow: 3:-)
BadCow: 3:-(

Some of the more interesting features are:

  • inter-process communication
    • c++ ↔ script: synchronized variables
    • c++ → script: call methods
    • script → cpp: emit signals
    • script ↔ script: call methods and access variables
  • many built-in functions (maths, string manipulation, file operations)
  • create and manage GUI elements: windows, widgets
  • create and manage arbitrary 2D scenes
  • create and manage arbitrary 3D scenes (complete with entity handling, keyboard and mouse input, …)
  • create and modify images

More highlights:

  • dynamically load/unload scripts
  • scripts share common scene graph for quick rendering
  • integrate 2D/3D scenes in widgets using offscreen rendering
  • HTTP client: automatically download remote content
  • HTTP server: dynamic webpages using MooScript

Current State

??% done - stopped

Screenshots

Videos

mooengine.txt · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki