by Forum_account
This library gives you the basic movement system of a platformer. You can make an action/platform game in minutes!
I split the code from my sidescroller demo into a library part and a demo part to create a sidescroller library.

Edit: I also made similar changes to my Isometric Pixel Movement demo to create an Isometric library.

Some people had asked about making a pixel movement library instead of just a demo. I was hesitant to make a library because it's not the best type of program to make into a library. You can create some new features just by using the library but certain types of features (i.e. most features) will require changes to the library. Still, I think making a nicer split between the library and demo is a good thing and makes it easier to use. Perhaps a second person will use it now =)

Using the Library

Just like BYOND's top-down movement system gives you default behavior, so does the library. Similar to how you can override Move, Enter, Exited, and other built-in procs to create new effects you can override procs defined by the library to change how the sidescroller works.

The library also comes with documentation that can be integrated with Dream Maker's help. This will let you get help about the library's vars and procs when you press F1. This forum post contains instructions on setting up the documentation.

The Sidescroller Movement System

The library gives each mob a proc called "movement" which is called every tick. By default this proc checks for keyboard input and reacts accordingly. For example, if you're holding onto a ladder and you press the up arrow, the movement proc will call the mob's "climb" proc. If you're standing on the ground and press the right arrow it will call the "move" proc. The move and climb procs come with default behavior but you can override them to create custom behavior. This lets you change how a mob moves just by changing its climb, move, and jump procs, you don't need to change its movement proc.

The library defines the "can_jump" proc for mobs. As the name suggests it is used to determine if the mob is able to jump. The default behavior returns 1 if you're standing on the ground and 0 otherwise. This should make sense - you can only jump when you're touching the ground. You can override the can_jump proc to create new behaviors - double jumps, triple jumps, even unlimited jumps.


The library comes with four demos. To run a demo, check off all of the files in the demo's folder (ex: the "ramps-demo" folder) and make sure the keyboard.dmf file in the common folder is checked. Then compile the program and run it.

The demos show off some of the simpler features. The one called "game-demo" gets into more complicated features - bullets, moving platforms, etc.
What about sidescroller backgrounds, like what you'd see in Sonic the Hedgehog?

It's not as simple as something you map, because the background always moves slower than the rest of the foreground does.
I'd message you on an IM but you don't have any contact information available!

Anyway, the library does not run properly.
Hmm, I think I see what you mean.
Ok, I think it's fixed. They don't make it easy to package libraries.

D4RK3 54B3R wrote:
What about sidescroller backgrounds, like what you'd see in Sonic the Hedgehog?

There are other features that I'd consider more crucial, but this might be one of the more straightforward features to add.
you are god
I made similar changes to my Isometric Pixel Movement demo to create an Isometric library.
Version 1.3 has been posted. The changes to the library are minor. The major change is the documentation. In addition to the library now comes with reference pages that you can add to the DM reference. This means you can press F1 in Dream Maker to see help pages about the library (sample screenshot). This page explains how to set up the documentation.
I just posted version 1.4 which is a fairly large update. There are two big changes:

1. More default behavior. The move, climb, and jump procs that had been defined in the demos are now the library's default behavior.

2. Simpler icon_state management. The set_action, set_direction, and compute_state procs were removed and set_state does all the work. The library uses 4-direction icons for mobs so the icon_state is just the action being performed (standing, moving, jumping, or climbing)

These changes greatly simplified the demos. The only lines in "simple-demo" that relate to the library are the ones to set the mob's pwidth and pheight.

A smaller (but very handy change) now lets you set the mob's position just by setting its loc. The mob's movement proc checks for an external change to the mob's x, y, or z coordinate and will call set_pos. This means you can change a mob's loc the same way you always would (ex: mob.loc = locate(4,5,6)).