Computer Science Canada

help with shooter game

Author:  Schaef [ Fri Feb 20, 2004 5:08 pm ]
Post subject:  help with shooter game

This is just the start of a small shooter game that I am going to try to make. The problem with it is that when i reload it ends up taking more then one clip away. How can I make it so that the amount of clips only goes down once even if the reload button is held?

Author:  shorthair [ Fri Feb 20, 2004 5:19 pm ]
Post subject: 

your using input.KeyDown thast your first problem , becuse that takes whats in the buffer , it knows when it was hit and relesed , you need to use getch i belive to just get it once , it only takes it character at a time till a charater matches ,i know that the proble m becuase blitz has a Input.KeyPressed , and Input.KeyDown, so i know its to do with that statement

Author:  Paul [ Fri Feb 20, 2004 5:20 pm ]
Post subject: 


if chars (KEY_TAB) and clips >0 then
delay (100)
fork reload
end if

Computer is too fast, I changed it to here, and it works.
You can still have negative clips though, plus if you press tab for too long, it still takes more than 1, you could even make the delay longer, it takes more than 1 millisecond to reload in real time too

Author:  josh [ Fri Feb 20, 2004 5:39 pm ]
Post subject: 

this looks like it's going to be a really neat game. Keep up the good work. (I really like the shotgun sounds)

Author:  Cervantes [ Fri Feb 20, 2004 5:51 pm ]
Post subject: 

if you have turint 4.0.5 then you can use Input.Flush to clear the buffer.
I would definately use that over processes.

EDIT: or you could put a small delay in the if chars (KEY_TAB) part

Author:  Schaef [ Sat Feb 21, 2004 8:13 pm ]
Post subject: 

wat kind of code could i use so that i can tell the program to do something once the gun is shot at a ball that i am going to make come onto the screen?

Author:  Schaef [ Sat Feb 21, 2004 8:26 pm ]
Post subject: 

Right now I am using

if buttonmoved("up") and whatdotcolor(cx,cy)=2 then  %2 is the colour of the ball.

but I have heard that watdotcolor is not a good method to use b4

Author:  Cervantes [ Sat Feb 21, 2004 8:26 pm ]
Post subject: 

you can use an if statement.


if mousex > ballx - ballradius and mousex < ballx + ballradius and mousey > bally - ballradius and mousey < bally + ballradius and mousebutton = 1 then

EDIT: if you know functions you could make your code a lot neater by putting that if statement into a function that returns true or false and then later calling the function.