Sidescroller

by Forum_account
Sidescroller
This library gives you the basic movement system of a platformer. You can make an action/platform game in minutes!
ID:738134
 
This is a small update that adds a couple of minor things. First, it adds two more parameters to the left() and right() procs. Previously these procs had one parameter which was the width of the bounding box to use. The two optional parameters that were added can be used to specify the bottom and top of the bounding box. By default the bottom is 1 and the top is pheight so the bounding box is the same height as the atom.

If the mob attacks by thrusting a dagger straight outwards in the direction they're facing, you can do something like this to find the targets:

for(var/mob/m in front(8, 12, 13))
m.take_damage(10)

The bounding box extends 8 pixels in front of your mob, it's bottom is at the 12th pixel of your icon and the top is at the 13th pixel.

The other change is that step_x and step_y are used in the atom's New() proc (if the atom is an /atom/movable) to set the object's initial px and py vars. This lets you define static pixel offsets for all objects - previously you'd have to do this in their constructor:

// you used to have to do this:
mob/powerup
New()
..()
set_pos(px + 8, py + 8)

// now you can do this:
mob/powerup
step_x = 8
step_y = 8

While these changes are useful, they were added mostly for the Sidescroller Challenges. I just added three more challenges, two of which are made easier by these changes.
Nice! I had made a hacky workaround for the height issue of left() and right by spawning a mob of the desired size at the location and checking inside it. This is much cleaner!
I'm glad to hear you found it useful! If you come across anything else like this that you think would be handy to have as part of the library, just let me know. It's hard to think to make these kinds of changes until I run into the need for it, and while I use the library a bit there are lots of things I've just never needed.

I often try to come up with similar helper procs that would be more convenient ways to call obounds(), but one of two things happens:

1. The helper proc ends up having the exact same parameters as obounds().
2. The helper proc ends up just being an easier way to create the left() and right() procs, but doesn't do anything you can't easily do with them.