Small example of recursive movement

Learn to use DS Game Maker by Example!

Small example of recursive movement

Postby YoshiInAVoid » September 4th, 2011, 2:20 pm

Someone asked me by PM for some moving back and forth automatically code.

I knew that I could do it with about 10 lines by going "If [X] >= 224 ; Start Block ; Move the other way..."

But I decided to keep it small and simple so here it is:

Set Variable,[X];[X]+(Direction?1:-1),this
Set Variable,Direction;[X]!=160?[X]!=64?Direction:1:0,this

The numbers in bold you can change for the co-ordinates that it moves to.

You have to declare Direction in the Variable menu as a Boolean starting at 1 or it will give you a compile error.

Here it is compiled:
DSGMTempNewProject49458902.nds
(352.06 KiB) Downloaded 10 times
User avatar
YoshiInAVoid
 
Posts: 1262
Joined: December 30th, 2010, 11:53 am
Location: England

Return to Tutorials & Examples

Who is online

Users browsing this forum: No registered users and 1 guest