Scripted Tutorial and Level Editor

Instead of a complex set of rules and conditions for the tutorial, the game now uses a scripting system that allows us to precisely define and modify the tutorial and any levels we want to add.

The game loads a script from a plain text, tab separated file that can be edited with any text editor. Since it’s tab separated, it can also be copied to a spreadsheet (Excel or Google Docs) and edited very easily. Each line of the script is a command and has 4 fields:

  1. The command
  2. Any parameters required by the command (optional)
  3. A terminating condition (optional)
  4. A delay (optional)

The script interpreter will read a line from the script file and execute the given command with any parameters specified. Then, it checks for the terminating condition (if any) and waits until it’s valid. Then it launches a timer delay (if any) and moves the script pointer to the next line in the script file.

The commands (with it’s parameters, all required, separated by spaces) currently available are:

  • nothing: do nothing (usually for waiting for some compound termination condition)
  • text: displays a text in the text box
    • string: the text to display in the text box
  • reset: removes all enemies, apples and traps from the environment (used when restarting a level)
  • enable: enables game mechanics (used for the tutorial).
    parameters:

    • numeric: what element to enable (both in the gameplay and UI elements) where:
      • 0: all disabled
      • 1: enables firing projectiles
      • 2, 3: enables projectile types
      • 4: enables force and mass control (parabolic arc)
      • 5: enables rotation and camera movement
      • 6: enables the statistics box and general gameplay
  • setup: sets up the next level or tutorial section by setting the level counter, number of enemies, projectiles and lives given
    • numeric: level identifier
    • numeric: enemies that may be spawned before completing the level (99 for the tutorial)
    • numeric: number of total projectiles allowed
    • numeric: number of regular projectiles
    • numeric: number of sticky projectiles
    • numeric: number of frictionless trap projectiles
    • numeric: the default apple that is given to the player (which may not be able to change it in the early parts of the tutorial)
      • 0: regular projectiles
      • 1: sticky projectiles
      • 2: frictionless trap projectiles
    • numeric: number of lives or hits allowed
  • spawn: spawns a new enemy
    • numeric: the type of enemy, where:
      • 0: the bot
      • 1: the boat
      • 2: the car
      • 3: the tank
    • float 0.0-1.0: the radial location  for spawning*
      • 0.0: east
      • 0.25: north
      • 0.5: west
      • 0.75: south
    • float 0.0-1.0: the distance for spawning*
      • 0.0: right next to the player home section
      • 0.5: half way, about 45 units from the center
      • 1.0: the bush area perimeter, about 80 units from the center
    • boolean 0 or 1: wether the enemy is moving or not
    • string: enemy identifier for the tutorial and terminating conditions
    • boolean 0 or 1: wether the enemy is highlighted with a special marker
  • startwave: sets up a player turn for a level
    • numeric: level identifier

About the terminating conditions: There are several terminating conditions that can be used in the script to wait for events to happen before proceeding. Currently there we implemented the following:

  • win-ENEMYID: when an enemy with a specified identifier reaches the top
  • kill-ENEMYID: when the player kills an enemy with specified identifier
  • pop-apple: when a projectile is destroyed by a tank
  • splash: when a frictionless trap has been set
  • shoot-TYPE: when a projectile of the specified type is shot
  • endwave-LEVELID: when a level is finished successfully (# of enemies killed+enemies won is equal to # of enemies spawned)

*For reference:

2014-03-03 19.17.50

Let’s look at the script used by the tutorial and the first level:

reset 0 0
enable 0 0
text Welcome to Little Newton, a Team Serious game. 1
text Let’s learn how to play. 1
spawn 2 0.85 0.25 1 car1 1 0
text Did you notice that? That is a member of the Evil League of Toys trying to distract you! win-car1 1
text The toys will attempt to climb your hill; if they reach the top you will lose a life. 1
enable 1 0
setup 0 99 1 0 0 0 99 0
spawn 2 0.75 0.65 0 car2 1 0
text Let’s try to fight those evil toys. Press Space to fire an apple. kill-car2 1
text Perfect! 1
setup 0 99 99 0 0 0 99 0
spawn 3 0.75 0.65 0 tank1 1 0
text What’s that? Try shooting it with an apple! pop-apple 0
text The apple didn’t work because the enemy was too heavy to be knocked over. Let’s try something else… 1
enable 2 0
setup 0 99 1 1 1 2 99 0
text Let’s use a different kind of apple. splash 1
text This created a low friction zone; let’s see how it affects an incoming toy tank. 0
spawn 3 0.75 0.50 1 tank2 1 kill-tank2 0
text Did you see that? Amazing! The toy tank slipped because of the low friction zone you made! 1
setup 0 99 0 0 0 2 99 0
enable 0 0
spawn 1 0.75 0.65 1 boat1 1 0
text Another enemy? win-boat1 0
text What was that? It seems that the little surface contact of the boat did not slip… 1
enable 2 0
setup 0 99 0 1 0 1 99 0
text Time to test another apple type! shoot-1 0
spawn 1 0.75 0.65 1 boat2 1 kill-boat2 0
reset 0
setup 0 99 99 0 0 0 99 0
text Game on! 0
spawn 0 0.75 0.4 0 bot1 1 0
spawn 0 0.75 0.25 0 bot2 1 0
spawn 0 0.75 0.6 0 bot3 1 0
text What is this? A new type of enemy? When does this stop? 1
enable 4 0
text This will be tricky. You have to hit them in the head. Try adjusting your power! kill-bot1 0
nothing kill-bot2 0
nothing kill-bot3 0
text Great work! And now for the real deal! 1
reset 5 0
enable 5 0
setup 0 99 99 0 0 0 99 0
spawn 2 0.85 0.66 0 car3 1 0
spawn 2 0.75 0.66 0 car4 0 0
spawn 2 0.65 0.66 0 car5 1 0
text Use the arrows to move around and the mouse to change the camera angle. kill-car3 0
nothing kill-car4 0
nothing kill-car5 0
text Fantastic! 1
reset 0 0
enable 6 0
text One last thing: look at the stats to see how many enemies, apples and hits there are total. 1
text And now, let’s play! 1
text Wave 1 0
reset 6 0
setup 1 6 3 3 3 0 99 0
spawn 2 0.0 1.0 1 car 0 0
spawn 2 0.5 1.0 1 car 0 0
spawn 2 0.75 1.0 1 car 0 0
startwave 0
spawn 2 0.0 1.0 1 car 0 3
spawn 2 0.5 1.0 1 car 0 3
spawn 2 0.75 1.0 1 car 0 3
nothing endwave-1 0
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s