Pixel Movement

by Forum_account
Pixel Movement
A pixel movement library for isometric and top-down maps.
ID:112958
 
I meant to add features to my Pixel Movement library right after adding them to my Sidescroller library, but I let things slide for a while. The Pixel Movement library needed a lot of work to catch up but now it's nearly complete - it's complete enough to post an update.

You can view the hub entry for the complete set of update notes.

Easier to Use

There are some very simple changes that were made to make the library even easier to use. It's now possible to enable pixel movement in your game just by including the library - you don't have to write any code at all to incorporate it!



The video shows how you can add pixel movement to a game just by checking the box to include the library.

New Features

The library has a lot of new features. If you've used my Sidescroller library they should look familiar.

atom.flags

The mob has variables (on_ground, on_left, on_right, etc.) that you can use to check if the mob is standing next to an object. The flags var lets you define properties for objects that can be read from those mob vars (on_ground, etc.).

For example, suppose you use on_left, on_right, etc. to write some wall climbing code - if the mob is next to a wall, they can climb the wall. That works, but you might want to make some walls unclimbable, so you can do something like this:

var/const/NOT_CLIMBABLE = 2

turf
slippery_wall
flags = NOT_CLIMBABLE

// in the wall-climbing code:
mob
proc
climb_wall()
if(on_left & NOT_CLIMBABLE)
src << "You can't climb that wall!"
return
// rest of the code...


The atom.flags var is a bit which gets binary ORed with the mob's flags (on_left, on_right, etc.).

mob.camera

The mob has a camera var, which is an instance of the /Camera object and contains many vars which you can use to control the camera's behavior. You can see examples of this in the demos called "intermediate-demo" and "zelda-demo".

atom.ramp and atom.ramp_dir

You can create sloped tiles by setting the turf's ramp and ramp_dir vars. ramp_dir is a direction (NORTH, SOUTH, EAST, or WEST) which is the direction that the ramp goes up. If the north end of the ramp is the highest point, ramp_dir = NORTH. The ramp var controls how tall the ramp is.

mob.move_to and mob.move_towards

These are procs which are similar to BYOND's built-in walk_to and walk_towards procs. mob.move_to(t), where t is a turf, will make the mob plan and follow a path from their current position to the turf. mob.move_towards is similar, except it doesn't plan a path so it doesn't intelligently avoid obstacles.

New Demos!

The library currently has five demos.

basic-demo: this shows how you can use the library without using many vars or procs that it defines.

intermediate-demo: this shows how to use many of the library's features.

isometric-demo: a simple example that uses the isometric map format.

top-down-demo: a simple example that uses the SIDE_MAP map format.

zelda-demo: a demo that shows how to create some features you'd see in a Zelda game: movement, enemy AI, melee attacks, ranged attacks, and camera control.
The next things I plan to work on are:

* DM reference style documentation. I'm not looking forward to this.

* A demo showing more projectile and map effects (ramps, elevation, etc.). I have the demo written but it uses ripped graphics, and I'd like to avoid that (Zelda-demo being an exception).

* Educational materials. The demos might be helpful to some people, but I'd like to write a few articles that cover specific topics in more detail (and use pictures/video to explain things, not just comments in code).

* A concept I'm calling "control scheme demos". The default movement is meant to be like a person running, but not everyone will use the library for that. People might want to make cars or spaceships. These things might require a bit of work to get just right, so I'd like to include examples that people can build off of.

I have no idea when I'll get the time to make these things, do don't think of this as a promise to make all these things =)
The documentation is almost done. It's a new code file that contains my reference library and the definitions of all the reference pages. You'll just need to run the library, click a verb, then restart DM and you'll have F1 help for all of the library's vars and procs. It's also a nice way to explore the library, by clicking "see also" links you can get a sense of how things work without having to read through code.

I'd like to write a tutorial showing how to include the library and use some of its basic features. I would like to write some more articles about it but I'm hoping to get more user feedback first. I don't want to write an article that isn't needed.

I'm not sure if I'll have any more demos ready for the next update. I'd like to make some larger demos, even more complete than the zelda demo.
I just posted an update which includes the DM reference documentation.

I'd like to make some control scheme demos using the graphics already in the library. I also want to make some more "complete game" type of demos, but I'm not sure if I want to continue with copying things from NES games. I think that showing features from familiar games is a practical thing to do, but people have strange feelings about "non-original" stuff.