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 / help with shooting

Author
Message
TravisP
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: Behind you, with a knife!
Posted: 4th Jul 2004 06:26
-DBC-
I am trying to make it so my plane can shoot a machine gun. But this code dosnt work. Any suggestions?

--- Troan ---
|)a l33t n00b!e
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 4th Jul 2004 07:48
Okay...

Well first, I note that you have made the sprite image being used as "check+2" when you have only loaded and saved two pictures! (The plane as 1 and the bullet as 2.) Sprites need an image to work with, and since #2 is your bullet, the LAST prarameter of the sprite command must be 2!

Second, and though you have not written the code for this, the bullety() value keeps getting decremented constantly, so the sprite is going to go off the screen VERY FAST, meaning you may not even have time to see it!

And third, because you do the keyboard detection as part of the main loop, if you do anything but "tap" the spacebar very quickly, you're going to "fill up" the array and use all your bullets at once. You need a method to "slow down" the response time of the program to keyboard actions; either a wait X command or a timer based function.

Good luck with your efforts!
S.

Any truly great code should be indisguishable from magic.
TravisP
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: Behind you, with a knife!
Posted: 4th Jul 2004 08:42
Thankz! its working but now it only shoots one bullet then it stops . Any suggestions?

--- Troan ---
|)a l33t n00b!e
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 4th Jul 2004 09:05 Edited at: 4th Jul 2004 09:06
Okay...

And PS; thank goodness you posted the updated code for me, otherwise I'd be lost!

You still have the same problem... What I mean is, your bullet check command "uses up" all possible bullets for any press of the spacebar, because it does not "exit" when you have declared a bullet as being fired. Try this instead;



The problem is, you aren't counting up the bullets right, and bypassing the others remaining the store or already active.

S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 4th Jul 2004 09:10
Oh yes...

I'd also like to add a point about "releasing" the space bar to that. What I mean is, again because of the speed of the main loop, you might want to try something like this;



Then, in your timer routine, add the line of

Space = space-1

to delay the firing of multiple bullets...

S.

Any truly great code should be indisguishable from magic.
TravisP
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: Behind you, with a knife!
Posted: 4th Jul 2004 09:18 Edited at: 4th Jul 2004 09:33
thankz.
this helps some but it cuts out the
if current=check then bulletx(check)=shipx+20
becuase it dosnt go to next check
so now it looks like this.... oh and
and the timing didnt i alrdy do that here.....

PS(that wasnt on first post)

--- Troan ---
|)a l33t n00b!e
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 4th Jul 2004 09:40
Actually, it doesn't cut out the check.... unless you are using that to control your sprite at the same time as the spacebar check. Then, you DO need to add another routine to update the bullet position for each pass through the loop. But that movement should NOT be a part of your fire code anyway, so I don't know why it's important to you. (the fire code should be in your controls section imho.) The IF-ENDIF I used didn't remove anything, it just added a qualifying parameter as to how often a bullet could be fired.

And the new timer code should be;

time:
time=time+1
space = space - 1
if space < 0 then space = 0
if time>1000 then time=1000
if time=1000 then gosub shoot

or;

time:
time=time+1
dec space
if space < 0 then space = 0
if time>1000 then time=1000
if time=1000 then gosub shoot

S.

Any truly great code should be indisguishable from magic.
TravisP
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: Behind you, with a knife!
Posted: 4th Jul 2004 09:53
o i found what my prob was that i didnt use


thanks SandraD

--- Troan ---
|)a l33t n00b!e
TravisP
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: Behind you, with a knife!
Posted: 4th Jul 2004 11:02 Edited at: 4th Jul 2004 11:04
AGH!!
i get this erorr that makes no sense when i try to change array.
Rutime Error at line 49. bobs range from 1 to 65535 at line 49
the problem seems to be this...


i dont see whats the matter with it.
Anyone plez help. thank you

(PS: All of it in source.)

--- Troan ---
|)a l33t n00b!e
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 4th Jul 2004 12:51
Trojan...

In this case the error is a correct one, for you have Delete sprite check when check starts out as ZERO in the for loop! Like the error says, sprites, images and such start at #1, not #0.

Change your zeros to 1...
S.

Any truly great code should be indisguishable from magic.
TravisP
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location: Behind you, with a knife!
Posted: 4th Jul 2004 13:42 Edited at: 4th Jul 2004 13:43
thx!! yes no more promblems

(PS:name is Troan not Trojan )

--- Troan ---
|)a l33t n00b!e
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 5th Jul 2004 02:54
Oh, okay.. fingers adding characters to my words again... hehehe.
S.

Any truly great code should be indisguishable from magic.

Login to post a reply

Server time is: 2024-11-26 23:38:50
Your offset time is: 2024-11-26 23:38:50