aka "so, you want to write a game, do you?"
© 2008 PeeJay
© 2008 PeeJay
Warning: Undefined array key "keywords_en" in /mnt/web218/a3/28/510129628/htdocs/main.php on line 234 Warning: Undefined array key "description_en" in /mnt/web218/a3/28/510129628/htdocs/main.php on line 235 Warning: Undefined array key "commercials" in /mnt/web218/a3/28/510129628/htdocs/main.php on line 261
SELECT pldir CASE 0 bull.buldifx=0 bull.buldify=-8 CASE 1 bull.buldifx=-6 bull.buldify=-6 (etc) ENDSELECTSELECT is a quick way of doing lots of IF - ENDIF's testing the same variable - in this case, pldir. I could have just as easily have been written:
IF pldir=0 bull.buldifx=0 bull.buldify=-8 ENDIF IF pldir=1 bull.buldifx=-6 bull.buldify=-6 ENDIF (etc)but using SELECT can save you quite a bit of typing! Just as with the enemies, for every game loop we need to update the bullets, and when drawing the screen, we will need to draw the bullets. Now, run the program - woohoo, we can fire! But, we have a problem - our character seems to have some sort of mega machine gun! This is because every time the player is updated, we have the capability of adding another bullet? Can you think of a way of slowing down the firing? This will be discussed in the next lesson, as well as using this system to add a firing graphic to our main character. If you've understood everything we've done so far, well done! We've discussed some fairly difficult topics, and, although they are only used very simply in this game, a little imagination could produce something extremely complex. If you have an idea on how to slow down the firing, very well done indeed - programming is all about solving problems by logical thinking. If you haven't, again, don't worry - you'll see how I've chosen to do it in the next lesson, and hopefully you'll remember how to do it for your own games.