# Disable Diagonal Movement (L,R,U,D) Only Needed

5 replies to this topic

### #1 Lewis2907OFFLINE

Lewis2907

Moonsweeper

• 303 posts
• Location:Senatobia, MS

Posted Tue Jun 5, 2018 1:21 PM

Does any one know how to permanently disable diagonal movement even when using gosub, goto, etc.? Below is a part of the code. I just need Left, Right, Up and Down. Any other movements like Up && Down mess up the program and what I am trying to get accomplished. Basically I am bringing PacMan Eat N Run over to Multisprite the hard way. I am calculating the exact spots where I need to move Up, Left, Right, Down etc. As stated before the "Diagonal Movements" throw player0 into the play field. Since we can't get pfpixel, pfread to work properly or fairly easy. I think this is about the best way (for what I can do). Very time consuming and using up space, but I think I can accomplish it since the playfield will help map where I need to make movements. Thanks if anyone can solve this for me.

Currently if you just move the controls normally (no diagonals) you have the "smooth collision detection". I only worked up the middle (3rd Floor) and the ones above and below it.

;***************************************************************
;
;  Kernel setup.
;
includesfile multisprite_bankswitch.inc
include fixed_point_math.asm
set tv ntsc
set kernel multisprite
set romsize 32kSC
set optimization speed
set smartbranching on
set optimization noinlinedata
set optimization inlinerand

;****************************************************************
;
;  Player0-4 fixed point variables for more flexibility in
;  gameplay mechanics.
;  "c" is used in joy0 checks for last movement
;
dim _P0_L_R = player0x.a
dim _P0_U_D = player0y.b

(More Code)

;***************************************************************
;
;  remember joy0 position for making left, right, up, down movement
;
if joy0up then       c{1}=1:c{2}=0:c{3}=0:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0
if joy0down then  c{1}=0:c{2}=1:c{3}=0:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0
if joy0left then      c{1}=0:c{2}=0:c{3}=1:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0
if joy0right then    c{1}=0:c{2}=0:c{3}=0:c{4}=1:c{5}=0:c{6}=0:c{7}=0:c{0}=0

(More Code)

#### Attached Files

Edited by Lewis2907, Tue Jun 5, 2018 1:21 PM.

### #2 Random TerrainOFFLINE

Random Terrain

Visual batari Basic User

• 28,811 posts
• Controlled Randomness
Replay Value
Nonlinear
• Location:North Carolina (USA)

Posted Tue Jun 5, 2018 3:27 PM

It seems to be working as-is using the middle holes.

### #3 Lewis2907OFFLINE

Lewis2907

Moonsweeper

• Topic Starter
• 303 posts
• Location:Senatobia, MS

Posted Tue Jun 5, 2018 3:30 PM

RT,

Yes, but if you down or up to the 2nd Floor and while moving press up/right or up/left and the reverse when going down. You will get stuck. It work fine so far when moving to the 4th Floor, but when I added the code I noticed the 2nd Floor would put you in the playfield. I saw a few posts on where people removed the diagonal movements, but didn't post their code to look at. I'm not sure if SWCHA would work as I am not that great at using that method, thanks.

### #4 ultimaOFFLINE

ultima

Chopper Commander

• 208 posts

Posted Wed Jun 6, 2018 5:17 PM

You can add a label after the directional check. Then add a goto label after the first 3 checks.

sorta like this:

if joy0up then c=%00000010: goto __NextPart

if joy0down then c=%00000100: goto __NextPart
if joy0left then c=%00001000: goto __NextPart
if joy0right then c=%00010000
__NextPart

Edited by ultima, Wed Jun 6, 2018 8:16 PM.

### #5 Lewis2907OFFLINE

Lewis2907

Moonsweeper

• Topic Starter
• 303 posts
• Location:Senatobia, MS

Posted Wed Jun 6, 2018 8:50 PM

Ultima,

Do you have a sample code that I can look at? If so I should be okay on how to make it fit into the program I have, thanks.

### #6 Lewis2907OFFLINE

Lewis2907

Moonsweeper

• Topic Starter
• 303 posts
• Location:Senatobia, MS

Posted Thu Jun 7, 2018 10:30 AM

I figured it out on going to the 2nd floor. I had > in stead of a <. Just a simple equation error will have your head banging the desk.

#### 0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users