Right. So today, I make a new enemy! Well, start to at least.
First I needed to find an enemy to use which meant finding an enemy strip like the one used for the mine enemy or the player.
I found a fairly neat looking enemy ship. It had far more frames of animation than I needed so I cut out some of them. Now the hard part is knowing how spaced they need to be from each other. I have no idea how good Visual Studio 2010 is about that (I suppose I should have probably mentioned that was the program I've been using).
Looking at the mine and player animation pictures, both have 8 frames but they are spaced much differently, so I have hope that the program is fairly good about that kind of thing. The explosion animation has 12 frames, so I am fairly sure there isn't a required number of frames or spacing.
I figured most of the stuff from enemy.cs would be the same so I copied that over to Enemy2.cs and decided to change a few things. I figured I'd give the enemy more health but make it slower and worth more points. Actually enemy.cs is fairly small, a lot of what is done is just
As I went through Game1.cs I added calls and stuff for the new enemy I found an interesting line in the AddEnemy method. enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true); I believe those numbers are what tells the program how big each frame is and how many there are. I think it is width, height, number of frames, and something else. Might be frames per second, it was set to 30 and that seems fairly standard, though changing it doesn't seem to have a large effect.
Opening the mine animation in paint and looking at the pixels, width and height are almost surely the first two numbers.
After adding Enemy2.cs and changing the AddEnemy method I get the new enemy to spawn though there are a number of issue.
One: The new enemy and the old one spawn on top of each other, I expected this to happen once in a while, but since they spawn at the same instant and since the randomness is based on my computer's clock, they always spawn in the exact same space.
Two: The white background appears so the enemy ship is encased in a white block
Three: The speed, score, and everything else is using the regular mine enemy's stats (Killing it is worth as much as killing a normal enemy, it moves as fast, etc.)
Four: The animation needs more frames, it looks kinda wonky as is, but that is a minor problem
Next time I want to resolve some of these problems.
Edit: By setting a second randomly determined position they still spawn at the same time but at different positions. Of course they still sometimes spawn on top of each other or partially on top of each other.
Edit2: Yeah, couldn't help but play with it more. Got the second enemy to spawn, seemingly using their own stats (based on their slower speed) by adding a for loop in the update enemies for the enemy 2s and adding a bit in the draw segment. Now I haven't done anything with collisions so all I have to go on is speed, they pass through the ship. Also need to drastically lower their spawn rate, the game would be crazy impossible at their current spawn rate.
No comments:
Post a Comment