Thursday, November 3, 2011

I'ma firin' mah laz0r

Ok, today is all about the lasers! Both making the enemy fire a little less predictably and exploring making the boss either fire faster or firing a different unique weapon.

The first thing I notice when looking at the projectile class is that I still have remnants of when I was trying to incorporate the enemy projectiles into the regular projectile class. I cleaned that up and moved to the main Game.cs to look for where the projectiles are implemented.

Both types of projectiles (player and enemy) are set to fire based on how much game time has gone by. Not sure if I could just use some random number generator to decide whether each ship fires when it spawns? The player's firing logic is in update player and enemy's is in update enemy which makes sense. There is already a random variable in use, and since to my knowledge the random is just based on your computer's clock time (down to the second or millisecond) having two randoms is sorta useless as each one would give the exact same value at any given millisecond.

So now I need to decide how often I want the enemy to fire. I don't want them firing constantly, that would be rather difficult, in fact I think I'd rather they not all even fire 100% of the time, maybe 60-70% of the time. If I knew the range of the random number generator that wouldn't be difficult to do. An if statement asking if the random value is less than half whatever the max number it could generate would make them fire half the time, and if I adjusted the that I should be able to get it to fire at whatever percentage of the time I want.

The logic may need to be moved to where the enemy spawns as being in the update section would just make it check constantly (and thus every enemy would fire constantly unless I made the thresh hold really low).

I know I didn't do much tonight, I pretty much just theory crafted a little bit, but I spent a bit long unpacking and am rather tired, a cop out, I know.

A question to Chris and Ben, you guys have any idea what the range of the random variable is in Visual Studios 2010? If you don't know I can look it up later.

No comments:

Post a Comment