Retro Lord Posted February 18, 2015 Share Posted February 18, 2015 I'm a bit lost on this one. I'm trying to figure out how to make the a.i fire at the player depending on if the player is left or right to the a.i I basically tried something like this, but that don't work at all: if d=0 then missile1x=player1x : missile1y=player1y if d=1 then missile1x=missile1x+1 if d=2 then missile1x=missile1x-1 if player0x<player1x then d=2 if player0x<player1x then d=1 if missile1x<10 then d=0 if missile1x>135 then d=0 Quote Link to comment Share on other sites More sharing options...
ultima Posted February 19, 2015 Share Posted February 19, 2015 (edited) Would this help? dim fire = a c{1}=0 c{2}=0 player1x = 50 : player1y = 50 player0x = 70 : player0y = 50 e=60 fire = 0 loop COLUBK = $00 : COLUP1= $5A : COLUP0= $0A if joy0up then player0y = player0y - 1 if joy0down then player0y = player0y + 1 if joy0left then player0x = player0x - 1 if joy0right then player0x = player0x + 1 if player0x > player1x then fire = 1 : c=%00000010 if player0x < player1x then fire = 1 : c=%00000001 if fire = 1 && c{0} then missile1x = player1x - e : missile1y = player1y - 1 if fire = 1 && c{1} then missile1x = player1x + 1 + e : missile1y = player1y - 1 if e>60 then e=0 : fire = 0 : missile1x = 0 : missile1y = 0 e=e+1 player1: %00000000 %00000000 %00000000 %00111100 %01111110 %00000000 %01111110 %00011000 end player0: %11100000 end drawscreen goto loop spaceship code.bas.bin Edited February 19, 2015 by ultima Quote Link to comment Share on other sites More sharing options...
ZackAttack Posted February 19, 2015 Share Posted February 19, 2015 You forgot to change the caparison for setting d=1. You should also add a check for d=0 before setting d to 1 or 2. Otherwise the missle will change directions mid flight. Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted February 19, 2015 Author Share Posted February 19, 2015 Cheers for the help guys, you are the best =) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.