Over the last week I’ve been *extremely* busy, polishing Spacebat until I can see my reflection in it.
Here’s a condensed list of what I’ve done in the past week:
1- shield now makes an explosion sound when it gets hit
2- planets replaced with darker sprites – to make them blend in a bit more
4- added in a message that recommends reading through the help pages when starting level one for the first time
5- Hot Box logo now fades in/out on the splash
6- added in radical super dive sound
7- fixed the layer that the blue glow is on for the edges of levels to be on top
8- black holes no longer spawn near the edges of the survival
9- completely re-written the Facebook posting system, now more stable.
10-each star rating has a different picture to post on the Facebook thing
11-revised the snake spawning intervals on survival, now appear slower and in a better order
12-fireballs and snake snot now get affected by black holes
13-rewritten the trippy snake script to make the trippy snake more trippy
14-cleaned up/optimised various code blocks
15-implemented a new camera system – partly due to the new trippy snake script
16-camera stops instead of following Spacebat when dead
17-revised diving system
18-Spacebat now flies upwards when completing a level
19-credit stars are now longer
20-all objects now sparkle when they get sucked into a black hole
21-created and implemented a system to control the snake spawning more accurately
22-fixed issue where the dive buttons were inside the virtual key for flapping – this caused spacebat to dive left/right slightly before diving down when pressing different areas of the center dive button
23-revised the upwards dive at the end of the level – sticks around for a second, charges up and then performs a upwards super dive
I’ve removed everything from the list that wasn’t a bug, otherwise it’d be at least twice as big. Anyway, I figured that I’d go through how I went around creating my latest masterpiece, I call it the Uber Snake Selection System.
There I sat, playing the new survival with the recently rewritten snake spawning script, and while it was great, I found that there wasn’t a very good distribution between the snakes, it just took the amount of snakes to be spawned and distributed the selection evenly, resulting in the same amount of each type of snake.
My idea was that depending on the score, each snake would have a different chance to be spawned until all of the snakes were available at 200+ points, then the chance to be spawned, or weight, would be set in stone.
I first started out by deciding when the intervals at which the new snakes would be ‘activated’ and allowed to be considered for spawning. Then depending if the set intervals have passed or not, I would populate an array with each snake’s weight, which is an integer (a whole number).
Now that we have each snake’s weight stored, we can go about picking a snake.
The first thing that happens is the total weight of all of the snakes is contained in a variable. Next, a random number from 0 – total snake weight is chosen.
Now we use this random number in a ‘while’ loop to keep removing each snake’s weight from the chosen number until there is no weight left, by time this happens, the loop has ran a maximum amount of 8 times, allowing me to pull a number from it and then return that number as the position in the array in which all of the snakes are stored.
In short, this new system allows for a much higher amount of control over the snake spawning system, and in-turn allow us to make survival all that more interesting.