Permalink
Browse files

Committing what I have done so far. Will probably be able to continue to

work on this next weekend.
  • Loading branch information...
1 parent f7f3e5b commit 28cabf2ea46c8977be6c9308c92e24b5d48ef890 Shedo Surashu committed Feb 19, 2012
Showing with 39 additions and 58 deletions.
  1. +1 −1 src/Main.as
  2. +5 −46 src/actors/NPC.as
  3. +9 −4 src/actors/Player.as
  4. +4 −3 src/system/Camera.as
  5. +2 −2 src/system/GC.as
  6. +18 −2 src/worlds/Game.as
View
@@ -7,7 +7,7 @@ package
import worlds.*;
- [SWF(width="640", height="480", frameRate="60")]
+ [SWF(width="920", height="600", frameRate="60")]
public class Main extends Engine
{
public function Main()
View
@@ -3,6 +3,7 @@ package actors
import flash.geom.Point;
import net.flashpunk.Entity;
+ import net.flashpunk.FP;
import net.flashpunk.Graphic;
import net.flashpunk.Mask;
import net.flashpunk.graphics.Spritemap;
@@ -23,6 +24,8 @@ package actors
setupSprite();
+ type = "npc";
+
graphic = npcSprite;
npcSprite.play(currentAnim);
@@ -45,52 +48,8 @@ package actors
}
}
- override public function update():void {
-
-// npcSprite.play(currentAnim);
-//
-// if (Input.check("walk_right")) {
-//
-// if (!colliding(new Point(x + speed, y))) {
-// currentAnim = "walk_right";
-// x += speed;
-// }
-//
-// } else if (Input.check("walk_left")) {
-//
-// if (!colliding(new Point(x - speed, y))) {
-// currentAnim = "walk_left";
-// x -= speed;
-// }
-//
-// } else if (Input.check("walk_down")) {
-//
-// if (!colliding(new Point(x, y + speed))) {
-// currentAnim = "walk_down";
-// y += speed;
-// }
-//
-// } else if (Input.check("walk_up")) {
-//
-// if (!colliding(new Point(x, y - speed))) {
-// currentAnim = "walk_up";
-// y -= speed;
-// }
-//
-// }
-//
-//
-// // CHeck if the buttons have been released.
-// if (Input.released("walk_right")) {
-// currentAnim = "stand_right";
-// } else if (Input.released("walk_left")) {
-// currentAnim = "stand_left";
-// } else if (Input.released("walk_down")) {
-// currentAnim = "stand_down";
-// } else if (Input.released("walk_up")) {
-// currentAnim = "stand_up";
-// }
-
+ override public function update():void {
+ layer = -y;
}
public function setupSprite():void {
View
@@ -3,6 +3,7 @@ package actors
import flash.geom.Point;
import net.flashpunk.Entity;
+ import net.flashpunk.FP;
import net.flashpunk.Graphic;
import net.flashpunk.Mask;
import net.flashpunk.graphics.Spritemap;
@@ -23,6 +24,8 @@ package actors
setupSprite();
+ type = "player";
+
// playerSprite = _playerSprite;
graphic = playerSprite;
@@ -32,14 +35,13 @@ package actors
y = position.y;
// Temporary until I can think of a way to make this dynamic.
- setHitbox(32,48,0,0);
-
+ setHitbox(32,32,0,-16);
}
public function colliding(position:Point):Boolean {
// Check for collision against any of the existing tile types.
- var tileType:String = "tile_collision";
- if (collide(tileType, position.x, position.y)) {
+ if (collide("tile_collision", position.x, position.y) ||
+ collide("npc", position.x, position.y)) {
return true;
} else {
return false;
@@ -48,6 +50,9 @@ package actors
override public function update():void {
+ layer = -y;
+// FP.log(layer.toString());
+
playerSprite.play(currentAnim);
if (Input.check("walk_right")) {
View
@@ -11,8 +11,8 @@ package system
public function Camera(){}
public function adjust(mapWidth:int, mapHeight:int, player:Player):void {
- var newCameraX:int = ((player.x + player + player.width)/2) - (FP.width/2);
- var newCameraY:int = ((player.y + player + player.height)/2) - (FP.height/2);
+ var newCameraX:int = ((player.x + player.width)/2) - (FP.width/2);
+ var newCameraY:int = ((player.y + player.height)/2) - (FP.height/2);
// Checks for outbound locations then sets them inside the limit.
if (newCameraX < 0) {
@@ -59,7 +59,8 @@ package system
}
- FP.log("Camera: x="+FP.camera.x.toString()+" y="+FP.camera.y.toString());
+// FP.log("Camera: x="+FP.camera.x.toString()+" y="+FP.camera.y.toString());
+// FP.log(FP.width.toString()+" "+mapHeight.toString()+" Sprite: x="+player.x.toString()+" y="+(player.y + (-player.originY)+ player.height).toString());
}
}
View
@@ -17,8 +17,8 @@ package system
{
// Game Details
public static const GD_NAME:String = "Blaarpgh";
- public static const GD_WIDTH:int = 640;
- public static const GD_HEIGHT:int = 480;
+ public static const GD_WIDTH:int = 920;
+ public static const GD_HEIGHT:int = 600;
public static const GD_FPS:int = 60;
public static const GD_SCALE:int = 2; // Minimum value is 1.
public static const GD_FLASHPUNKCONSOLE:Boolean = true;
View
@@ -37,8 +37,9 @@ package worlds
public function Game()
{
+// player = new Player(new Point(500,250));
player = new Player(new Point(500,250));
-// npc_italy01 = new NPC(new Point(100,50));
+ npc_italy01 = new NPC(new Point(100,50));
maps = Maps.list;
// Set default camera location
@@ -49,6 +50,9 @@ package worlds
override public function update():void {
gameCamera.followPlayer(currentMap.width, currentMap.height, player);
+ mapAboveEntity.layer = -player.bottom;
+ mapAboveAll.layer = -(player.bottom+1);
+ FP.log(FP.screen.width);
super.update();
}
@@ -65,16 +69,28 @@ package worlds
mapAboveEntity = new AboveEntity(currentMap.xml, Tilesets.NEWTOWN5);
mapAboveAll = new AboveAll(currentMap.xml, Tilesets.NEWTOWN5);
+// mapAboveAll.layer = 0;
+// mapAboveEntity.layer = 1;
+// player.layer = 3;
+// npc_italy01.layer = 4;
+// mapAboveGround.layer = 5;
+// mapGround.layer = 6;
+// mapUnderGround.layer = 7;
+// mapMarkerCollisionTriggers.layer = 8;
+// mapMarkerTriggers.layer = 9;
+// mapMarkerCollisions.layer = 10;
+
add(mapMarkerCollisions);
add(mapMarkerTriggers);
add(mapMarkerCollisionTriggers);
add(mapUnderGround);
add(mapGround);
add(mapAboveGround);
-// add(npc_italy01);
add(player);
+ add(npc_italy01);
add(mapAboveEntity);
add(mapAboveAll);
+ FP.log("Layer: "+player.layer.toString());
FP.log("Map has been loaded.");
}

0 comments on commit 28cabf2

Please sign in to comment.