alien invaders
Author |
Message |
shoobyman
|
Posted: Tue May 30, 2006 5:18 pm Post subject: alien invaders |
|
|
controls are mouse to move and click to shoot
this is for my alien invader game. it has 2 problems.
1. when you shoot, the laser moves with you.
2. when you let go of the mouse button, the bullet dissapears.
can anyone help me fix these problems?
Description: |
|
Download |
Filename: |
ALIEN INVADERS.zip |
Filesize: |
6.46 KB |
Downloaded: |
87 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheOneTrueGod
|
Posted: Tue May 30, 2006 5:54 pm Post subject: (No subject) |
|
|
Er... the answer is kinda staring you in the face in your code...
code: |
if button = 1 then
bulx := x + 2
buly += 10
drawline (bulx, buly, bulx, buly + 25, 12)
end if
if button not= 1 then
buly := 90
end if
|
you are allways setting the bullet's x to the mouse's x when the button is down, and if the button isn't down, then you're allways setting the bullet y to 90...
Instead, have a flag that keeps track of if the bullet is fired or not, and update the bullets position if it is fired. When the bullet goes off screen (or later hits someone) make it so the flag updates that. Make sure you can only shoot when this flag is false. (by flag, I mean boolean, though really, you can use anything for a flag if you feel like it.)
Of course, there are many better ways to do this, such as arrays or even better, flexible arrays, so you can fire more than one bullet at once (Though in the case of the 'alien invaders' game [if you're thinking of the same one I am], there is only one bullet anyways). That should pretty much cover it.
|
|
|
|
|
|
|
|