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 / Shooting Help!

Author
Message
Seboolek
16
Years of Service
User Offline
Joined: 2nd Oct 2007
Location: POLAND
Posted: 23rd Nov 2007 13:59
Hello

I need help a Shooting.
I don't now how to make Shooting. Please. Help!

This is a Code.


My English is poor. I'm From Poland. I make a Zombie game in GTA Style. But i don't now how to make a shooting.

Thanks
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 24th Nov 2007 04:32 Edited at: 24th Nov 2007 04:36
i've added a basic shooting routine to your code to get you started. the code i added is outlined with:

******ADD THIS*****
...
*******************



use the left mouse button to shoot.

i hope this helps to get you going... plenty more to add including collision, etc, but this is a start. work with it, modify to suit your needs, etc, and enjoy

edit: i should have added some comments to the code to let you know what i was going for/what's going on, but i don't have time for it right now. look at the code and let me know if you have any questions?

Virtual Nomad
AMD XP 1800+ (~1.6 Ghz) / 1.5 GB RAM
ATI Radeon 8700LE 128 MB / Windows XP
Seboolek
16
Years of Service
User Offline
Joined: 2nd Oct 2007
Location: POLAND
Posted: 24th Nov 2007 20:26
Very Nice! Thanks But bullet has disappears after renewed a click Left mouse button.

Thanks for Help I Use this
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 25th Nov 2007 03:20 Edited at: 25th Nov 2007 03:22
that was to get you started with one method of "shooting". you'll want to add additional bullets, etc. to suit your needs.

look at the code, see what's going on, then develop it further.

good luck

Virtual Nomad
AMD XP 1800+ (~1.6 Ghz) / 1.5 GB RAM
ATI Radeon 8700LE 128 MB / Windows XP
Seboolek
16
Years of Service
User Offline
Joined: 2nd Oct 2007
Location: POLAND
Posted: 25th Nov 2007 18:58
I try but i don't know how to make a Machine gun... Bullet alweys disappear. I search in a forum but i can't find how to make that.
Flyin Mushroom
17
Years of Service
User Offline
Joined: 12th Jun 2007
Location: Arkansas
Posted: 27th Nov 2007 04:29
Heres some code of a machine gun, but I had to edit alot because I had sound and different weapons added. Theres a place where you can put a gun, but i turned it into a invisible box, and the bullets into spheres. I hope some of unnessary coding dont distract you too much.

I still need to modify it alittle bit, because it looks like not all the bullets dont move until the trigger button is Released

hide mouse : sync rate 0 : sync on : autocam off
backdrop on : color backdrop rgb(0,0,0)

dim bullet#(40,3) : gunx#=0 : guny#=0 : gunz#=0

rem -------------- PLAYERS POSITION
make object cube 1,15 : hide object 1

rem ----------- THIS WOULD BE GUN, but is currently a hidden box out of position
make object box 2,1,1,1 : hide object 2
yrotate object 2,180 : fix object pivot 2 : set object rotation zyx 2
gunx#=x# : guny#=y#-100 : gunz#=z#


rem --------------------- MAKING BULLET OBJECTS
for l=0 to 40
for b=0 to 1
ll=4+(l*2)+b
make object sphere ll,1 : scale object ll,300,300,750
set object rotation zyx ll : hide object ll : next b : next l

rem -------- BULLET VARIABLE
bilbul=0

do

set cursor 20,20 : print "Bullets: ";95-bilbul-5
set cursor 20,60 : print "USE LEFT MOUSE CLICK 2 FIRE"
set cursor 20,80 : print "USE RIGHT MOUSE CLICK 2 FIRE (delayed)"


rem - Right mouse click uses the WAIT command, and might not work to well
rem - in a overall game, because it will freeze the screen.

olx#=x# : olz#=z#

position camera cx#,y#+30,cz#
rotate camera wrapvalue(cxa#),cya#,0

gosub machine_gun

sync : loop


rem ----------------------------------------------------------------------
machine_gun:

rem Control HIDDEN MACHINE GUN
g=0
gga#=wrapvalue((cya#-20)+(g*40))
gundx#=newxvalue(ggx#,wrapvalue((cya#-20)+(g*40)),10)
gundy#=y#-(sin(cxa#)*10)
gundz#=newzvalue(ggz#,gga#,10)
gunx#=curvevalue(gundx#,gunx#,1)
guny#=curvevalue(gundy#,guny#,1)
gunz#=curvevalue(gundz#,gunz#,1)
position object 2,gunx#,guny#+25,gunz#
xrotate object 2,wrapvalue(0-cxa#)
yrotate object 2,wrapvalue(cya#+180)

rem Firing
if mouseclick()=1 or mouseclick()=2
if mouseclick()=2 then wait 10
gunpressed=0
gunpressed=1

rem RELOAD FUNCTION ----------------------------------------------------

if bilbul>89
wait 10 : bilbul=0 : endif

rem Find free bullet
bf=-1
for b=0 to 40
if bullet#(b,1)=0 then bf=b
next b

rem Trigger bullet
if bf>0
rem ------ BULLET VARIABLE
bilbul= bilbul+1
objid=4+(bf*2)+0
bullet#(bf,1)=1
bullet#(bf,2)=0
tx#=object position x(2)
ty#=object position y(2)
tz#=object position z(2)
txa#=object angle x(2)
tya#=object angle y(2)
position object objid,tx#,ty#,tz#
rotate object objid,txa#,wrapvalue(tya#+90),0
move object objid,0.0
rotate object objid,txa#,tya#,0
move object objid,10
if object exist(objid+1)=1 then show object objid+1
endif
for adv=1 to 40
objid=3+(adv*2)+0
if adv<>rp and bullet#(adv,1)=1 then move object objid,-25.0
next adv : endif

rem Control bullet movement
for b=0 to 40

rem Bullet alive
if bullet#(b,1)=1

rem Move bullet
objid=4+(b*2)+0
move object objid,-40.0
ex#=object position x(objid)
eh#=object position y(objid)
ez#=object position z(objid)
position object objid+1,ex#,eh#-20,ez#
rotate object objid+1,wrapvalue(0-object angle x(objid)),object angle y(objid),0

rem --------------------- Refresh bullet
refreshbullet=0
bullet#(b,2)=bullet#(b,2)+1
if bullet#(b,2)>60 then refreshbullet=1

if refreshbullet=1
move object objid,50.0
ex#=object position x(objid)
ez#=object position z(objid)
bullet#(b,1)=0
endif : endif : next b
return
Seboolek
16
Years of Service
User Offline
Joined: 2nd Oct 2007
Location: POLAND
Posted: 14th Dec 2007 13:04
Hmm.. Good.

I try to make that but i dont know how its wrong...

Look that.


What is wrong?
Seboolek
16
Years of Service
User Offline
Joined: 2nd Oct 2007
Location: POLAND
Posted: 19th Dec 2007 20:36
Please. I need to shooting. I dont know how to make.

This is my game.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-09-27 08:16:49
Your offset time is: 2024-09-27 08:16:49