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.

DarkBASIC Discussion / sprite collision commands and BOBs

Author
Message
Naf
21
Years of Service
User Offline
Joined: 7th Nov 2002
Location:
Posted: 18th Nov 2002 19:11
im usin a sprite collision() command but when i try 2 run it it tells me that "BOB does not exist" but all my sprite numbers are right, anyone got n e ideas??
ill post some code here soon so u can see 4 urselves
cheers
Naf
if it works... DONT FIX IT!!!
just tweak it a bit around the edges till it dont work... THEN fix it!!!
-my BASIC programming motto
Kentaree
21
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 18th Nov 2002 22:31
I get that problem when I use the sprite commands, but the sprite hasnt been initialised, i.e. when you use sprite collision(1,2) before the commands sprite 1,x,y,1 and sprite 2,x,y,2 have been used. Try seeing if in all cases, both the sprites have been used yet.

Whatever I did I didn't do it!
Naf
21
Years of Service
User Offline
Joined: 7th Nov 2002
Location:
Posted: 19th Nov 2002 12:10
i have used the load bitmap command and then the get image command to load eleven sprites
i have then put all of these sprites onto the screen using the sprite <sprite number>,<coordinates>,<image number> command
i have got the sprite collision command at the end of a repeat... until loop
the line is
until j>800 or sprite collision (11,1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9)=1
as far as i know this shoud end the loop if j>800 or if sprite 11 collides with any of sprites one to nine
any ideas why not
there will be more code coming soon

if it works... DONT FIX IT!!!
just tweak it a bit around the edges till it dont work... THEN fix it!!!
-my BASIC programming motto
Naf
21
Years of Service
User Offline
Joined: 7th Nov 2002
Location:
Posted: 19th Nov 2002 16:28
the game i am making is the counterpart of a game that bog boy is also making.
the idea is to throw bombs at each other over a set of buildings.
here is the code i am using for the physics... its full of rems to make sure u all know what im doin
the problem is with the 'until j=>800...' line - it tells me 'BOB does not exist' for that line

rem start
PhysicsP1: is the label from a previous gosub command so there is a return at the end of this section
d is the velocity the player types in for the ball
e is the angle the player types in for the ball
h is the horizontal component of the ball's speed
i is the vertical component of the ball's speed
j and k are the ball's coordinates on the screen at any given time
a is the y coordinate of the person throwing the ball
remend

PhysicsP1:
h=d*cos(e)
i=d*sin(e)
j=101
k=a-30
sprite 11,j,k,11
repeat
k=k-i
i=i-c
j=j+h
sprite 11,j,k,11
until j=>800 or sprite collision(11,1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9)=1
return

hope someone can give me a hand to stop it telling me 'BOB does not exist' on the 'until j=>800...' line

if it works... DONT FIX IT!!!
just tweak it a bit around the edges till it dont work... THEN fix it!!!
-my BASIC programming motto
ToXic
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Australia
Posted: 19th Nov 2002 22:04
a bob is just another name for a sprite.

bob=blitter object, an old sprite format.

I dont think you can do this.
sprite collision(11,1 or 2 or 3 or 4 or 5 or 6)=1

like this i think.

S=sprite collision(11,0)
if s=1 then whatever
if s=2 then whatever
if s=3 then whatever
if s=4 then whatever
if s>10 and s<20 then whatever

hope this helps you

ToXic.
TheCyborg
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 20th Nov 2002 09:06
This does NOT solve your problem, just a tip:
Do not ever use "+" or "-" inside a loop as they are slow.
Instead use:
Inc k,i :REM Increases k with j
Dec i,c :REM Decreases i with c
Inc j,h :REM Increases j with h

As Toxic said, you cannot use:
sprite collision(11,1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9)=1

Try this:
Repeat
....your code....
S=Sprite Collision(11,0)
until j=>800 or S>0 And S<10

Hope that helped...

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.

Login to post a reply

Server time is: 2024-03-03 15:05:48
Your offset time is: 2024-03-03 15:05:48