Having difficulty finding Diagonal movement scripts for 4.5

Post Reply
zeldafreakneo
Posts: 5
Joined: Mon Sep 10, 2018 7:37 am

Having difficulty finding Diagonal movement scripts for 4.5

Post by zeldafreakneo » Wed Aug 12, 2020 7:01 am

Can someone please point me in the right direction?

I'm not looking for anything fancy like adding diagonal movement sprites, I would just like more intuitive and fluid movement for the character.

I see a few scripts for 4.1 but will those work in 4.5/4.6?
WillElm
Posts: 116
Joined: Wed Mar 20, 2019 3:56 am

Re: Having difficulty finding Diagonal movement scripts for 4.5

Post by WillElm » Wed Aug 12, 2020 12:44 pm

zeldafreakneo wrote:
Wed Aug 12, 2020 7:01 am
Can someone please point me in the right direction?

I'm not looking for anything fancy like adding diagonal movement sprites, I would just like more intuitive and fluid movement for the character.

I see a few scripts for 4.1 but will those work in 4.5/4.6?
There's gotta be a way, but it's not gonna be as easy for whatever reason. The arguments #LEFT_UP and #UP_LEFT gives me an error, which i think means the StartMoving macro can't do it. and i haven't been able to make a diagonal monster AI by flagging the right bits. It doesn't bode well that the AI scripts have the comment "Choose out of 4 directions, UDLR." I'm looking at oStartMovingInADirection, which you see the JSR for in the StartMoving macro, but I don't really know what to make of it. I wonder where the arguments are defined...
zeldafreakneo
Posts: 5
Joined: Mon Sep 10, 2018 7:37 am

Re: Having difficulty finding Diagonal movement scripts for 4.5

Post by zeldafreakneo » Wed Aug 12, 2020 1:46 pm

Thank you for looking into this. Hopefully a solution can be found soon.
WillElm
Posts: 116
Joined: Wed Mar 20, 2019 3:56 am

Re: Having difficulty finding Diagonal movement scripts for 4.5

Post by WillElm » Wed Aug 12, 2020 3:41 pm

zeldafreakneo wrote:
Wed Aug 12, 2020 1:46 pm
Thank you for looking into this. Hopefully a solution can be found soon.
I'm pretty lost tbh. I have a few threads on things that are different in the scripts/engine. I really like so many of the features of 4.5.6 but there are so many basic changes that make small modifications completely different. I'm sure many of these things will be solved in time though.
User avatar
Doktor.E
Posts: 6
Joined: Thu Aug 13, 2020 1:40 am
Location: Huntsville, AL

Re: Having difficulty finding Diagonal movement scripts for 4.5

Post by Doktor.E » Thu Aug 13, 2020 2:16 am

Maybe this is what you're looking for? It works for me.

Code: Select all

;;;; 
    
    TXA
    STA temp ;; assumes the object we want to move is in x.

    StartMoving temp, #DOWNLEFT
        TXA
        STA temp ;; assumes the object we want to move is in x.
        ChangeFacingDirection temp, #FACE_DOWN

    RTS
I just modified the tutorial movement scripts to say #DOWNLEFT instead of just #DOWN or #LEFT. I made these for each of the 4 additional directions to make it an 8 direction game. Then I just assigned them with the input editor as you would a 4 direction game. So for Down/Left, you would choose those two directions and select "Hold". If you're looking for strictly diagonal movement like in Q*Bert for example, I imagine you would just use this way and exclude left, right, up, and down.

I'm still in the tutorial phase, so this probably isn't the best way to do it or whatever. Also collisions are a lil ugly because I'm still using the tutorial script for solid objects where you simply stop moving upon collision.

Hope this helps!
WillElm
Posts: 116
Joined: Wed Mar 20, 2019 3:56 am

Re: Having difficulty finding Diagonal movement scripts for 4.5

Post by WillElm » Thu Aug 13, 2020 2:28 am

Doktor.E wrote:
Thu Aug 13, 2020 2:16 am
Maybe this is what you're looking for? It works for me.

Code: Select all

;;;; 
    
    TXA
    STA temp ;; assumes the object we want to move is in x.

    StartMoving temp, #DOWNLEFT
        TXA
        STA temp ;; assumes the object we want to move is in x.
        ChangeFacingDirection temp, #FACE_DOWN

    RTS
I just modified the tutorial movement scripts to say #DOWNLEFT instead of just #DOWN or #LEFT. I made these for each of the 4 additional directions to make it an 8 direction game. Then I just assigned them with the input editor as you would a 4 direction game. So for Down/Left, you would choose those two directions and select "Hold". If you're looking for strictly diagonal movement like in Q*Bert for example, I imagine you would just use this way and exclude left, right, up, and down.

I'm still in the tutorial phase, so this probably isn't the best way to do it or whatever. Also collisions are a lil ugly because I'm still using the tutorial script for solid objects where you simply stop moving upon collision.

Hope this helps!
No that's likely the way to do it. For whatever reason, I couldn't get diagonal ai to work. I'm in platformer though, so it might be like 4.1.5 where you have to do a modification to get vertical movement to work.
User avatar
Doktor.E
Posts: 6
Joined: Thu Aug 13, 2020 1:40 am
Location: Huntsville, AL

Re: Having difficulty finding Diagonal movement scripts for 4.5

Post by Doktor.E » Sat Aug 22, 2020 9:54 am

WillElm wrote:
Thu Aug 13, 2020 2:28 am
Doktor.E wrote:
Thu Aug 13, 2020 2:16 am
Maybe this is what you're looking for? It works for me.

Code: Select all

;;;; 
    
    TXA
    STA temp ;; assumes the object we want to move is in x.

    StartMoving temp, #DOWNLEFT
        TXA
        STA temp ;; assumes the object we want to move is in x.
        ChangeFacingDirection temp, #FACE_DOWN

    RTS
I just modified the tutorial movement scripts to say #DOWNLEFT instead of just #DOWN or #LEFT. I made these for each of the 4 additional directions to make it an 8 direction game. Then I just assigned them with the input editor as you would a 4 direction game. So for Down/Left, you would choose those two directions and select "Hold". If you're looking for strictly diagonal movement like in Q*Bert for example, I imagine you would just use this way and exclude left, right, up, and down.

I'm still in the tutorial phase, so this probably isn't the best way to do it or whatever. Also collisions are a lil ugly because I'm still using the tutorial script for solid objects where you simply stop moving upon collision.

Hope this helps!
No that's likely the way to do it. For whatever reason, I couldn't get diagonal ai to work. I'm in platformer though, so it might be like 4.1.5 where you have to do a modification to get vertical movement to work.


It feels pretty solid. I'm trying to figure out a way to adjust speed for diagonal movement now. It sorta adds the Up/Down and Left/Right speed together when you go diagonally.
Post Reply