Pixel Movement

by Forum_account
Pixel Movement
A pixel movement library for isometric and top-down maps.
ID:113098
 

Using Pixel Movement in BYOND

BYOND uses a tile-based world. This makes it easy to create graphics and build maps, but it also means that the default movement system is tile-based. Sometimes you don't want that. Imagine a racing game where cars moved one whole tile at a time and could only move in 8 directions - it sounds terrible! Having the car move a whole tile at a time doesn't look nice, and being able to move in 8 directions doesn't give the driver the fine control over their car that they'd need.

So here's what you do. You take BYOND's default, tile-based movement system and you build your own, pixel-based movement system on top of it. Instead of moving a whole tile at a time, players can move pixel by pixel and in any direction. You can make a top-down shooter game where the left and right arrow keys turn the player and the up arrow makes them move in whatever direction they're facing. Or, you can keep BYOND's 4 or 8 directional movement and just allow for finer control. You can also have dense obstacles of arbitrary sizes. Instead of having a whole tile be dense or not dense, you can have a stack of crates that takes up half a tile. The player is free to walk in the other half of the tile, or even jump on top of the crates.

That sounds hard, but here's the best part: I've done all that work for you! BYOND lets users create features and package them as libraries. You can then include the library in your project and use the feature.

This tutorial explains how to use my Pixel Movement library. Even if you've never downloaded and used a DM library before, this will tell you everything you need to know.

Contents

Downloading the Library and Running Demos

Go to the library's hub entry and click the download link.

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-1.png"/>
Click to view the full size image.

Once the library has downloaded and is installed, Dream Maker will open and show you the library.

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-2.png"/>

Read through _readme.dm, it contains a lot of useful information about the library.

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-3.png"/>

The library also comes with a few demos. Each demo is in it's own folder ("basic-demo", "intermediate-demo", etc.). To run a demo, open a demo folder and check off all the files in the folder. Then, compile and run the project.

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-4.png"/>

Here's what you'll see when you run "basic-demo":

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-5.png"/>

Note: Make sure you only have the files for one demo included at a time.

Including the Library in Your Own Project

Now I'll show you how to use the library in a project of your own. Go to File -> New Environment... to create a new project (for this example, I named my environment "pixel-movement-example").

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-6.png"/>

Create some icons:

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-7.png"/>

Write some code to set the icons and define some turfs:

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-8.png"/>

Then make a map:

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-9.png"/>

Open the "Lib" folder in the file list and check the box next to "Forum_account.PixelMovement". This will include the library in your project.

<img width="400" height="240" src="http://files.byondhome.com/Forumaccount/pixel-movement-tutorial/step-10.png"/>

Now compile and run your project. You'll move around using the pixel movement system defined by the library instead of BYOND's default tile-based movement.

Click here to download the project shown in the screenshots.

Installing the Library's Help Files

The library comes with help files that you can install, which will give you the ability to see help pages for the library's content when you press F1 in Dream Maker. These steps explain how to set this up.

First, open up the library and include _reference.dm.

Then compile and run the library. You don't need to include any demos. If you have no demos included, you should see this:

Even if you have the files included for a demo, you'll still have these two verbs. Click on the "generate reference pages" verb. You will be prompted about accessing files (you may get multiple prompts), click "Yes" each time.

It may take a few seconds for the documentation to install. When it's done you'll see the "Complete!" message on the screen:

Once its complete, close Dream Seeker and Dream Maker. You have to restart Dream Maker for the changes to the documentation to take effect. When you restart Dream Maker, open up a demo and highlight a variable or proc that's defined by the library, like this:

Then press F1. You'll see that there are now help pages for the library's content.

You can click on the links in the help pages to browse through the library's content and learn how things work, just like you can do with DM's built-in features.

Hey, Forum, you'd probably get a kick out of this.
That BYOND Portal game is just a demonstration of how powerful BYOND can be, but how unwilling people are to get their shit together and make presentable games to distribute to audiences outside of BYOND.
Thanks for the link. I saw the post when I was at work but couldn't watch the video, then forgot to watch it later.

Duelmaster409 wrote:
That BYOND Portal game is just a demonstration of how powerful BYOND can be, but how unwilling people are to get their shit together and make presentable games to distribute to audiences outside of BYOND.

Not only that, but it can be really easy to put a BYOND game together. Not to say that it was easy to make that, but I'm sure people have put much more effort into DM projects and gotten much worse results. When you have a good game idea, original or not, you can put together a good BYOND game very quickly.
Really nice writeup. You do an excellent job providing examples and details and basically leaving little to the end-user to get started. I'm not sure what else you can do to convince people to try it out! I hope they do.
i am willing, he actually got me very interested in this.
Tom wrote:
Really nice writeup. You do an excellent job providing examples and details and basically leaving little to the end-user to get started. I'm not sure what else you can do to convince people to try it out! I hope they do.

Thanks. I think that people are generally aware of the library, but since it has a little learning curve to it you don't see a lot of people using it. I'm not sure where along the learning curve people are getting stuck, so I'm trying to cover all the bases.

I think the biggest problem is that its easy for developers to be invisible in the community. Game players have to play games and we can all see who is playing what. Multiplayer games are automatically social, game development is not. I'm not sure how to make it more social. I'm thinking about doing a contest, but I've been waiting to get the library in better shape first (and even then, I'm still skeptical because most DM contests seem to go poorly).
Forum_account wrote:
I think the biggest problem is that its easy for developers to be invisible in the community. Game players have to play games and we can all see who is playing what. Multiplayer games are automatically social, game development is not. I'm not sure how to make it more social. I'm thinking about doing a contest, but I've been waiting to get the library in better shape first (and even then, I'm still skeptical because most DM contests seem to go poorly).

Forum, if you make a development contest, I will volunteer funding.

Excellent, I'll keep that in mind.
Very informational. Always been a fan of your work on this field and am excited to see that you're advertising it a little more openly! Maybe we'll see such innovation in more BYOND projects to come.
I've included your library into my current project. But now it seems that my macro isn't working anymore to continue my dialogs or the code just doesn't work anymore because of your library.
The library defines its own macros that call your mob's key_up() and key_down() procs. So, instead of defining your own macro in a .dmf file, you'd have to do something like this:

mob
key_down(k)
if(k == "space")
continue_dialog()


Instead of making a macro in the .dmf file to make the space bar continue the dialog, you make the key_down() proc handle it.
Forum_account wrote:
The library defines its own macros that call your mob's key_up() and key_down() procs. So, instead of defining your own macro in a .dmf file, you'd have to do something like this:

> mob
> key_down(k)
> if(k == "space")
> continue_dialog()
>

Instead of making a macro in the .dmf file to make the space bar continue the dialog, you make the key_down() proc handle it.

Thank you, that declares a lot. Although I still didn't get it to work.
mob
key_down(k)
if(k == "return")
if(src.textboxactive==1)
usr.client.MessageBtn()
else
return
Got it to work, but what's the exact name of the Enter/Return key?
It should be "return".
Is there a place where I can read up on all the commands of the keyboard buttons?
I'm not sure what you mean, but you can look in the keyboard.dm file in the library to see which keys have macros defined for them (search for "var/list/keys" in that file, it's towards the bottom).
Forum_account wrote:
I'm not sure what you mean, but you can look in the keyboard.dm file in the library to see which keys have macros defined for them (search for "var/list/keys" in that file, it's towards the bottom).

Thanks, that's what I needed.
Also, for some more explanation, how would I cancel the movement if I'm in a certain part of something, like a cutscene. Normally, I would do:
client
Move()
if(NameSelecting)
return 0
else ..()
You can use the mob's lock_input() proc and clear_input() proc. When input is locked, the key_down() and key_up procs aren't called. clear_input() makes the library forget what keys the player is holding - locking input isn't enough if the player was already holding an arrow key when you called lock_input().
Forum_account wrote:
You can use the mob's lock_input() proc and clear_input() proc. When input is locked, the key_down() and key_up procs aren't called. clear_input() makes the library forget what keys the player is holding - locking input isn't enough if the player was already holding an arrow key when you called lock_input().

How about unlocking it?
Page: 1 2