Skip to content

Instantly share code, notes, and snippets.

@EFox2413
Created July 30, 2013 14:18
Show Gist options
  • Save EFox2413/6113307 to your computer and use it in GitHub Desktop.
Save EFox2413/6113307 to your computer and use it in GitHub Desktop.
diff --git a/main.ts b/main.ts
index 1778148..2c04212 100644
--- a/main.ts
+++ b/main.ts
@@ -327,15 +327,24 @@ function newSpellList() : Spell[] {
class Player extends Actor {
x : number = 0;
img : heart.HeartImage = null;
+ imgFlip : heart.HeartImage = null;
xp : number = 975;
upgradePoints : number = 1;
+ isFlipped : bool;
constructor() {
super(0);
this.getSpell("Slash").level = 2;
+ this.isFlipped = false;
}
- getImage() { return this.img }
+ getImage() {
+ if(this.isFlipped)
+ return this.imgFlip;
+ else
+ return this.img;
+ }
+
damage(amount:number) {
super.damage(amount);
@@ -454,8 +463,8 @@ class PlayState implements GameState {
// go right
if(c == "right") {
+ player.isFlipped = false;
turn();
- heart.graphics.newImage("assets/player.png", function(r) { player.img = r; TILE_WIDTH = r.img.width; TILE_HEIGHT = r.img.height; });
if(player.x+1 < map.width && !map.isSolidAt(player.x+1)) {
player.x++;
camera.center(player.x);
@@ -463,8 +472,8 @@ class PlayState implements GameState {
}
// go left
else if(c == "left") {
+ player.isFlipped = true;
turn();
- heart.graphics.newImage("assets/player_reversed.png", function(r) { player.img = r; TILE_WIDTH = r.img.width; TILE_HEIGHT = r.img.height; });
if(player.x-1 >= 0 && !map.isSolidAt(player.x-1)) {
player.x--;
camera.center(player.x);
@@ -567,6 +576,7 @@ var SCREEN_WIDTH, SCREEN_HEIGHT, TILE_WIDTH, TILE_HEIGHT;
heart.preload = function() {
heart.graphics.newImage("assets/player.png", function(r) { player.img = r; TILE_WIDTH = r.img.width; TILE_HEIGHT = r.img.height; });
+ heart.graphics.newImage("assets/player_reversed.png", function(r) { player.imgFlip = r; TILE_WIDTH = r.img.width; TILE_HEIGHT = r.img.height; });
heart.graphics.newImage("assets/top.png", function(r) { tile_top = r; });
heart.graphics.newImage("assets/wall3.png", function(r) { tile_wall = r; });
heart.graphics.newImage("assets/ankh1.png", function(r) { tile_idk = r; });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment