forums

TNT Basic Forums > Programming Q&A
aaaah help
< Last Thread     Next Thread >
Author
Thread        Post A Reply

02-09-2003 18:43

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

i think im going mad
i just cant get my bullets shooting up the screen
all i have managed so far is to get 1 bullet to shoot by pressing space which is then cancelled when you press space which fires the same bullet again from the start, no good!

if anyone can help it would be greatly appreciated

i want to have multiple bullets firing at the same time
in a semi-automatic style ie 1 bullet each time you press the spacebar


02-09-2003 20:32

Posted by:
ERaZer

Click Here to Email ERaZer   Find more posts by ERaZer

You need to create new bullets every time you shoot, and when the bullets leave the screen(or whenever you want to) delete them.

02-09-2003 21:25

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

but how?
i could post my code
its not very long

02-09-2003 21:47

Posted by:
matteo

Location:
Venice, ITALY!

Click Here to Email matteo   Find more posts by matteo

you must use arrays.
I hope you know what they are: ther are a "thing" that contains many numbers:

so if before you had bulletx, bullety, now you have bulletx[10] and bullety[10], each of those contains 10 numbers: bulletx of the first bullet is bulletx[0], bulletx of the second bullet is bulletx[1]...

there may be more than 1 bullet on the screen.

so you should have a variable "bulletexists[10]" that tells you wich bullets still are on the screen.

so:

if pressed space
make the first bullet that did not exist before now exist
set bulletx of that bullet =...
set bullety of that bullet =...
end if

for i=0 to 9
if bulletexists=true
sprite i, bulletx, bullety, spritepict
bulletx=bulletx+3
if bulletx>640 then bulletexists=false
end if
next

hope you figure out this stuff

02-09-2003 22:39

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

grrrr

i had something similar tto that before


'shooting
if pressed(49)
for n=0 to 29

if bulletexists[n]=true

bx[n]= sprite x (ship2)
by[n]= sprite y (ship2)

set image bank bulletstart+n,bulletbank
set sprite transparency bulletstart+n,50
sprite bulletstart,bx[n]-17,by[n]-65,bulletstart
move sprite bulletstart+n,0,-480,bs
if by[n]=0 then bulletexists[n]=false
end if

next n

end if

but it still wont work
please put me out of my misery

02-09-2003 23:27

Posted by:
matteo

Location:
Venice, ITALY!

Click Here to Email matteo   Find more posts by matteo

if pressed(49)

NONNONO:

YOU MUST DO:
IF PRESSED(49) AND (SOMETHING TO AVOID IT SHOOTING ALL THE BULLETS TOO QUICKLY)

WRITE THE CODE TO FIND THE "N" OF A BULLET THAT DOES NOT EXIST

BULLETEXISTS[N]=TRUE
AND HERE YOU WRITE

bx[n]= sprite x (ship2)
by[n]= sprite y (ship2)
set image bank bulletstart+n,bulletbank
set sprite transparency bulletstart+n,50

END IF

THEN

for n=0 to 29

if bulletexists[n]=true



sprite bulletstart,bx[n]-17,by[n]-65,bulletstart

THIS IS ANOTHER PROBLEM: FOR MANT SPRITES, YOU MUST HAVE DIFFERENT SPRITE NUMBERS!
SHOULD BE:

sprite**bulletstart+N**,bx[n]-17,by[n]-65,BULLETIMAGE!


move sprite bulletstart+n,0,-480,bs

MOVE IT SLOWLY!

if by[n]=0 then bulletexists[n]=false

NONONO : IF BY[N]<0 ...
end if

next n

end if

TERRIBLE CODE ;)

02-10-2003 00:15

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

yep your right
my coding is pretty bad
but ive only been using tnt for 2 days

anyway, if i am to have different sprite numbers
does this mean i need to have a different sprite for each number or can i achieve this another way
thanks for your help so far
charlie :0

02-10-2003 03:20

Posted by:
matteo

Location:
Venice, ITALY!

Click Here to Email matteo   Find more posts by matteo

I call "sprite" not the image of the sprite: if you have two bullets you have two sprites with the same image.

when you call sprite:

sprite spritenumber, sprX,sprY,spriteImage

you must choose a different sprite number for every sprite you have on the screen.
Otherwise if you call again the same sprite, it removes that sprite and places it in another place:
You should just get a number for each sprite, no matter what number, just so you can call it afterwards.

sprite**bulletstart+N**,bx[n]-17,by[n]-65,BULLETIMAGE!

you see: here you sprite **bulletstart+N**!! so there are say 5 bullets: one is sprite 2, one is sprite 5, one is sprite 8...
You need to have an array to know wich are still on the screen: that is bulletxists

so if bulletxists[n]= true you sprite that sprite, whoose number is bulletstart+N, with the control:

sprite**bulletstart+N**,bx[n]-17,by[n]-65,BULLETIMAGE!

BULLETIMAGE is the number of the image in your sprites image archive

Another thing:

dont use
move sprite bulletstart+n,0,-480,bs
,you' ll never know the sprites x and y.

put bulletx[n]=bulletx[n]+xspeed...


Hope you manage...

02-10-2003 09:50

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

im still a bit stuck
does anyone know of any source code for this kind of thing that keeps it simple
or even post some here
im sure im stuck on the most stupid of things

charlie

02-10-2003 23:16

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Posting code on boards isn't a good idea; it isn't tabbed and has no programmation context. E-mail me your project and I'll look at it.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.