Log In  


Cart #37218 | 2017-02-06 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6

A small cart I've made to make my scroll shooter game development easier.

It's a pretty custom editor, and it's definitely not finished, but you might find it useful if you want to write your own editor.

If you have a good idea about improving this, please, post it down here.

6


Awesome. This doesn't seem to work in the browser...? It's not doing anything with the mouse. Can't wait to try it out later on the client.

Just seeing what you've posted so far about this, I know it's going to improve dev 100% - can't wait to use and abuse it. :)


Hmmm...just tried it on the PocketCHIP and it's not doing anything. The UI loads but using touch(mouse) doesn't do anything.

Should I be able to start making a path right out of the gate with clicking, or is there some setup/config necssary?


Hey @morningtoast, you have to right-click to set a node.

You may want to adjust the code a bit and have the X button change a 'mode'. Then have left click perform the behavior of left or right click conditionally based on that.



Yeah...now that I'm on my desktop with mouse buttons, it's working great :)

Yet I'm still not sure how to utilize it...hopefully he'll clue us in a bit. I got it to create the export.p8 file and see the sprite data stuff but not sure how to use it in a game.


Thanks for attention! As I said, it's not complete, so you might have to edit it to suit your tasks.
A few things to make your work easier:
You can edit export cart's name at line:

export_cartridge = "export.p8"

"Save points" and "Load points" are there to save data to spritesheet. It is saved only to 128 - 159 sprites. There is a limit to 16 maximum points, and it is saved in a column (4 pixels by 16 pixels). It's two pixels for x coordinate, and to for y. It's written the ugliest way possible, so if you want to adjust max size of path you'll have to find all cycles and rewrite those.
What's written after "in_development" region doesn't work right.

You're also able to delete a point by clicking middle mouse button.

If you have specific questions - ask them here, I'll try to answer them as fast as possible


I guess the big thing is how do I use the export? I see the sprite data like you said but I don't know how to use it in my game.

If I draw a path and export it. I can copy that data into my game cart but how do I make a sprite move along the path, etc?

Using the sprite section to store data is WAY beyond my skill so I'm not able to even reverse engineer it, unfortunately :(


First of all you need to set name of your export file. You can export directly to your game cartridge, just make sure, there is no important data in sprite sheet from 128 to 159 indexes. Find this line export_cartridge = "export.p8" and change "export.p8" to whatever you need. For example "mygame.p8". I believe, both editor and game cart are have to be in the same folder.

Second thing you have to do is to copy function load_points from editor to your game cart. This function reads data from sprite sheet and makes a table of points in the end. You might want to change the last line there from "points=pts" to "return pts" so you can use something like

local mypath_number_one = load_points(1)

And a little about saving and reading to and from sprite sheet. Since we need to store coordinate from 0 to 127 we can't have it in one pixel. We can only save values from 0 to 15 (0 to F in hexadecimal) in one pixel (since we have only 16 colors). But if we use two pixels we get 256 possible values (0 to FF in hexadecimal). To save a coordinate we have to split it into two numbers. First number is rounded coordinate/16, and second is coordinate%16. So we have two numbers, and both can be from 0 to 15, and that's exactly what we want. We now use sset to set pixels accordingly(two for x coordinate, and two for y). It's a fairly easy function to use, you can find info about it on wiki.

Moving an object along the path is another thing. What i'm doing is calculating direction to next point as a vector, and set x and y speeds accordingly. When distance to this point is small enough I switch target point to next. If you need help at this, I recommend you to learn a little about linear algebra. For example, this article is pretty good:
http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/



[Please log in to post a comment]