Saturday, November 21, 2009

Case 07 - Final

This is kinda late, I know.. Been buisy doing other school stuff so I kinda forgot to blog =_=

So this case was about mutiple classes divided on different actionscipt files. This is called OOP(Object Oriented Programming) and means you write several codes in different files. This makes it easier to arrange stuff, and you can use different classas you create on different elemtents. A nice exaple is veihicles, say you make a base class for different cars, they all share the same base properties, like they drive forward, can turn to the left or rigth. But you might want to make some cars faster than others, and some that can withstand more than others. By making a base class you can just change the properties on the different cars, instead of writing code from scratch for each car.
OOP also gives you a better overview of your code, because instead of having 1000+ lines, you split it up in several files.

That being said, this case was about making a new class for the game, namlely an enemy class. What we're supposed to do here is make a new ActionScript file and start from scratch to write the code. When this is done you can use the enemy class you've created and import it from the main ActionScript code. This saves space in the document, and you can easily browse through the classes and change stuff.

I won't bother writing all the code of my enemy, but I'll tell you roughly what I've done so far. So, I wanted enemies to spawn in the air and fall down to the ground and attack/follow the player. This is done by telling the enemy that if it's value of X is greater that the players, it is to reduce the X value by diminishing the value. In other words, the enemy stive to have the same X vale as the player. This is the most basic enemy AI you can get. But it is enough. At least for me :)
Finally I had to add object detection, wich means that the enemy doesn't go through walls. I did this more or less the same way I added gravity and hitTestPoint to the player. This means that when the enemy hits the ground, he doesn't go through it.

Here's a preview of the game so far.


Case 07 by ~Elr0hiR on deviantART

No comments:

Post a Comment