Rabbit 2600 Posted June 3, 2013 Share Posted June 3, 2013 (edited) I'm having issues with making animation for player1 work. I'm using this formula for his movement: dim _P1_L_R = player1x.a dim _P1_U_D = player1y.b dim _P0_L_R = player0x.a dim _P0_U_D = player0y.b dim _player0a = a dim _player0b = b if _P1_U_D < _P0_U_D then _P1_U_D = _P1_U_D + 0.30 if _P1_U_D > _P0_U_D then _P1_U_D = _P1_U_D - 0.30 if _P1_L_R < _P0_L_R then _P1_L_R = _P1_L_R + 0.30 if _P1_L_R > _P0_L_R then _P1_L_R = _P1_L_R - 0.30 And the animation for player0 works like this: f=f+1 : if f = 20 then f = 0 if f = 0 then gosub f0 if f = 10 then gosub f1 if joy0right then r = 0 if joy0left then r = 8 REFP0 = r f0 player0: %00100110 %00000110 %00110010 %00110010 %01100100 %00000100 %00111000 %01001000 %00100000 %01110000 %01010000 %01110000 %11000000 %11000000 %00000000 %00000000 end return f1 player0: %10010111 %01000001 %00110001 %00110001 %01100010 %00000010 %00011100 %00100100 %00010000 %00111000 %00101000 %00111000 %01100000 %01100000 %00000000 %00000000 end Edited June 3, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted June 3, 2013 Share Posted June 3, 2013 I'm having issues with making animation for player1 work. I'm using this formula for his movement: dim _P1_L_R = player1x.a dim _P1_U_D = player1y.b dim _P0_L_R = player0x.a dim _P0_U_D = player0y.b dim _player0a = a dim _player0b = b That looks questionable to me. Shouldn't player1 have separate variables of its own in player1x.a and player1y.b instead of using player0's variables (I'm referring to the a and b)? Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted June 3, 2013 Author Share Posted June 3, 2013 Might have missed to paste something in. The entire code is here: rem Generated 2013-05-31 20:37:14 by Visual bB Version 1.0.0.554 rem ********************************** rem * * rem * * rem * * rem * * rem * * rem ********************************** set kernel_options player1colors playercolors pfcolors set smartbranching on playfield: .....X.X..XX..X..X.XXX.XXXX..... .....X.X.X..X.X..X.X...X........ .....XXX.X..X.X..X.XXX.XXXX..... .....X.X.X..X.X..X...X.X........ .....X.X..XX...XX..XXX.XXXX..... ................................ .X..X.XXXX.XXXX.XX..X.X..X.XXXX. .X.X..X....X....X.X.X.XX.X.X.... .XX...XXXX.XXXX.XX..X.X.XX.X.XX. .X.X..X....X....X...X.X..X.X..X. .X..X.XXXX.XXXX.X...X.X..X.XXXX. end title pfcolors: $2E $2C $2C $2A $2A $28 $28 $26 $26 $24 $24 $24 end drawscreen if joy0fire || joy1fire then goto skiptitle goto title screen1 skiptitle playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX...XXXXXXXXXXXXXX XXXXXXXXXXXXXXX...XXXXXXXXXXXXXX X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end dim rand16 = z dim Master_Counter = a dim timer = b dim _P1_L_R = player1x.a dim _P1_U_D = player1y.b dim _P0_L_R = player0x.a dim _P0_U_D = player0y.b dim _player0a = a dim _player0b = b scorecolor = $20 player0x = 80 player0y = 22 p = 1 player1x = 80 player1y = 41 ballx = rand&127 bally = rand&63 ballheight = 4 c = 0 h = h + 1 if h = 120 then player1y = 33 player0color: $F4; $F4; $0E; $0E; $0E; $0E; $2E; $2E; $2E; $2E; $2E; $06; $06; $06; $0E; $0E; end player1color: $A2; $A2; $A2; $A2; $A2; $20; $20; $20; $20; $20; $2E; $2E; $2E; $2E; $0E; $0E; end main f=f+1 : if f = 20 then f = 0 if f = 0 then gosub f0 if f = 10 then gosub f1 rem POSSIBLY INEFFICIENT CODE, SEPARATE COLOR INFO FOR EACH FRAME... if joy0right then r = 0 if joy0left then r = 8 REFP0 = r pfcolors: $2E $2C $2C $2A $2A $28 $28 $26 $26 $24 $24 $24 end drawscreen if joy0right then player0x = player0x + 1 if joy0left then player0x = player0x - 1 if joy0up then player0y = player0y - 1 if joy0down then player0y = player0y + 1 if _P1_U_D < _P0_U_D then _P1_U_D = _P1_U_D + 0.30 if _P1_U_D > _P0_U_D then _P1_U_D = _P1_U_D - 0.30 if _P1_L_R < _P0_L_R then _P1_L_R = _P1_L_R + 0.30 if _P1_L_R > _P0_L_R then _P1_L_R = _P1_L_R - 0.30 if p = 1 then if collision(player0, ball) then p = 0: score = score+10: p = 1:bally=rand&63:ballx=rand&127: c = c + 1 if c = 5 then goto __Clean_Screen_Loop if collision(ball,playfield) then bally=rand&63:ballx=rand&127 if bally < 31 then bally=rand&63:ballx=rand&127 if bally > 80 then bally=rand&63:ballx=rand&127 if ballx < 22 then bally=rand&63:ballx=rand&127 if ballx > 134 then bally=rand&63:ballx=rand&127 if player0y < 38 then player0y = player0y + 1 if player0y > 80 then player0y = player0y -1 if player0x < 21 then player0x = player0x +1 if player0x > 133 then player0x = player0x - 1 goto main __Clean_Screen_Loop rem **************************************************************** rem * rem * Playfield colors. rem * rem ```````````````````````````````````````````````````````````````` rem ` COLUBK = 0 : COLUPF = $30 ballx = 255 : bally = 255 player0x = 255 : player0y = 255 player1x = 255 : player1y = 255 missile0x = 255 : missile0y = 255 missile1x = 255 : missile1y = 255 rem **************************************************************** rem * rem * Draws the screen. rem * rem ```````````````````````````````````````````````````````````````` rem ` playfield: ................................ ................................ ................................ .....XXX.X...XXX..X..X..X.X..... .....X...X...X...X.X.XX.X.X..... .....X...X...XXX.XXX.X.XX.X..... .....X...X...X...X.X.X..X....... .....XXX.XXX.XXX.X.X.X..X.X..... ................................ ................................ ................................ end drawscreen if joy0fire || joy1fire then c = 0: goto title goto __Clean_Screen_Loop f0 player0: %00100110 %00000110 %00110010 %00110010 %01100100 %00000100 %00111000 %01001000 %00100000 %01110000 %01010000 %01110000 %11000000 %11000000 %00000000 %00000000 end return f1 player0: %10010111 %01000001 %00110001 %00110001 %01100010 %00000010 %00011100 %00100100 %00010000 %00111000 %00101000 %00111000 %01100000 %01100000 %00000000 %00000000 end player1: %00000100 %01100100 %00100100 %00101000 %00111000 %00000000 %10111000 %10111000 %11111100 %00111010 %00000001 %00111001 %00101001 %00111000 %00000000 %00000000 end player1: %00101000 %00101000 %00101000 %00101000 %00111000 %01000000 %01011000 %01011000 %01111100 %00111010 %00000010 %00111010 %00101010 %00111000 %00000000 %00000000 end return Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted June 3, 2013 Share Posted June 3, 2013 That looks questionable to me. Shouldn't player1 have separate variables of its own in player1x.a and player1y.b instead of using player0's variables (I'm referring to the a and b)? Right. He should be using something like this: dim _P1_L_R = player1x.a dim _P1_U_D = player1y.b dim _P0_L_R = player0x.c dim _P0_U_D = player0y.d dim _player0a = e dim _player0b = f Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted June 3, 2013 Author Share Posted June 3, 2013 (edited) Okay. I changed and added these lines of codes. Now atleast player1 gets mirrored so it's a step in the right direction dim _P1_L_R = player1x.a dim _P1_U_D = player1y.b dim _P0_L_R = player0x.a dim _P0_U_D = player0y.b dim _player0a = c dim _player0b = d g=g+1 : if g = 20 then g = 0 if g = 0 then gosub g0 if g = 10 then gosub g1 REFP1 = g g0 player1: %00000100 %01100100 %00100100 %00101000 %00111000 %00000000 %10111000 %10111000 %11111100 %00111010 %00000001 %00111001 %00101001 %00111000 %00000000 %00000000 end g1 player1: %00101000 %00101000 %00101000 %00101000 %00111000 %01000000 %01011000 %01011000 %01111100 %00111010 %00000010 %00111010 %00101010 %00111000 %00000000 %00000000 end What do I do about this code? How do I go about making it switch between player1 frame 1 and 2? if _P1_U_D < _P0_U_D then _P1_U_D = _P1_U_D + 0.30 if _P1_U_D > _P0_U_D then _P1_U_D = _P1_U_D - 0.30 if _P1_L_R < _P0_L_R then _P1_L_R = _P1_L_R + 0.30: g = 0 if _P1_L_R > _P0_L_R then _P1_L_R = _P1_L_R - 0.30: g = 8 Edited June 3, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted June 3, 2013 Share Posted June 3, 2013 Did you look at my post? Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted June 3, 2013 Author Share Posted June 3, 2013 (edited) Yes, I did. Odds are I just didn't understand. With your post I managed to get player1 to be able to mirror himself depending on player0's position, but that's as far as I got. Edited June 3, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted June 3, 2013 Share Posted June 3, 2013 Yes, I did. Odds are I just didn't understand. No understanding needed when you use copy and paste. But this one isn't too hard to understand. In this specific case, each dim needs a separate variable. Look at the variables in my post, then look at the variables in your post. Do you notice anything different? Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted June 3, 2013 Author Share Posted June 3, 2013 My bad. I copy & pasted it, so now it should be correct. 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.