+Random Terrain Posted September 26, 2005 Share Posted September 26, 2005 I used to know how to do this stuff on the VIC-20 and Commodore 64, but I cannot remember how to limit the joystick to 4-way movement. I'm almost done with my test program with the random mazes and a little sprite you can move around, but the little thing can sneak diagonally sometimes and go over little bits of the wall. How do you stop the player from moving diagonally? Thanks. Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted September 26, 2005 Share Posted September 26, 2005 (edited) I used to know how to do this stuff on the VIC-20 and Commodore 64, but I cannot remember how to limit the joystick to 4-way movement. I'm almost done with my test program with the random mazes and a little sprite you can move around, but the little thing can sneak diagonally sometimes and go over little bits of the wall. How do you stop the player from moving diagonally? Thanks. 938370[/snapback] If you stop reading the joystick once you have you've detected movement in a single direction then you won't get diagonals. Edited September 26, 2005 by vdub_bobby Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted September 26, 2005 Author Share Posted September 26, 2005 (edited) If you stop reading the joystick once you have you've detected movement in a single direction then you won't get diagonals. Thanks. Does it matter that the little sprite moves like Pac-Man? It doesn't stop until it comes to a wall. Oh yeah, and about what you said, is this the best way to do that? if joy0up then do some stuff : goto skipstick if joy0down then do some stuff : goto skipstick if joy0left then do some stuff : goto skipstick if joy0right then do some stuff skipstick Edited September 26, 2005 by Random Terrain Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted September 26, 2005 Share Posted September 26, 2005 Oh yeah, and about what you said, is this the best way to do that? if joy0up then do some stuff : goto skipstick if joy0down then do some stuff : goto skipstick if joy0left then do some stuff : goto skipstick if joy0right then do some stuff skipstick 938396[/snapback] I dunno about "best," but that looks like it will certainly work. That's how I'd do it, anyway. Or put it in a subroutine and: if joy0up then do some stuff : return if joy0down then do some stuff : return if joy0left then do some stuff : return if joy0right then do some stuff : return return Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted September 26, 2005 Author Share Posted September 26, 2005 I dunno about "best," but that looks like it will certainly work. That's how I'd do it, anyway. Or put it in a subroutine and: if joy0up then do some stuff : return if joy0down then do some stuff : return if joy0left then do some stuff : return if joy0right then do some stuff : return return 938407[/snapback] Thanks. That's a good alternative to remember. I'd have to have a label for either one, so I guess the goto version will work OK for now unless something changes. Maybe I should check to see which one takes up more bytes. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted September 27, 2005 Author Share Posted September 27, 2005 (edited) After trying and failing many times, I found a different way to stop the diagonal movement and stop the player from passing through bits of the wall. I had to jump to the same movement related gosubs twice and make the x and y negative/positive variables equal zero at the right time. Edited September 27, 2005 by Random Terrain 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.