Επιστροφή στις Δημοσιεύσεις

Developing with FlashPunk

Konstantinos Egkarchos / September 22, 2011

After some time playing with FlashPunk I finally think I got a big part of it. FlashPunk is an actionscript 3 game engine for flash. And that is the magic, because I didn’t need the fancy Adobe Flash Professional which costs 700$ to develop a game. Just download flashdevelop and start coding in actionscript 3.

Starting from the bottom since I never really had the chance to code in as3, I got amazed of how easy it was with FlashPunk. You actually don’t need to know anything. A tutorial was ready to drive me in, with anything I ever wanted. Images, keyboard/mouse input, collision, sound, particles, animated sprites (!!!), and not only that but a community member, Zachari Lewis, created a series of videos showing how to use Ogmo editor, and load the level I create with it in my game. So here are the core steps:

  • Set up flashdevelop with FlashPunk.
  • Starting flashpunk

public class Main extends Engine

  • Loading a world (the same as levels or menus)

FP.world = new MyWorld;

  • Keyboard Input
Input.define("Shoot", Key.SPACE, Key.X, Key.C);

if (Input.check("Shoot"))
  • Collision
width = 50;
height = 50;
type="bullet";
var b:Bullet = collide("bullet", x, y) as Bullet;
if (b)
{...}
  • Sound
[Embed(source = 'assets/shoot.mp3')] private const SHOOT:Class;

public var shoot:Sfx = new Sfx(SHOOT);
shoot.play();
  • Animated sprites
[Embed(source = 'assets/swordguysprite.png')] private const SWORDGUY:Class;

public var sprSwordguy:Spritemap = new Spritemap(SWORDGUY, 48, 32);
sprSwordguy.add("stand", [0, 1, 2, 3, 4, 5], 20, true);
sprSwordguy.add("run", [6, 7, 8, 9, 10, 11], 20, true);
graphic = sprSwordguy;
sprSwordguy.play("stand");

That’s the basics. Simple, aren’t they? With these and more I’ve started creating my game Invaders from the Strange Space, which is a clone of Space Invaders but much more interesting I hope. More posts will come with tutorials of how to use FlashPunk, creating amazing yet simple effects, and developing a game. Oh, and of course my game :D.