Sunday, January 12, 2014

Alex attempts to make a game - Part 2: Beware the Prototype!!


So apparently "new" doesn't mean "new" in Javascript. Or at least it's not my understanding of what "new" is supposed to mean. Turns out if you have objects inheriting from other objects and so on, they share their prototype properties. So initially when I created the Enemy class ALL the enemies behaved the same. Or roughly the same. Took me a while to figure out I had the use the Super Constructor call in the base Enemy Class in order to make each enemy unique. That took me a lot longer to figure out than it should have. Mostly, because I got hung up on how I was instantiating the objects, so I kept chasing a wild goose. Anyways, lesson learned. :D

Also, I'm doing something really hacking so that enemy objects don't clear each other off the screen. I may need to try and generalize the rendering of all the elements, I'm not sure. But in either case, NOW the enemies all clear together, they all move together, and they all draw together. Like one big happy family.

There also seems to be a bit of a bug that when some of the enemies go off screen they pop in right in the center of the screen for a split second. That I'm going to need to fix because eventually the player will die if he/she runs into an enemy ship. 

Lastly, I started on but did not finish my sprite packer program. I need to figure out what the best way for me to actually compile the images together after they are cropped. An idea I had was to use Photoshop automation but I'm going to research and see if there is a pretty decent way to do it in just C# first. If not, or it's too difficult for my brain, I may just look into using PS automation since I've already been researching it.

No comments:

Post a Comment