@Tawnithan HOW DID I KNOW WHAT IT WAS BEFORE I CLICKED (Today)

@AJollyCorpse Interesting theories! Maybe after a little while of not drawing it just takes awhile to get back into it -_- (Today)

@AJollyCorpse Haha, that kinda seems like the opposite will happen but.. I dont know if I can give it up for 6 months :O (Today)

RT @saint11: "Oh my god a big chest!" "I'll get it!" "No, I'll get it!" t.co/bug7vaDXq8 #TowerFall (Today)

What is it with my brain and its ability to just totally forget how to draw anything. (Today)

@mossmouth @aeiowu @StoryFort @fucrate Get BLOWN UP! #bodied #exposed (Today)

@torahhorse sega dreamcast committed sudoku before its time (Today)

RT @octonion: TI-89 - 188K RAM, 2.7 MB storage. Kindle Fire - 1GB RAM, 8 GB storage. Same price. (Today)

@MANvsGAME That comment is what set the wheels in motion... the twinkle in the eye of Savage that would later become "BE A MAN" (Today)

@MANvsGAME t.co/kRIrA2c3EV (Today)

RT @phubans: If you follow me but aren't familiar with any of my work, I've put it all neatly on this page with downloads, too - t.c… (Today)

RT @ColinNorthway: In case anyone missed it my GDC talk on the art of Incredipede is up for frees! I'm pretty proud of it: t.co/Ld3k… (Today)

@psysal @igdaphx @gamecolab Aw YEAH we even had a stage and a sound system for this meeting. PRO AS SHIT (Yesterday)

Awesome turn out tonight for @igdaPHX at the @GameCoLab - t.co/atw4UIduPl :D The phoenix game dev community is growing! (Yesterday)

@YourWifeAndKids @marshall_cannon Yeah, he is. I never submitted my best time because I didn't want to be on my own leaderboards ;D (Yesterday)

@BeeMickSee Brandon McCartin: ADULT (Yesterday)

@YourWifeAndKids Hey thanks! <3 I saw your name climbing the ranks recently. Can you dethrone @marshall_cannon? ;D (Yesterday)

@NoelFB Interesting set up :O but I hope a frames palette with onion skinning is still an option ;D (Yesterday)

RT @AeornFlippout: I really look forward to my XBox telling me I have too many people in the room and that I need to pay up: t.co/H… (Yesterday)

RT @igdaphx: Our May meeting is tonight at 7:30pm at @GameCoLab. Details here: t.co/TYDxnGztAW See you there! (Yesterday)

follow
search

2013 - 2 - 18 / 12:42 pm / games

Dev Log: Slopes and Slopes

Dev Log: Slopes and Slopes

Still working on the re-make of my Global Game Jam game! The most recent development I can talk about is this:

Image

Image

Look at those beautiful SLOPES! I haven't actually done any platforming with slopes since all the way back in 2009 when I first made Jottobots (and before that, Verge.) This is my first time doing slopes of any sort in Flashpunk. There were a couple of hurdles to get over to get them working smoothly though.

The first major hurdle is that I'm using Ogmo Editor for all my level data. Usually my method of making collision data in Ogmo Editor is to just use a "grid" layer, and then that gets imported into my Flashpunk project as a Grid collision mask. That usually works, but in the case of slopes it does not... the Grid only supports a tile grid of solid boxes of collision -- no slopes!

My way of solving this was to go back and change my grid layer to a layer of tiles. I made a small tile sheet that contained all of the slopes that I wanted to use, and drew the collision with that. The tile sheet looked like this:

Image
So now I could export data from Ogmo that would have solid blocks and slopes. Note that it's important to keep the tile at 0,0 completely blank, otherwise there are some complications in the Flashpunk code to convert it to collision data.

Next I made this ugly looking function that takes a tilemap and converts it into a bunch of collision data of a given type. Note that this function is in my "Level" class, which extends "World"

public function solidTilesToGrid(tilesEntity:String, type:String):void {
var tilesSolid:Entity = getInstance(tilesEntity);
var tileMap:Tilemap = tilesSolid.graphic as Tilemap;

addMask(tileMap.createGrid([7]), type);

var tilebitmap:BitmapData = tileMap.tileset;
var maskbitmap:BitmapData = new BitmapData(16, 16, true, 0);

for (var xx:uint = 0; xx < tileMap.columns; xx++) {
for (var yy:uint = 0; yy < tileMap.rows; yy++) {
var tile:uint = tileMap.getTile(xx, yy);
if (tile != 0 && tile != 7) {
maskbitmap.fillRect(maskbitmap.rect, 0);
maskbitmap.copyPixels(tilebitmap, tileRect(tileMap, tile), zero);
addMask(new Pixelmask(maskbitmap.clone()), type, xx * tileMap.tileWidth, yy * tileMap.tileHeight);
}
}
}

maskbitmap.dispose();

if (!drawCollisions) {
remove(tilesSolid);
tilesSolid = null;
}
}


The function first uses tileMap.createGrid() which is a Flashpunk function that will convert tiles of a certain index into a Grid for collision. In my case, the 7th tile on my tilesheet was the completely solid one, so I use [7] for that function. The next part is a little weird. I iterate through all the tiles on the tileMap, and if I hit a tile thats not blank, and that's not the 7th (completely solid) tile, then I must be looking at a slope. I end up copying the pixels from the tile I'm looking at, and then I make a pixelmask out of it. I then add the pixelmask to the world with addMask(), and that results in all of the slopes being copied into pixel mask collision data.

There's also the function tileRect() in there, which just returns a rectangle of the corresponding pixel data for any tile on tilemap.

So that's what I'm working with right now. I'll save the actual collision / moving up and down slopes for next time!

2 Comments
Avatar

2013 - 2 - 18 1:29 PM

Malky

Thanks for posting about this! I love FP and Ogmo, but I've hit the "how the hell do I do slopes" wall a few times now. I'm glad I seem to be on the right track so far, and I'm looking forward to seeing more of your thoughts on the subject.

Avatar

2013 - 2 - 18 1:33 PM

Kyle

Awesome! Glad I could help :) The only issue right now is that I create a separate pixel mask for each slope, but I think this might be the best way to go... the only other thing I could think of was a big pixel mask for the entire tile layer, but that's probably horrible for performance.

Avatar

Post your comment!

POST COMMENT

about

About

Hi there, my name is Kyle, and I'm a 27 year old kid with adult powers. I'm making video games and living the indie game developer life in Tempe, Arizona. Here you will find my thoughts, games, websites, doodles, and other stuff like that. I worked on Snapshot, Offspring Fling, and a whole bunch of other games. If you want to get a hold of me use the form on the bottom of the page, leave a comment, or just tweet at me. I try to post three times a week. Thanks for stoppin' by!

facebook

old sites

xerus kylepulver

contact

Your message has been sent! Thanks :)
SEND MESSAGE