Jump to content
IGNORED

Reverse direction of missile upon collision?


Tyler Frisbee

Recommended Posts

I'm trying to program my game so when missile1 hits player0, if player0 is holding the fire button, the missile will bounce in the opposite direction and hit player1. Currently, the missile will deflect the first time you try it, but it will pass through player1 without anything happening, and player1 won't fire any more missiles afterward. I've been staring at and changing this code for hours and its beginning to drive me insane. I don't want to bother anyone, but can anyone spot how I screwed up? I just can't figure it out...

 if d = 0 then goto checkfire
 if d = 1 then goto reverse

reverse
 missile1x = missile1x + 2:goto draw


checkfire
 if missile1x>153 then goto skip
 missile1x = missile1x - 2 : goto draw

 rem if a missile hasn't been fired, then fire missile
skip
 missile1y=player1y-3:missile1x=player1x-5

 if missile1x=11 then missile1y=250
 rem----------------------------------------------

 rem Draw output to screen
draw
 drawscreen

if collision(missile1,player0) && joy0fire then score=score+1:d=1
if collision(missile1,player1) then score=score+1:d=0:player1x=153:player1y=(rand&81)+1:missile1y=255

Hack Attack.bas.bin

Hack Attack.bas

Link to comment
Share on other sites

I found that I am able to deflect the missile back at player1. If he is there the missile kills him and he fires again. But if he is not there, no collision happens and the missile continues to the right side of the screen and wraps around to the right in which case it gets stuck and player1 stops shooting. I'm guessing if you put a limit on the missile on the right side, have it reset or something. It may fix the problem.

  • Like 1
Link to comment
Share on other sites

Looks like I fixed one problem:

 

hack_attack_2015y_01m_31d_2035t.bin

 

hack_attack_2015y_01m_31d_2035t.bas

 

I see that you are using rand& with numbers not in the list:

 

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

 

 

I also see that you are using reboot which can screw up random numbers:

 

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

  • Like 1
Link to comment
Share on other sites

Looks like I fixed one problem:

 

attachicon.gifhack_attack_2015y_01m_31d_2035t.bin

 

attachicon.gifhack_attack_2015y_01m_31d_2035t.bas

 

I see that you are using rand& with numbers not in the list:

 

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

 

 

I also see that you are using reboot which can screw up random numbers:

 

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

Oops...thats probably it. Apparently I neglected to read the sentence stating that you could only use those numbers with rand&. Thanks for the help everyone!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...