Jump to content
Lewis2907

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

Recommended Posts

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)

20180605_Multisprite_Pac_Man.bas.bin

20180605 - PacMan_Eat_N_Run_(Multisprite).txt

20180605_Multisprite_Pac_Man.bas

Edited by Lewis2907

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...