Mark Sachs (ksleet) wrote,
Mark Sachs

  • Mood:
  • Music:

"Recalling surface squads so we can all die together. Aye sir!"

So yeah, today I made some rockets.

The idea behind these simple enemies is that they're fixed to a wall and launch in roughly a straight line if the player gets close. Nothing too fancy, but the neat part is that the rockets are entirely defined by a brand new XML configuration:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
				<ram name="attack" />
				<setflag name="launch" flag="0" />
				<idle name="idle" />
				<and target="attack">
					<checkflag flag="0" />
					<worlddetection entity="PlayerShip" />
				<fandetection target="launch" range="400" width="40" entity="PlayerShip" />
				<true target="idle" />
	<movement maxspeed="300" acceleration="200" turnrate="10.0" />
	<graphics file="player.svg" />
	<physics radius="10" />
	<special oncollision="explode" />

The AI system has been beefed up a bit by giving it an array of flags that can be set or examined as the AI runs. In the case of the rocket, we just use one flag. When the player intrudes on the triangular detection volume in front of the rocket, we set flag 0. The next time the AI runs, it sees that flag 0 is set to true, so it executes the behavior that auto-detects the player and tries to home in on them. In summary, I now have a reasonably elegant way of maintaining multiple AI states and switching between them based on arbitrary game events.

You'll note that I have also enhanced the config file by putting most of the details of enemy behavior in it, such as the enemy's movement abilities, graphics, physics radius, and so forth. (In this case, the rocket accelerates quickly to a high top speed, but it can only turn at ten degrees per second, so its homing abilities are very limited.) There's kind of a hack in there as well which makes the rocket explode when it crashes into anything.

So it's all pretty straightforward, but this sort of thing should make it very easy to create and tweak enemies in the game.

I'm not sure what to work on next! More enemies and enemy behavior? More player features, such as a shield and the ability to use inventory items? Beefing up the map with things like doors and spawners? Adding the overall game structure -- attract screen, level transitions, and so on? I could use your suggestions!
Tags: neon galaxy
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded