Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / How to shoot a gun in a 2d enviroment

Author
Message
Avalanche_ Akshay
19
Years of Service
User Offline
Joined: 27th Jun 2005
Location:
Posted: 16th Aug 2005 14:22
i really must know how to shoot a gun in a 2d enviroment. i know some basic codes but i need to shoot multiple bullets find a way to increases the velocity without decreasing the velocity. If you guys could help it would make it easier. here is what i know about shooting in 2d enviroment. first the bullet has to come to you second the bullet has to move depending on which direction you face.
(this cannot be used with multiple shots)

speed#=2
sync on
do
cls
make the guy move and jump and stuff*
sprite bullet,b#,y#,bullet
inc b#,speed#
make a basic comand so that the person faces the way you want it to. use a variable to do so. if facing#=1 then the person face right if it is 0 the person faces left.*
if facing#=0 then speed#=2
if facing#=1 then speed#=-2
if spacebar()=1
b#=xpos#(players position)
y#=ypos#(players position)
ypos#=y#
endif
now just add gravity and the bullet moves, however if you repetedly press space bar it shall look like a taser*
sync
loop
*not real code
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th Aug 2005 14:36 Edited at: 16th Aug 2005 14:38
You will probably need arrays.

like this:


*not tested

Immunity and Annihalation makes Immunihalation...
Avalanche_ Akshay
19
Years of Service
User Offline
Joined: 27th Jun 2005
Location:
Posted: 16th Aug 2005 14:52
thanks for the info but i find your whole code to complectated, i thought that it would be better to clone the bullet(about 50 times!!) . but i found an easier way which is not tested.
for the sprites number value of recognition which i put as bullet you could instead do this

it would still be difficult to control more than one but thanks to your codes i think i shall be able to understand it.
Avalanche_ Akshay
19
Years of Service
User Offline
Joined: 27th Jun 2005
Location:
Posted: 16th Aug 2005 14:53
also could u explain your code.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 16th Aug 2005 22:13 Edited at: 16th Aug 2005 22:16


I added a couple of things than in the previous code.
I cannot guarantee that the code will work, since I didn't test it. If something isn't right, please tell me.
The code is fully commented

Immunity and Annihalation makes Immunihalation...
Avalanche_ Akshay
19
Years of Service
User Offline
Joined: 27th Jun 2005
Location:
Posted: 17th Aug 2005 00:33
thanks
i think i understand now, never used case comand before
how do you state infinity?
without causing a major system shutdown.
i only know basics
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Aug 2005 21:35
A computer will never know what to do with infinity. Infinity isn't even a number. So you won't be able to state infinity.

Immunity and Annihalation makes Immunihalation...

Login to post a reply

Server time is: 2024-09-24 01:33:10
Your offset time is: 2024-09-24 01:33:10