LK4O4 blog header photo
LK4O4's c-blog

"Truth... is the equivalent of love."

Posts 0Blogs 38Following 0Followers 19



Flixel, Day 6

Posted by: Ryan

I came across an ActionScript 3 game library called Flixel, which is pretty simple, but it's also pretty damned cool in my opinion. For those who don't know, ActionScript is the programming language that Flash uses, and there's something about coding files, compiling them, and getting back .swf files that just feels really cool. So I've set it all up on my home computer and my work computer, and I've been messing with it to try and make a small 2D Flash game.

Before I get on with this, I want to discuss 2D character movement.

Thoughts on Character Movement

The first time I made a prototype character moving on screen, I got really silly with the physics of it, and I had a character who bounced every time he landed from a jump or hit a wall. I had him locked into a single screen, so moving him kind of reminded me of a patient in a psyche ward, jumping into the walls over and over, bouncing off the wall, then bouncing slightly off of the floor as well. My girlfriend wondered why I decided to get rid of the "bounce" in this prototype.

While it's true that the bounce is fun, there's a reason that Mario and Mega Man-style games don't have any bounce. Most 8-bit platformers were built with precision jumping in mind. And precision jumping is in no way realistic. The player thinks that movement is precise if they can make the character do exactly what they want. The player presses right, and their character moves right. If the player stops pressing right, the character should almost immediately stop moving.

When the player runs forward and jumps, their character jumps forward, and if they let go of the forward button, then their character should stop moving forward in mid-air, and just drop straight down. Or even better, they can press the opposite direction, and turn around in mid-air. When the player presses left or right, they move left or right, regardless of the realism involved with changing direction in mid-air; that's what makes the control feel precise. I don't care if I'm in the air or in the middle of another animation or whatever your excuse is: I pressed left, move me left dammit!

Of course, there is something to be said for the more emergent-style gameplay that comes from unpredictable movement, like a slight bounce when the character collides with a wall. Just know that when you do something like that to your character, you had better not make any precise platforming puzzles or disappearing blocks.

Okay, now back to the actual game creation stuff:

Flixel, Day 3 (Saturday)
Today's Work Time: N/A

First off, you guys should know that I work a Monday through Friday job, so I had the day off today. I went out to the beach with my girlfriend, and she ended up spending the night. I didn't write a single line of code, nor should I have.

Flixel, Day 4 (Sunday)
Today's Work Time: Less than 1 hour

I was really tired today. After my girlfriend left in the morning, I fell back asleep, and I work up around 1PM. For those who don't know, that's very unusual for me. I never sleep in that late. I ended up coding a little bit late at night, since I couldn't sleep. I stole some block images from Mode and made some blocks, which continues my trend of stealing art from the demo game. The blocks look pretty ugly against the 16-bit background, but they're functional for now. All in all, not much got done tonight.

Flixel, Day 5
Today's Work Time: N/A

I expected to be home around 9PM, and I ended up home around 11PM. I didn't feel like writing more code at 11PM at night when I have work the next morning. No coding today either.

However, during my lunch break, I found myself writing down a bunch of ideas for what I might make. It was just a really inspirational day, and I wrote everything down, so once I can get a basic game up and running, then I can modify it with some cool ideas. I'm all hyped about actually making something cool now. A lot of my ideas also involve the graphics and sound, but those are definitely not my strong suits. I'll probably see how far I can go in the actual building of a game before I go out of my way to ask for an artist or musician to help me, but I'll probably have to at some point.

Flixel, Day 6 (Today)
Today's Work Time: Less than 3 hours

I made the floor, ceiling, and wall out of blocks, so that I can actually remove that stupid "if(sprite.y>floor)" type of code. Now everything is done using actual collision detection. Everything is either a square or a rectangle, which makes the collision detection pretty fast, and it doesn't hurt the framerate too much. Also, Flixel does a good job of making collision detection quick and easy; for those who don't know, collision detection is a pain when you have to roll your own on your very first game.

I did run into a collision detection issue though. Since the blocks are all only 16 pixels wide, if the character is moving more than 16 pixels per frame, he'll actually go completely past the wall and he won't collide. The most obvious fix to this is to not make the character move so damned fast, especially since it makes platforming kind of weird. The character now moves slower and doesn't jump as high, which feels better when you're jumping on blocks anyway. To be honest, I occasionally get a weird collision problem, so I'm still sorting that out.

Flixel also makes it really easy to implement a camera that follows the player through the world. It's really like three lines of code. Not bad at all. So I made the world twice as big as the screen, I tested scrolling back and forth around the screen, and it works pretty well.

But of course, you guys want to test it out for yourselves:

You control with just left/right to run, and up is to jump. You might have to click on the screen to make it work.
Login to vote this up!



Please login (or) make a quick account (free)
to view and post comments.

 Login with Twitter

 Login with Dtoid

Three day old threads are only visible to verified humans - this helps our small community management team stay on top of spam

Sorry for the extra step!


About LK4O4one of us since 1:47 PM on 05.07.2009

Hello there.

My name is Ryan and I work at a pretty prominent web company. I'm 24 years old, which makes me one of the youngest people at the company (out of over 100 people). I have half of a college degree, a full-time job, and now I've got a place to hang out and talk about awesome video games.

Feel free to talk to me! <3

== Currently Playing ==
FTL: Faster Than Light
Slitherlink by Nikoli

== Recently Finished ==
Thomas Was Alone
Fire Emblem: Awakening
FTL: Faster Than Light (Easy)
Hotline Miami
Little Inferno
Analogue: A Hate Story
Mark of the Ninja
Atom Zombie Smasher
Time Fcuk
Thirty Flights of Loving
Lone Survivor
Might & Magic: Clash of Heroes
Dynamite Jack
Slitherlink by Nikoli
The Legend of Zelda: Skyward Sword
Ghost Trick
Mighty Switch Force
The Legend of Zelda: Four Swords AE
Shin Megami Tensei: Devil Survivor Overclocked
Mighty Flip Champs
Donkey Kong (Game Boy version)
Escapee GO!
Aura-Aura Climber
Resident Evil: The Mercenaries 3D
Shantae: Risky's Revenge
Dragon Quest Heroes: Rocket Slime
Elite Beat Agents (Normal Difficulty)
Paper Mario
Sonic Colors (Wii version)
Dragon Quest V: Hand of the Heavenly Bride
Mother 3 (Fan Translation)
Muramasa: The Demon Blade (Both Second Endings)
Portal (Steam version)
Cave Story (Wii version)
Spartan: Total Warrior (GameCube version)
LostWinds: Winter of the Melodias
Half-Life 2 (original Xbox version)
The Lost Vikings (Genesis version)
Pokemon HeartGold Version
Bangai-O Spirits (All 160+ Levels Cleared!)
Super Mario 64 DS
The Great Circus Mystery Starring Mickey & Minnie
The World Ends With You
Ninja Gaiden Black (Normal Difficulty)
Chrono Trigger

== Systems I Own and Love ==
Sega Genesis
Sega Dreamcast
Game Boy Advance
Nintendo DS Lite
Nintendo 3DS

== 3DS Friend Code ==
5241 1905 5146

== Wii System Code ==
4688 2108 9135 7828

== Tatsunoko vs Capcom ==
4297 4386 7686

== Monster Hunter Tri ==
Mii code:4688 2108 9135 7828
3DS Code:5241 1905 5146


Around the Community