Jump to content

Photo

Batari Basic peculiar


6 replies to this topic

#1 MissCommand OFFLINE  

MissCommand

    Space Invader

  • 33 posts
  • Location:North Carolina, USA

Posted Fri Sep 29, 2017 11:00 AM

Hello all,

 

  Slowly working on my game (decided on name... Mall Rush!) and having a very peculiar problem. Been staring at this a few days now and before totally rewriting to find a different way to code, thought I would see if anyone had a solution (or explanation):

 

Using DPC+. I have sprites "falling" and my player0 at the bottom dodging. I have a special sprite (player7) that I want to collect and not dodge. Distilled below:

 

So when I detect a collision:

 

Main loop:

 

  ;*** Check for collisions
  if collision(player0,player1) then goto _End_Coll
_Return_CollGift
 
continue
 
_End_Coll
  if player7y > 149 && player7y < 166 then gencount = 1 else goto _Return_CollGift
  score = score + 200
  Ch0_Sound = 5 : Ch0_Duration = 1 : Ch0_Counter = 0 ; Play Adventure Grab
  goto _Return_CollGift
 
This works great for testing... It detects the player7 position on my bottom row and adds score and plays sound.
 
So now when I actually want player0 to lose a life when colliding with anything else I just redirect the goto to a differnt location instead back to the main loop:
 
_End_Coll
  if player7y > 149 && player7y < 166 then gencount = 1 else goto _End_Life
  score = score + 200
  Ch0_Sound = 5 : Ch0_Duration = 1 : Ch0_Counter = 0 ; Play Adventure Grab
  goto _Return_CollGift
 
_End_Life
  do stuff
  goto _Return_CollGift
 
And now every collision is sending me to _End_Life! Im not sure how changing a goto location is causing my if statement to work different and not evaluate player7 position correctly.
 
I must be doing something dumb and just not catching it.
 
Help! :)

Edited by MissCommand, Fri Sep 29, 2017 11:59 AM.


#2 kdgarris ONLINE  

kdgarris

    Chopper Commander

  • 202 posts

Posted Fri Sep 29, 2017 1:34 PM

Without seeing the rest of your source, I can only make a guess, but the first thing I would suggest trying is renaming your _End_Life label to not have the word "end" in it.  I've had issues with labels containing keyword before.



#3 atari2600land OFFLINE  

atari2600land

    Waffles:

  • 10,773 posts
  • Man's best invention. Ever.
  • Location:Salem, Oregon

Posted Fri Sep 29, 2017 6:47 PM

The problem with the "end" in a label is if it's the first word in it. Something like "please_end_coll" would work.



#4 MissCommand OFFLINE  

MissCommand

    Space Invader

  • Topic Starter
  • 33 posts
  • Location:North Carolina, USA

Posted Mon Oct 2, 2017 12:42 PM

Thanks for the suggestions guys! As RandomTerrain and others suggest, I do use underscores in front of all my labels.

 

After much aggravation I finally realized the problem. The collision routine is actually being called TWICE because I did not remove player7 completely from my internal list. The first time through it works correctly, but I did not notice because the "partial" remove I did called the collision to work opposite the second time... so I did not notice the first pass through. I finally realized what was going on when I noticed the score was being incremented even though it was not supposed to. Ugh!


Edited by MissCommand, Mon Oct 2, 2017 12:43 PM.


#5 MissCommand OFFLINE  

MissCommand

    Space Invader

  • Topic Starter
  • 33 posts
  • Location:North Carolina, USA

Posted Wed Oct 4, 2017 6:54 AM

  Actually, after more testing that was only partially the problem... ugh! Can anyone tell me how to monitor the numerical position of a particular sprite? Either through setting the score or through the Stella debugger?

 

  Thanks!



#6 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,181 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Wed Oct 4, 2017 8:24 AM

Actually, after more testing that was only partially the problem... ugh! Can anyone tell me how to monitor the numerical position of a particular sprite? Either through setting the score or through the Stella debugger?
 
  Thanks!


You mean like what is in these example programs?

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#testvariables

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#find_border_coordinates

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#ex_multisprite_9_objects

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#ex_dpc_13_objects



#7 MissCommand OFFLINE  

MissCommand

    Space Invader

  • Topic Starter
  • 33 posts
  • Location:North Carolina, USA

Posted Wed Oct 4, 2017 12:43 PM

You mean like what is in these example programs?

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#testvariables

 

 

  Exactly like your first link!  :)  Thanks!

 

  It did reveal something really interesting... the collision detection appears to be happening a few pixels above where I think it should be. My sprite starts at y-position 150 (16 pixels high), but the collision triggers start at y-position142. Strange.


Edited by MissCommand, Wed Oct 4, 2017 12:44 PM.





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users