Enemy Placement

Let's make some shit to blow (us) up.

Working in stage_OnStart()…
First we'll define what sprite sheets the enemies will be wearing:
loadWalkPattern(0,"img/charas/enemy2.gfx",8,32,32)
loadWalkPattern(1,"img/charas/enemy3.gfx",8,32,32)

loadWalkPattern() variables, in order

  • Sprite graphics index, if you have two functions with the same value here the level will crash your game
  • Path to the sprite sheet to use
  • rows the sprite sheet has
  • size of each sprite instance, width
  • size of each sprite instance, height

Then place them:
createEnemy(0,56,48,90,0,1,"rotator",1.2,0)
createEnemy(0,96,80,90,0,1,"rotator",-1.2,0)

createEnemy() variables

  • Sprite graphics indicator, matching the first value of loadWalkPattern()
  • Starting X position
  • Starting Y position
  • Starting angle to face, 90 looks straight down; 270 looks up
  • no idea, most have 0
  • might be initial life
  • the name of the object, ie. "rotator" looks for rotator_OnStart() and rotator_OnStep()
  • a value that can be called on with getv(64), used in various ways
  • enemies atop walls have a 2 for this value

After placing enemies, or changing the amount of enemies, double check that your actual enemy count matches the stage's enemy count.

setEnemyCount(8);

If this number is off, the level may end prematurely, or will not end after killing all the enemies. In that case you have to walk every person individually to the stage exit which is quite troublesome for the player.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.