IGNORED

# Double Collision

## Recommended Posts

Hi i wanted to know how can I have a collision Ex:

if collision(player1,player0) then a=1

but if it collides again I get Ex:

if collision(player1,player0) then a=0

cause if i do

if collision(player1,player0) then a=0

if collision(player1,player0) then a=1

it will just stay on a=1?

Edited by Zereox
##### Share on other sites

Hi I'm pretty new to programming and I simply don't know how to use a variable to play between settings Eg:

a=0

if a=0 then player0x=40

if a=1 then player0y=40

can someone tell me how to do this thanks.

Are you talking about using a single bit of a variable as a flag? If so, then you put curly brackets after the variable, with a value of 0 to 7 between the brackets to indicate which bit you're interested in. For example:

```   rem * to set bit 3 on or off
a{3} = 1 : rem * to set bit 3 on
a{3} = 0 : rem * to set bit 3 off
rem * to test the value of bit 3
if a{3} then player0x = 40 : rem * i.e., if <true> then <do this>, so this means if a{3} is set to 1
if !a{3} then player0y = 40 : rem * ! means not, so this means if <not true>, or if a{3} is set to 0```

Does that help, or were you talking about something different?

Michael

##### Share on other sites

that would be:

if collision(player1,player0) then a = 2

if !collision(player1,player0) && a = 2 then a = 1

if collision(player1, player0) && a = 1 then a = 0

This way, if there is a collision, a is set to 2. If that has been done, and the sprites are no longer touching, a is set to 1, and then if they touch again it is set to 0.

##### Share on other sites

OK guys since i just started I'm pretty newb and don't really understand so let my simplify.

Im making a tag game just to learn so Points go up while the other player chases you. when he touches you points go down until you touch him back.So that is where my collision is needed when I have to touch him back.

As for right now he can only touch you. here is my script:

Edited by Zereox
##### Share on other sites

Probably just stating what you already know, but you will need to do something after the collision so they don't keep colliding. Something good to do might be to offset the x and/or y coordinate(s) of one or both of the players enough so that after a collision is registered, they will not keep colliding.

Like Michael said, since you only have two players, the most efficient way of doing this easily in bB is via setting a bit in one of the params. If you are playing traditional tag then one or the other player is "it" and whenever there is a collision you could change who is it if you are defining the first bit in the variable a to be that flag by doing the following:

a{0} = !a{0}

That basically just flips the first bit of the variable a.

Then you can check that bit and highlight the player to indicate which is "it" if you wanted like:

if a{0} then (change player0 to light blue and player1 to dark red) else (change player0 to dark blue and player1 to light red)

For collisions then you could do:

if collision(player0,player1) then player0x = player0x - 5 : player1x = player1x + 5 : gosub handlepoints : a{0} = !a{0}

and then define handlepoints like:

handlepoints

if a{0} then (add point for player0) else (add point for player1)

return

Later on you might want to take a look at the player scores minikernel by curtisp. That will let you show two two digit scores in the color of each player.

Good luck!

Edited by Fort Apocalypse
##### Share on other sites

Thanks alot I will post my progress later.

--Double Post--

Ok I got the collision system to work + the "It" color change I will be adding the 2digit score system by Curtisp and points handler.

Could somone show me how to find the exect color needed?

Edited by Zereox
##### Share on other sites

Can someone help me out with Curtis minikernel because when ever I compile i get this error:

---------- Capture Output ----------

> "C:\Atari2600\bB\2600bas.bat" C:\Atari2600\bB\samples\playerscores.bas

2600 Basic compilation complete.

Warning: Unable to open 'playerscores.asm'

Warning: Unable to open 'bcd_math.asm'

bytes of ROM space left

Warning: Unable to open 'playerscores.asm'

Warning: Unable to open 'bcd_math.asm'

2765 bytes of ROM space left

Warning: Unable to open 'playerscores.asm'

Warning: Unable to open 'bcd_math.asm'

2765 bytes of ROM space left

--- Unresolved Symbol List

player1score 0000 ???? (R )

player0score 0000 ???? (R )

subbcd 0000 ???? (R )

player1scorecolor 0000 ???? (R )

player0scorecolor 0000 ???? (R )

Fatal assembly error: Source is not resolvable.

> Terminated with exit code 0.

even tought I have both files in my folder what wrong?

##### Share on other sites

For the colors question look at this (under colors):

To use curtis's minikernel put his file in the "includes" directory under your "bB" directory (the batari basic directory, not the directory with your code in it).

Then at the very end of your game's source file (game.bas) put these lines in: (indent them all by at least one space, don't use tabs for ident, because it messes up bB in version 1.0)

rem should be last lines in game

inline playerscores.asm

inline bcd_math.asm

(note: the bcd_math stuff just makes it easier to add to the score)

Then up above in the code you'll want to initialize the score to 00 (although it should start as 00 anyway) for each player and set the scorecolor:

player0score = \$00

player1score = \$00

player0scorecolor = 0

player1scorecolor = 222

then use the following code to add 1 to the score (example):

##### Share on other sites

For the colors question look at this (under colors):

http://www.randomterrain.com/atari-2600-me...c-commands.html

To use curtis's minikernel put his file in the "includes" directory under your "bB" directory (the batari basic directory, not the directory with your code in it). In other words, unzip the playerscores.zip and put the .asm files into that dir.

Then at the very end of your game's source file (game.bas) put these lines in: (indent them all by at least one space, don't use tabs for ident, because it messes up bB in version 1.0)

rem should be last lines in game

inline playerscores.asm

inline bcd_math.asm

(note: the bcd_math stuff just makes it easier to add to the score)

Then up above in the code you'll want to initialize the score to 00 (although it should start as 00 anyway) for each player and set the scorecolor:

player0score = \$00

player1score = \$00

player0scorecolor = 0

player1scorecolor = 222

then use the following code to add 1 to the score (example):

Edited by Fort Apocalypse
##### Share on other sites

OK thanks now this is what i have done:

Taging (Collision)

"It" coloring (Darkish color when "It")

Scoring system

Being "It"

To-Do:

Method of chasing the enemy

This is the hardest getting the enemy to flee properly and then be able to add a third digits to Curtisp minikernel.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.