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 / Continuous shooting problem

Author
Message
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 4th Sep 2004 06:27
I got i bit of a problem. I can't sus out how to do continuous shooting.

i found a thread that when on about it but it looked as if it'll do only 100 shots and have to be reset which seems like a rum do to be honest.

is there a simpler way to do it, or will it have to be done with an array?

cheers

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 4th Sep 2004 06:51
can this help?
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 4th Sep 2004 07:07
eeeek

all i wanted was code to help with shooting in a shoot-em-up game like space invaders (not actually space invaders but 3D based) not a FPS (sorry if it isn't).

and a few comments would be nice in the code anyway.

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 4th Sep 2004 07:19
Yes, an array is a good idea. Figure out how many shots you simultaneously on the screen and that will be the size of your 'gun queue'. Once you exceed the max on-screen shots allowed, you start over at the beginning of the array.
--
TAZ

"Do you think it is wise to provoke him?" "It's what I do." -- Stargate SG-1
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 4th Sep 2004 09:08
i can try but i still don't think an array would allow me to constantly shoot until i let go of the space bar.

wouldn't it delete any objects or throw up an error if i reset an array?

i need to know as many solutions to my problem as there is and find out which would be the best choice.

i'll give it a go 2morrow anyway and see how it goes. fingers crossed

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 5th Sep 2004 04:09
I've had a go at it an no luck at all.

i'll post my code that i'm using so far and could u tell me where i'm going wrong.

i know its not the neatest but it's working prety well so far. just click the scource button below to have a look.

i've maked where it needs looking at.

oh and one more thing. It keeps throwing up this error

#100008: parameter for 'object exist' do not match 'object number' at line 288

(line 288 is the 1st line of the move_bullet() function if u don't wanna look for it)

i know what its on about but i just can't seem to figure a way round it

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 5th Sep 2004 04:46
You don't actually reset the array...

When the shoot button is clicked, you go to a subroutine to search for a bullet object to use, like this:

(There is a little bit of psuedo code...)

Place this code in your setup code, before the loop


Place this code in your loop


This is the subroutine, place it outside of your loop


Is there anything you don't understand?

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 5th Sep 2004 08:12
yeah...

there's nothing to say about moving the shots.

it look as though the code says that the shot will be placed where u want it and thats it, it stays there without moving.

i know u said it had psudo code in it but i'm a bit lost with the second part.

i'm gonna have i tinker with it. but could u explane it to me a bit just incase i can't grasp it. and i'll take your word for it as u did do "firewall" and that obviously has shooting in it.

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 5th Sep 2004 09:32
couldn't figure it out from it all so i desided to make my own up.

it seems to work as it threw up an error saying object didnt exist because it overshot on counting till i fixed it, but it don't show anything on screen. could be summat i done wrong.

anyway heres the code i'm using. it looks to see if the spacebar is pressed and then runs the code below. the update_bullets sub should move the object up the screen.



did i mess up somewhere and its all wrong or have i made i slight mistake?

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 5th Sep 2004 09:40
First, have you made sure you've created all the bullet objects? I.e., you should have a loop to create all 100 at the start of your program:



I just created a cube to demonstrate, but you could create a cylinder or even load in your own object.

Also, there's another problem with your code though, you're checking if a bullet goes off-screen and then minusing the last bullet by 1. So what happens if Bullet #5 goes off-screen? You still only minus one, so the next loop will move Bullet #99 even if 99 was still on-screen. So there way you're doing it probably isn't the best, but it's a good start.


"Computers are useless they can only give you answers."
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 5th Sep 2004 21:12
i've made the objects for me weapon. yeah ok i'm not upto scratch with it coz this is my first time doing a 3d game so the codings different to what i'm used to.

At the moment i need some guidence in this. lets take this step by step shall we?

1. so far i've created the objects for the weapon all 100 of them



this seems to work as it doesn't throw up any errors at all

what do i need to do next? i've tried as it shows up above but now i'm lost. i'm also sure i'm not that far off getting it right but its come to a hault

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 6th Sep 2004 01:40
i managed to get the shooting part to work after a fashon. heres the code i'm currently using.



now i've come accross a problem. When 50 shots are fired it throws up an error saying that the object doesn't exist when it tries to retrieve the 1st shot fired. now either its a DBpro error or the shots out of bounds and been deleted.

if thats the case how do i get around it. also how do i put a delay between shots?

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 6th Sep 2004 03:39
Oh yeah...I sort of thought you had the moving part figured out.

Here is some code that will move your bullets. However, remember that you have to get things set up when the bullet is shot, like the angle and speed. So here are the new code snippets.

Bullet setup:


Shoot bullet:


Move bullets:


Find bulllet:


There are arrays for the angle of the bullet. One revolves around the y axis, the other is for how high the bullet moves. Remember, you only need two angles in 3 dimensions. There is also bulletvel#, the velocity of the bullet. This is just how fast it moves, currently 2.0 units per frame.

Now remember that there is an easy method of making the program run the same speed on all computers, even at different frame rates. Simply set up a variable that is inversely related to the frame rate, like this:

gspeed#=60.0/screen fps()

Now whenever you move and object, multiply its movement distance by gspeed#. And set the sync rate to 0. It works great.

About timing...I put a timing method in my example.

Anything else?

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 6th Sep 2004 05:16
yes there is

maybe i should of said that it is a retro type space shoot-em-up game, but in 3D.

so the shot is only going on the y axis so far.

if i can get it out then i can sort out collisions and other bullet types and maybe one that locks on to an enemy till its dead and goes for the next. (who am i kidding )

i'll see where i've gone wrong in the meentime and keep ya posted on it

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 6th Sep 2004 19:58
Good news!!!!

i got it sused. and i didn't need an array either.

its not quite what i had in mind but it will do for now. heres how i managed it and i know it isn't the neatest code but i stuck at it and it does work. it only shoots 50 bullets at a time and waits for then to go off screen at the moment. then it starts again. it doesn't include any collisions yet but i'll sor that out later on.

who knows it might even come in handy to some 1.



(the 2 subroutines that do all the work)

p.s.
I'm pretty chuffed with myself now

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 7th Sep 2004 03:41
Good job, I am glad you got it figured out your own way. Actually, that is very similar to my methods...I just use arrays to hold information like wether a bullet is on, hold it's object number, and velocity, etc...

Not to make you feel bad, but you will probably use arrays for the bullet stuff eventually. Think about it...would you want to do this:

bullettarget1=0
bullettarget2=0
bullettarget3=0
bullettarget4=0
bullettarget5=0

Or this:

dim bullettarget(5)
for n=1 to 5:bullettarget(n)=0:next n

Get it?

Good Luck on your game.

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 7th Sep 2004 05:58
cheers.

i know i'll use an array sooner of later. but it's ok for the time being.

and anyway i don't know how many vars i got defined just in case. its an old habbit i used when i made my games in DOS. i kinda tried to port the method over and i seems to of worked

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D
DLS
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 7th Sep 2004 07:36
oh one more thing

to delay the shot for about 1 10th of a second what would i need to put after this statement

If spacekey() = 1 and bullets_fired < 50

would it be

If spacekey() = 1 and bullets_fired < 50 and timer()-shoottime>100

and what would i need to do to make it work

(just upgraded) system specs: AMD XP 3000+, 512Mb DDR333, nvidia ge-force FX 5600 128MB, 1x8Gb & 1x40Gb HHD, 52x CD drive, DVD+RW 4x, Sound Blaster 128.... all in a Nokia 8310 case :0D

Login to post a reply

Server time is: 2024-11-27 08:45:00
Your offset time is: 2024-11-27 08:45:00