Computer Science Canada Help with Firing bullets and collision detection |
Author: | Teh_Pwnerer [ Mon Jun 20, 2005 2:17 pm ] | ||
Post subject: | Help with Firing bullets and collision detection | ||
Note: What I couldn't fit in the title is that both things I need help with are pictures. Anyway, here I am again, seeing as how my account got deleted, and posting this again. I finally got my ship to fire a bullet (yay!) but there's a problem. I have to hold space bar to move the bullet. I want the bullet to go when I press the space bar once, I don't want the bullet just to stay there if I don't hold it. Then there's the collision detection thing. I have three pictures: a ship, an enemy that appears at different y-co-ordinates, and a bullet. I need to make it so that when the bullet hits the enemy, it disappears and the score goes up by 10, the latter of which I can do. Then I need to make it so that if the ship collides with the enemy, the screen goes black and it says "Game over". The latter of which I can also do. Then after 3 enemies are defeated there will be another level, where the enemies appear in larger numbers and move faster. After that level the game's over unless I get alot of help with the levels and stuff tonight cause I can't work on it tomorrow as it's due. This is my code so far:
|
Author: | vagyb [ Mon Jun 20, 2005 8:37 pm ] |
Post subject: | Re: Help with Firing bullets and collision detection |
Quote: I have to hold space bar to move the bullet. I want the bullet to go when I press the space bar once, I don't want the bullet just to stay there if I don't hold it. Then there's the collision detection thing. I have three pictures: a ship, an enemy that appears at different y-co-ordinates, and a bullet. I need to make it so that when the bullet hits the enemy, it disappears and the score goes up by 10, the latter of which I can do. Then I need to make it so that if the ship collides with the enemy, the screen goes black and it says "Game over". The latter of which I can also do. Then after 3 enemies are defeated there will be another level, where the enemies appear in larger numbers and move faster. After that level the game's over unless I get alot of help with the levels and stuff tonight cause I can't work on it tomorrow as it's due. This is my code so far:
okay for one u need to do collison detections , i would suggest use whatdotcolor, make the bullet red and if the bullet x and y + like 10 or something = black (make the outside of astroids a nice thin black color) then exit, and pic.draw the broken up astroid. and also a cool trick to makin the bullet disapear is after u write whatdotcolor bla bla then bulletx: = -40 or something and bullety: = -50, so it takes bullet off screen. and also make a variable var score int:=0 and when the whatdotcolor collison occurs put then score += 10,. and also make a secondary counter for each enemy u kill and a variable for speed of astroids, and multiply all speeds of astroids by the speed. (var speed: int:= 0) and whenever the counter for killing enemies is >3 then change the speed to to 2 or something this way everythin speeds up.[/quote] |
Author: | Cervantes [ Tue Jun 21, 2005 10:01 am ] |
Post subject: | |
First, learn to use arrays. Then, learn to use flexible arrays. In that flexible arrays tutorial, there's an example of how to do bullet firing. There's also a collision detection tutorial. Really, it's all in the walkthrough. Just go through that. ![]() |
Author: | Mr. T [ Mon Jun 27, 2005 2:17 am ] |
Post subject: | Alex's Opinion |
Kinda hard to learn that all in one night, seeing as how the project was due the next day. ![]() |
Author: | MysticVegeta [ Fri Jul 29, 2005 7:33 am ] |
Post subject: | |
why not start a week earlier then ![]() |