Archive

Posts Tagged ‘Weekend Tower Defense’

Learning to use Flixel

June 4, 2013 Leave a comment

I kept running into errors associated with objects not being deleted properly with my old tower defense engine. Part of it is because I wasn’t putting in proper destroy commands into my classes. Part of it is that I had no idea how to create a proper game framework. One that registers each object and deletes those objects when they’re no longer needed.

In comes Flixel, a flash-based game engine. Flixel breaks a game into “States” that can be created and destroyed without worrying about objects lingering. So a menu state can be opened to start the game, and when you load the game state, everything from the menu is cleared from memory. More importantly, when you exit to menu and then reopen the game, everything from the old game has been cleared out. No more invisible towers that start shooting at invisible enemies as soon as you load the game (this happened more times than I’m willing to admit).

This is your brain on Flixel

This is your brain on Flixel

Flixel is an open source game-making library that is completely free for personal or commercial use. Written entirely in Actionscript 3, and designed to be used with free development tools, Flixel is easy to learn, extend and customize. -Flixel homepage

Flixel provides a large list of helper classes that takes care of some of the more basic programming needs. FlxGame is the base game class. FlxG controls global variables. FlxState can be extended to create new game states, though you only need one for your game to work. FlxSprite is the basic sprite, but with some animation automation, movement controls and automated cleanup. There’s lots of other classes that I haven’t yet dug in to.

Flixel sprites don’t have an addEventListener() function, which makes it harder to confuse yourself about which object is listening to which other object. From what I’ve read, the proper way to handle event checks is within the update function of each object. Flixel also has a class called FlxGroup which allows you to perform collision checks and tests against every object within the group. I’m currently using the FlxGroup as my enemy manager, tower manager and bullet manager.

I’ve started recoding my Weekend Tower Defense using the Flixel game engine. I’m not sure if recoding this Tower Defense game has just become a way to learn how to make games or if I’m actually planning on releasing this game eventually, but it certainly has been a learning experience. So far I’ve got a basic engine that loads up a map and spawns a series a waves to march across the map’s predefined paths.

"Progress"

“Progress”

Since finding Flixel, I’ve also found DAME a free tool for generating levels from tilemaps. You can create multiple layers in each level each using different tilemaps. It certainly makes creating new maps very easy and provides a nice visual tool for doing so. It supports several different export formats from a basic csv to an AS3 class that makes loading levels a breeze. It’s supposed to allow you to create paths, but I’ve haven’t yet been able to figure that tool out and have instead been defining paths manually.

Deadly Alien Map Editor in action

Deadly Alien Map Editor in action

All in all, I think learning both these tools will help with future games. Flixel especially has been teaching me a better mindset for creating games. It also seems like it’s much easier to prototype a flash game using Flixel than the old way I was doing it, so maybe it will really pay off when I move on to the next game.

Advertisements

Counters, Waves and Lasers

March 21, 2013 Leave a comment

Here’s the current status on my Weekend Tower Defense game.

So the changes since the last video I posted are 2 new tower types, Wave and Laser. The Wave tower hits all enemy in range simultaneously and deals a lot of damage, but fires very slowly. The laser does very little damage per hit, but fires continuously, so it works well for lots of fast, weak enemies.

There’s also a wave counter showing all the upcoming waves so that the player can actually make plans instead of just reacting to what’s coming right now. I’ve finally balanced the amount of money the player has throughout the level with the strength of the enemies, so that you actually have to make a plan in order to finish the level without taking damage. It’s not too hard yet, but it’s a start.

I’ve been playing around this last week with Flixel. It’s an open source game-making library for flash that will hopefully make it a little bit easier to develop games in the future. I’m hoping it will also teach me the “proper” way to program a game, since it supports game states and automates a lot of collision detection, event detection and clean-up. This should at least eliminate my horrible AS3 event scripting in the future (events are a nightmare in AS3 because they can cause a lot of memory leaks).