// Constructor public Player(Vector2 pos, GameField rf = null, AudioManager audio = null) { skeleton = new AnimatedFigure(SCALE); tongue = new Tongue(); this.pos = pos; this.oldPos = pos; this.width = WIDTH; this.height = HEIGHT; acc.X = ACC_X; acc.Y = ACC_Y; dead = false; gameRef = rf; this.audio = audio; // Store starting position startPos = pos; // Set space animation skeleton.Animate(AnimatedFigure.AnimationMode.Stand, 0.0f, 1.0f, 0); }
// Tongue collision public void GetTongueCollision(Tongue t, float tm) { const float TONGUE_COL_SIZE = Stage.TILE_SIZE; // Top left Vector2 tl = new Vector2(pos.X - TONGUE_COL_SIZE / 2, pos.Y - Stage.TILE_SIZE / 2 - TONGUE_COL_SIZE / 2); // Bottom right Vector2 br = new Vector2(pos.X + TONGUE_COL_SIZE / 2, pos.Y - Stage.TILE_SIZE / 2 + TONGUE_COL_SIZE / 2); // Check if hooked hooked = t.GetCollisionObject() == this; t.SetCollisionObject(this); // Collide t.GetFloorCollision(tl.X, tl.Y, TONGUE_COL_SIZE, tm); t.GetCeilingCollision(tl.X, br.Y, TONGUE_COL_SIZE, tm); t.GetWallCollision(tl.X, tl.Y, TONGUE_COL_SIZE, 1, tm); t.GetWallCollision(br.X, tl.Y, TONGUE_COL_SIZE, -1, tm); t.SetCollisionObject(null); }