? 4-directional circle pad movement? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Contest results!

4-directional circle pad movement?

  • #1 ✎ 3 ElectriicDev Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Can't seem to figure out how to get 4-directional circle pad movement working. Does anybody have an example on this kinda thing? Posted
  • #2 ✎ 3 ElectriicDev Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Like, the player moves a sprite using the circle pad but they can't move diagonally. If you've played the first Legend of Zelda game on 3DS Virtual Console, that kind of movement is what I'm trying to achieve. Posted
  • #3 ✎ 867 Lumage Head Admin Orthogonal movement. One solution is shown here: https://smilebasicsource.com/forum?fpid=6680#post_6680 The idea there being that if either X or Y is greater (in either direction) than the threshold value .2, take that as the direction. It's easier than mapping the angle to a right one. You could of course replace the ...B=B OR with just changing your sprite's position. Posted Edited by Lumage
  • #4 ✎ 361 Chemicalex Drawing I like to draw! Hobbies RNG Hidden Easter Eggs Video Games I like to play video games! Hobbies HERE IS ORTHAGONAL MOVEMENT EXAMPLE OK LETS GO PX = 10 'player X position PY = 10 'player Y position T = 0.2 'threshold value WHILE 1 STICK OUT CX, CY 'Get circle pad values 'check for dominant direction IF CX<CY AND CX>T THEN DIR = 1 ELSEIF CX>CY AND CY>T THEN DIR = 2 'DIR1 is up, DIR2 is right IF CX>CY AND CX<T THEN DIR = 3 ELSEIF CX<CY AND CY<T THEN DIR = 4 'DIR3 is down, DIR4 is left IF CX == 0 AND CY == 0 THEN DIR = 0 'not moving IF DIR == 1 then 'move up IF DIR == 2 then 'move right IF DIR == 3 then 'move down IF DIR == 4 then 'move left WEND This should work. Posted Edited by Chemicalex
  • #5 ✎ 3 ElectriicDev Video Games I like to play video games! Hobbies Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength I'll try these out, thank you! Posted