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.
- Downloading the Library and Running Demos
- Including the Library in Your Own Project
- Installing the Library's Help Files
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.
Read through _readme.dm, it contains a lot of useful information about the library.
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.
Here's what you'll see when you run "basic-demo":
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").
Create some icons:
Write some code to set the icons and define some turfs:
Then make a map:
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.
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.