+Gemintronic Posted January 13, 2023 Share Posted January 13, 2023 Maybe try making the player just move faster the longer you hold a direction first. Conquer that and then go for fancier double-tap stuff. rem //** Use vars "a" through "d" to store amount of directional presses **// dim rpressed = a dim lpressed = b dim upressed = c dim dpressed = d init rem //** Since we're using the ball make it 8 pixels tall and put it on screen **// ballheight = 8 : ballx = 77 : bally = 77 main rem //** if a direction is pressed increment its specific pressed var else clear it **// rem //** also make sure it doesn't roll over from 255 back to 0 **// if joy0right && rpressed < 255 then rpressed = rpressed + 1 else rpressed = 0 if joy0left && lpressed < 255 then lpressed = lpressed + 1 else lpressed = 0 if joy0up && upressed < 255 then upressed = upressed + 1 else upressed = 0 if joy0down && dpressed < 255 then dpressed = dpressed + 1 else dpressed = 0 rem //** If a direction is pressed move that way **// rem //** If that direction has been p[ressed over 32 times move even further **// if rpressed > 0 then ballx = ballx + 1 : if rpressed > 32 then ballx = ballx + 1 if lpressed > 0 then ballx = ballx - 1 : if lpressed > 32 then ballx = ballx - 1 if upressed > 0 then bally = bally - 1 : if upressed > 32 then bally = bally - 1 if dpressed > 0 then bally = bally + 1 : if dpressed > 32 then bally = bally + 1 rem //** Make the playfield normal but the ball should be 8 pixels wide **// rem //** Color the playfield walls white **// CTRLPF = $31 COLUPF = $0E rem //** Draw the screen and loop back around **// drawscreen goto main Quote Link to comment Share on other sites More sharing options...
bogax Posted January 14, 2023 Share Posted January 14, 2023 here I added a delay it uses another variable half for saving the state of SWCHA and half for a timer when it sees a change on SWCHA it starts the timer then processes the joystick when it times out a 4 frame delay seems a reasonable compromise between too long and not long enough (for me anyway) set optimization noinlinedata dim counter = c dim move_flags = m dim move_direction = temp1 dim j0_direction = temp2 def joy_was_0 = m{6} def frame_parity = m{5} def speed_x_2 = m{4} def true = 1 def false = 0 def set_move_flag = callmacro smd_mac def get_move_flag = callmacro gmd_mac const noscore = 1 const delay = 4 macro smd_mac {1} move_flags = (move_flags & %11110000) | {1} end macro gmd_mac {1} {1} = move_flags & %00001111 end gosub init loop COLUP0 = $38 COLUPF = $86 drawscreen get_move_flag move_direction if !collision(playfield, player0) then check_counter player0x = player0x - x_move_table[move_direction] player0y = player0y - y_move_table[move_direction] move_flags = 0 : move_direction = 0 goto skip_move check_counter if counter & $0F then count_down if (counter ^ SWCHA) & $F0 = 0 then check_parity counter = (counter & $F0) | delay goto check_parity count_down counter = counter - 1 if counter & $0F then check_parity check_joy0 j0_direction = (SWCHA ^ %11111111)/16 j0_direction = direction_table[j0_direction] if j0_direction = 0 then check_parity if j0_direction <> move_direction then move_direction = j0_direction : speed_x_2 = false : goto check_parity if joy_was_0 then speed_x_2 = true check_parity if speed_x_2 then do_move if frame_parity then skip_move do_move player0x = player0x + x_move_table[move_direction] player0y = player0y + y_move_table[move_direction] skip_move if SWCHA & $F0 = $F0 then joy_was_0 = false else joy_was_0 = true if frame_parity then frame_parity = false else frame_parity = true set_move_flag move_direction counter = counter & $0F : counter = (SWCHA & $F0) | counter goto loop init player0x = 40 player0y = 30 player0: %00011000 %00111100 %00111100 %00011000 end playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X..............XX..............X X..............XX..............X X..............XX..............X X..............XX..............X X..............XX..............X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end return data x_move_table 0, 0, 1, 1, 1, 0, -1, -1, -1 end data y_move_table 0, -1, -1, 0, 1, 1, 1, 0, -1 end ; 1 ; 8 2 ; 7 * 3 ; 6 4 ; 5 ; 0 1 2 3 4 5 6 7 8 9 10 SWCHA ; ---u --d- --du -l-- -l-u -ld- -ldu r--- r--u r-d- right left down up joy switches data direction_table 0, 1, 5, 0, 7, 8, 6, 0, 3, 2, 4 ; direction end double_tap_2.bas double_tap_2.bas.bin Quote Link to comment Share on other sites More sharing options...
Words Fail Posted January 14, 2023 Author Share Posted January 14, 2023 The good thing is I'm not using diagonal. You can only move 4 way direction. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 14, 2023 Share Posted January 14, 2023 40 minutes ago, Words Fail said: The good thing is I'm not using diagonal. You can only move 4 way direction. This example program only lets you move in 4 directions. https://forums.atariage.com/topic/346370-can-someone-help-me-with-a-routine-for-double-tapping-the-joystick/?do=findComment&comment=5188353 Quote Link to comment Share on other sites More sharing options...
bogax Posted January 15, 2023 Share Posted January 15, 2023 (edited) 23 hours ago, Words Fail said: The good thing is I'm not using diagonal. You can only move 4 way direction. 1 if you're only using horizontal and vertical you wouldn't need the timer which is only to make the second tap diagnol recognizeable as such 2 I think it would be trivial to either coerce a diagnol to horizontal or vertical or just ignore diagnols 3 its moot if you don't want to adapt it any way 😜 really I just meant to show the behavior without timing the double tap, the use of SWCHA and the use of tables (I just threw all those defs and macros and verbose names in there to keep RT happy ) Edited January 15, 2023 by bogax 2 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.