Permalink
Browse files

Gameplay! Add assets dir, package, and initial structure.

  • Loading branch information...
1 parent af39520 commit de6878005aaf72ea5f2f4bb61a5b196cef192b41 @Zutty committed Mar 11, 2012
View
BIN assets/guy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 src/EvilVille.as → src/uk/co/zutty/evilville/EvilVille.as
@@ -1,4 +1,4 @@
-package
+package uk.co.zutty.evilville
{
import flash.display.Sprite;
@@ -10,8 +10,10 @@ package
public function EvilVille() {
super(640, 480, 60, false);
FP.screen.scale = 1;
- FP.screen.color = 0x000000;
+ FP.screen.color = 0xffffff;
//FP.console.enable();
+
+ FP.world = new GameWorld();
}
}
}
View
18 src/uk/co/zutty/evilville/GameWorld.as
@@ -0,0 +1,18 @@
+package uk.co.zutty.evilville
+{
+ import net.flashpunk.World;
+
+ public class GameWorld extends World {
+
+ private var _player:Player;
+
+ public function GameWorld() {
+ super();
+
+ _player = new Player();
+ _player.x = 320;
+ _player.y = 240;
+ add(_player);
+ }
+ }
+}
View
41 src/uk/co/zutty/evilville/Player.as
@@ -0,0 +1,41 @@
+package uk.co.zutty.evilville
+{
+ import net.flashpunk.Entity;
+ import net.flashpunk.Graphic;
+ import net.flashpunk.Mask;
+ import net.flashpunk.graphics.Image;
+ import net.flashpunk.utils.Input;
+ import net.flashpunk.utils.Key;
+
+ public class Player extends Entity {
+
+ [Embed(source = 'assets/guy.png')]
+ private const GUY_IMAGE:Class;
+
+ private const SPEED:Number = 3;
+
+ public function Player() {
+ graphic = new Image(GUY_IMAGE);
+
+ Input.define("up", Key.UP, Key.W);
+ Input.define("down", Key.DOWN, Key.S);
+ Input.define("left", Key.LEFT, Key.A);
+ Input.define("right", Key.RIGHT, Key.D);
+ }
+
+ override public function update():void {
+ super.update();
+
+ if(Input.check("up")) {
+ y -= SPEED;
+ } else if(Input.check("down")) {
+ y += SPEED;
+ }
+ if(Input.check("left")) {
+ x -= SPEED;
+ } else if(Input.check("right")) {
+ x += SPEED;
+ }
+ }
+ }
+}

0 comments on commit de68780

Please sign in to comment.