Tuesday, August 16, 2011

Specific Spawning

Since I've already had a good base of the enemy class finished, I decided it was time to figure out how I was going to specify where they would spawn. So, as usual, I started a new class called 'EnemySpawner' (Believe it or not!), that would take care of most of the functionality. There were the basic fields like Texture and Vector position, but there was also a couple fields such as spawnRate and spawnTimer that were quite important.

For the texture, I quickly done one up on Photoshop.

Its just rough and temporary. (Hopefully Lynch can improve it a good bit!)

After giving the texture a position and drawing it to the screen, it was just a matter of specifying the spawn rate. I used the 'TimeSpan' keyword and set the spawn rate to two seconds. Then the spawn timer is set to zero initially. By now, I had created a list to hold any enemies that were being created. So every two seconds an enemy is created at the specified spawn point and added to the list.

Thats about all that was needed for the spawning, initially anyway. Further down the line I expect that the spawner will be placed just as the rest of the items on the maps are.

No comments:

Post a Comment