[4.1.5] 8 Directional Movement

Post Reply
User avatar
CutterCross
Posts: 394
Joined: Sat Apr 28, 2018 9:42 pm
Contact:

[4.1.5] 8 Directional Movement

Post by CutterCross » Thu Jun 20, 2019 6:29 pm

8 directional movement is actually really easy to set up. All of the movement code is already set up under the hood (which I'm assuming is left over from Mystic Searches). All you have to do is set up the StartMoving macro.

All of the movement arguments can be found in Constants.asm, starting on line 97:

Code: Select all

MOVE_RIGHT	= #%11000000
MOVE_LEFT 	= #%10000000
MOVE_DOWN	= #%00110000
MOVE_UP		= #%00100000
MOVE_RIGHT_DOWN = #%11110000
MOVE_LEFT_DOWN  = #%10110000
MOVE_RIGHT_UP	 = #%11100000
MOVE_LEFT_UP	 = #%10100000

STOP_RIGHT = #%01111111
STOP_LEFT = #%00111111
STOP_UP = #%11001111
STOP_DOWN = #%11011111
STOP_RIGHT_DOWN = #%01011111
STOP_LEFT_DOWN = #%00011111
STOP_RIGHT_UP = #%01001111
STOP_LEFT_UP = #%00001111
So for adding diagonal directions, just add and assign these scripts to the proper inputs.

Start Movement:

Code: Select all

;;;; Start moving Down+Right ;;;;
StartMoving player1_object, MOVE_RIGHT_DOWN
RTS

Code: Select all

;;;; Start moving Down+Left ;;;;
StartMoving player1_object, MOVE_LEFT_DOWN
RTS

Code: Select all

;;;; Start moving Up+Right ;;;;
StartMoving player1_object, MOVE_RIGHT_UP
RTS

Code: Select all

;;;; Start moving Up+Left ;;;;
StartMoving player1_object, MOVE_LEFT_UP
RTS
(You don't actually NEED these next scripts for stopping movement if you already set up your standard StopMoving scripts for Up, Down, Left, and Right, but I'll post them here anyway.)

Stop Movement:

Code: Select all

;;;; Stop moving Down+Right ;;;;
StopMoving player1_object, STOP_RIGHT_DOWN
RTS

Code: Select all

;;;; Stop moving Down+Left ;;;;
StopMoving player1_object, STOP_LEFT_DOWN
RTS

Code: Select all

;;;; Stop moving Up+Right ;;;;
StopMoving player1_object, STOP_RIGHT_UP
RTS

Code: Select all

;;;; Stop moving Up+Left ;;;;
StopMoving player1_object, STOP_LEFT_UP
RTS
So yeah, this is pretty simple. Makes me wonder why Joe never just gave us these scripts seeing as they're so easy to set up.

*EDIT: Accidently used "StartMoving" in the StopMoving diagonal scripts. Now they should all be correct.
Last edited by CutterCross on Sat Jul 13, 2019 2:14 pm, edited 1 time in total.
Music Man:
The Tower of Turmoil: http://www.nesmakers.com/viewtopic.php?f=12&t=1348
When the Clock Hands Stall: http://www.nesmakers.com/viewtopic.php?f=52&t=2723
User avatar
dale_coop
Posts: 3945
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.1.5] 8 Directional Movement

Post by dale_coop » Thu Jun 20, 2019 6:36 pm

This IS very useful, CutterCross. Thanks for sharing that. I know some are very very interesting.
It should be part of NESmaker by default.

...we should make a Module with that (and more stuff fixed).
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
CutterCross
Posts: 394
Joined: Sat Apr 28, 2018 9:42 pm
Contact:

Re: [4.1.5] 8 Directional Movement

Post by CutterCross » Thu Jun 20, 2019 6:40 pm

dale_coop wrote:
Thu Jun 20, 2019 6:36 pm
This IS very useful, CutterCross. Thanks for sharing that. I know some are very very interesting.
It should be part of NESmaker by default.

...we should make a Module with that (and more stuff fixed).
I think once I finish up my Point and Click demo for WtCHS I'll start working on tutorials for my custom Point and Click and 3D Dungeon Crawler modules (and release them too, of course).
Music Man:
The Tower of Turmoil: http://www.nesmakers.com/viewtopic.php?f=12&t=1348
When the Clock Hands Stall: http://www.nesmakers.com/viewtopic.php?f=52&t=2723
Gilbertmaxter
Posts: 98
Joined: Tue Oct 16, 2018 3:04 am

Re: [4.1.5] 8 Directional Movement

Post by Gilbertmaxter » Thu Jun 20, 2019 6:49 pm

And bookmarked :)

Think this is how mugi did it ?
User avatar
crazygrouptrio
Posts: 53
Joined: Fri Jan 11, 2019 2:22 pm
Location: United States
Contact:

Re: [4.1.5] 8 Directional Movement

Post by crazygrouptrio » Mon Jun 24, 2019 11:00 pm

Awesome, thanks!
User avatar
Mugi
Posts: 636
Joined: Thu Dec 27, 2018 8:30 pm

Re: [4.1.5] 8 Directional Movement

Post by Mugi » Tue Jun 25, 2019 8:58 am

Gilbertmaxter wrote:
Thu Jun 20, 2019 6:49 pm
And bookmarked :)

Think this is how mugi did it ?
?

im making a platformer, and it definitely doesnt have 8-directional movement anywhere :P
Gilbertmaxter
Posts: 98
Joined: Tue Oct 16, 2018 3:04 am

Re: [4.1.5] 8 Directional Movement

Post by Gilbertmaxter » Tue Jun 25, 2019 12:25 pm

For some reason i thought you making a top down as well. My mistake mugi thank you :)
User avatar
Mugi
Posts: 636
Joined: Thu Dec 27, 2018 8:30 pm

Re: [4.1.5] 8 Directional Movement

Post by Mugi » Tue Jun 25, 2019 5:52 pm

i have 8 directional scrolling, not movement xD
User avatar
Raftronaut
Posts: 216
Joined: Mon Sep 03, 2018 4:47 pm

Re: [4.1.5] 8 Directional Movement

Post by Raftronaut » Sun Aug 04, 2019 3:10 pm

I finally got around to getting this, took me a little longer as I was creating input commands for "PRESS" down+left etc instead of "HOLD" down+left. It's a rookie mistake on my part, but an important distinction in case anyone if having trouble with getting it working in the future.

Other than that, this was painless and works terrific! :)
Space Raft 2.0 Demo: [url] http://nesmakers.com/viewtopic.php?f=52&t=2867 [/url]

Chiptune: [url] https://soundcloud.com/user-634230995-350638590 [/url]
Post Reply