Powerups and trails

Well, I think I finally have a solid working system for all the base bullet powerups (levels 1-3).  I also have the health powerup spawning at two different points based upon the players health.  I also have the autofire and spreadshot powerups spawning.  If an asteroid that contains a powerup, I have it displaying a comet trail.  Each powerup, upon release, has its own little comet trail effect as well (to help the player find it amongst the morass of asteroids flying around).

I was having a little problem with a seeming random trail-renderer spawning while an asteroid was destroyed and then seemed to fly off screen (the trail, not the asteroid).  While I pondered it I started to think of the process.  OK, clearly, even though there is no trail rendered at that point, when the asteroid respawns offscreen, it’s getting the trail rendered, all the way from the point where it was last seen (hence a quick flash of a trail from the respawned original asteroid to the new spawn offscreen).

Upon reflecting about this sequence of events, I realized that I could just disable the trail-rendering until I know for sure that the asteroid will be on screen.  It’s probably smart to do that anyways, as I’m not using any CPU compute cycles then, to render anything offscreen.  I thought that this was sort of automatically taken care of, but it appears not.  So I added a check to see if the asteroid was visible and contained a powerup.  If it was, then I could display the trail renderer… But only once the asteroid becomes visible to the camera.

The couple short games  I played since then seem to indicate that the problem is fixed.  I won’t count my chickens yet, though.

The next question is: what powerups do I do next?

——————–

I can do the laser shot which is a pew pew type thing that will slice through any asteroids in its path and continue on its way.  The idea there is to score a multiplier effect such that for every asteroid it destroys scores exponentially more.

The next level to that might be a laser-beam which is a long straight narrow piercing beam that just shoots from the nose of the ship off screen and completely obliterates the asteroids.  Not sure how the scoring will work on that.  I think I’d like to use some form of exponential system to keep it tied in with the laser scoring, but it seems like it would be too powerful to just do pure exponential.  That said, there would be an energy stock for energy weapons like the laser so that you wouldn’t have an infinite supply of charge for it.

——-

I could do a shield for defense.  I have health up already as a somewhat “defensive” measure, but nothing else.

The basic shield would just be that.  A shield that lasts for a certain amount of time.  Powerups for the shield could include longer time periods, and a “retroflection” effect that causes energy to shout out in an arc and destroy multiple asteroids in a shockwave.  That might be more than I’m wanting to implement, but it could be cool.

——-

White Holes are another defensive measure I want to implement.  Initially I was just going to have mines placed around the perimeter of the black hole, but the problem there is if I place them behind me, and right next to the black hole – they would get eaten by the hole.  If I put them in front of me, fairly closely, they would block my shots…  Instead, I thought of a “white hole” vortex that would be able to consume the asteroids.  Similar to… Geometry Wars(IIRC), you could shoot the holes for a big bonus to your score.

——-

Anti-matter field is interesting, but a long term concept I want to add.  Essentially a huge shield that exists around the perimeter in front of you.  Asteroids would enter this field and their matter-polarities would invert and they’d become antimatter.  They would then enter the black hole and destroy some of its mass.  HOWEVER.  They are then a one hit kill.  Instead of just taking a small amount of life off, they would obliterate you regardless of how much health you have and how weak the asteroid is.  So use with caution.

——-

Nuke:  I think this is one of the next ones I want to implement.  Initially I wanted a complete nuke bomb, but I’m thinking I should have it work like the other weapons.  1st level would just destroy all red asteroids on screen, yellow would do red/yellow and green nuke would destroy every single asteroid on the screen.

I think an anti-matter nuke could be really cool – so you could not only destroy the asteroids but all the mass you destroyed would be subtracted from the black hole and reduce its radius… Hmm…

——-

I also need to add text effect for when the powerups spawn, and I’m thinking I might change the audio effect of the sounds for the spawned powerups — I want to get them to sound more robotic feminine.  Right now they’re very distorted and hard to understand.  I want it more like my original “Killing Horizon” vocal effect.  Sadly, I never saved the sequence of effects I used, so I don’t think I’ll be able to match that, but I hope I can come close.

I also need to add a health-bar (right now it’s just a simple numeric display), and an energy bar system for the laser/energy weapons.

It’s coming along, and I’m glad I (hopefully) got the bugs worked out of my current setup so I can go forward more confidently.

I’m really frustrated at my lack of optimization (30 fps on my work machine – easily 60 fps at home, which is good, but I have a solid system.  I want it to run on lower end systems as much as possible – considering it’s supposed to be a retro game and I don’t have anything too amazingly fancy, frankly, but that is part of the process of learning)

First 3 Powerups COMPLETE!

I got it working.  I now have Autofire, Spreadshot and 2 versions of health spawning.

The autofire spawns at a blackhole radius of 5.  Spreadshot is at blackhole radius 10.

The health I have spawning based upon the players health… at 70-79, a 10 point health restore can be gained.  at 50-59, a 15 point health restore can be gained.

I will probably be modifying these as difficulty warrants.

The next goal will probably be Bullet-Up (i.e. make the bullet worth 1 more hit point… the code is all there to do that, I just need to create the powerup spawn).

I also need to attach a trail renderer for powerups so they’re easier to see amidst the morass of asteroids.  Either a trail renderer or a particle system, not sure which.  Trailrenderer is damn easy, I know that much.

Regardless, this is very good news.

Powerups: Further down the rabbit hole

So, today I finally got to working on revamping the powerups.  I reworked it by adding a “hasPowerUp” boolean variable.  This let’s me easily determine whether my asteroid contains a powerup (I was trying to access the powerup value directly, but that led to issues regarding “null” vs “0” and indexing of an array and just a heck of a lot more complicated to resolve than making a simple boolean and checking that).

The good news is that resolved a lot of the problems I was having earlier.  I had to rejigger some of the state settings (that is – I have to check if I can embed a powerup in an asteroid, and then once I do, I have to tell it I can’t (until the next legitimate time to do so) — if you don’t, then it will keep spawning powerups.) This is, to me, one of the most annoying things about programming (in an non-Functional language… note: Functional here is a specific term of art, and not an adjective stating that the language I’m using (C#) is crappy or not functional).  Constantly setting states.  Now – using a functional language, you don’t have to deal with states, but then you lose the power of what states give you.  That’s a digression.

So I got that working, I am able to spawn both the autoshot and the spreadshot (god my spreadshot icon is FUGLY) at the required times, and they only spawn once so that resolved one of the issues I was having.  I also have a trail renderer that is properly attaching to asteroids that contain the powerups so players can see which asteroid has a powerup inside so they can target that asteroid specifically.

Now, however, for some odd reason, my code seems to have experienced bitrot on the “spreadshot” side.  I’m experiencing an issue where the delay for the autoshot mechanism is not being triggered properly when I get the spreadshot.  The main gun has a nice little delay, but the sideguns no longer have the delay – that is to say a pure stream of bullets ALL THE TIME with no spacing between them.  It looks cool and is one of those fun serendipities that happen when programming, but it’s definitely NOT what the doctor ordered.

So this is going to require some work to figure out why the side guns are not getting the proper delay for the autoshot.  It’s annoying, but in theory (always in theory!) it shouldn’t be too hard.

I think I worked about an hour and a half tonight.  What makes me happy is that I now have the foundation for all my powerups.  I just have to put in the right spawn times and the powerups to spawn and I’m good to go.

Since this is my first game and my code is crap (even though my friend says it’s not nearly as crappy as I think it is), I don’t think I’m going to do any fancy crazy algorithms.  I may do an occasional check to see if a given powerup hasn’t been obtained by the player so that they may get it as a drop again, but currently, the powerups don’t disappear.  This means they’ll just float around and around until the player gets them.  Of course, if they’re in spot that is impossible to get due to the way they move on the screen, that won’t help.  Perhaps I should have a time limit on them so that after, say, 5-10 seconds of life, they get destroyed.  Then I can check every so often and say “Did the player get autoshot?  No?  DROP IT AGAIN, SAM!  THIS TIME WITH FEELING!”

So, I’m happy.  Not 100% satisfied, but I never will be.  There’s always more to learn and to know that my code isn’t nearly as clean as I would like.  But that’s what happens when you “doodle” or “sketch” code instead of doing good planning.