Texture2D spritesheetPTR; // A pointer to the sprite sheet #endregion Fields #region Constructors public Tile(GameManager game, Texture2D spritesheetPTR, int value,Rectangle clip) { this.game = game; this.spritesheetPTR = spritesheetPTR; this.clip = clip; this.value = value; }
// Default Constructor public Entity2(GameManager game) : base(game) { this.game = game; this.spriteBatch = game.spriteBatch; this.camera = game.camera; pxlrect = new Rectangle(0, 0, 3, 3); whtpxl = game.Content.Load<Texture2D>("whtpxl"); state = State.STANDING; direction = Direction.RIGHT; status = Status.INACTIVE; loadPhysics(); isGravityOn = true; deltaX = 0.0f; deltaY = 0.0f; animationOffset = new Vector2(-33,-12); setAABB(); sensorA = new Vector2(AABB.Left + 1, AABB.Bottom); sensorB = new Vector2(AABB.Right - 1, AABB.Bottom); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (GameManager game = new GameManager()) { game.Run(); } }
// Default Constructor public KillableCreature(GameManager game) : base(game) { healSpeed = 500; // These values are just so the compiler will shut up. I highly recoverSpeed = 20; // recommend that you overwrite these when you extend this class. poisonTimer = 100; // [NOT CURRENTLY USED] }
public void JumpTest() { GameManager game = new GameManager(); Entity target = new Entity(game); target.Jump(); Assert.AreEqual(target.getState(), Entity.State.INAIR); }
public TileLayer(GameManager game, Texture2D spritesheet, int[,] tileNums) { this.game = game; this.spritesheetPTR = spritesheet; buildHeightmaps(); tile = buildTileLayer(tileNums); }
public void centerPointTest() { GameManager game = new GameManager(); Entity target = new Entity(game); Vector2 expected = new Vector2(target.position.X + (target.rect.Width / 2), target.position.Y + (target.rect.Height / 2)); Vector2 actual; actual = target.centerPoint(); Assert.AreEqual(expected, actual); }
Animation walkLeft, walkRight; // Animations #endregion Fields #region Constructors public Hero2(GameManager game, string ponyname) : base(game) { rect = new Rectangle((int)position.X, (int)position.Y, _heroWidth, _heroHeight); this.name = ponyname; this.spritesheet = game.Content.Load<Texture2D>("spritesheet_" + ponyname); loadHero(ponyname); loadAnimations(); }
public void getStateTest() { GameManager game = new GameManager(); Entity target = new Entity(game); Entity.State expected = Entity.State.STANDING; Entity.State actual; actual = target.getState(); Assert.AreEqual(expected, actual); expected = Entity.State.INAIR; Assert.AreNotEqual(expected, actual); }
// Default Consructor public Map(GameManager game, Texture2D spritesheet, string MapFileName) { this.game = game; this.camera = game.camera; this.spritesheet = spritesheet; loadMap(MapFileName); tileMapWidth = layer[collisionLayer].tile.GetLength(1); tileMapHeight = layer[collisionLayer].tile.GetLength(0); mapWidthInPixels = tileMapWidth * tileWidth; mapHeightInPixels = tileMapHeight * tileHeight; }
Animation walkLeft, walkRight; // Animations #endregion Fields #region Constructors public Enemy(GameManager game, string enemyname) : base(game) { rect = new Rectangle((int)position.X, (int)position.Y, _enemyWidth, _enemyHeight); this.enemyname = enemyname; this.spritesheet = game.Content.Load<Texture2D>("spritesheet_" + enemyname); loadEnemy(enemyname); loadAnimations(); setCollisionOffsets(); this.status = Status.ACTIVE; }
// Default Constructor public Level(GameManager game, string LevelNumber) : base(game, game.spriteBatch) { this.game = game; this.player = game.player; this.camera = game.camera; // Loads Map Texture2D mapSpritesheet = game.Content.Load<Texture2D>("spritesheet_map-" + LevelNumber); this.map = new Map(game, mapSpritesheet, "Data\\map-" + LevelNumber + ".txt"); // Loads Level loadLevel("Data\\level-" + LevelNumber + ".txt"); Components.Add(this.player); }
// Default Constructor public Entity(GameManager game) : base(game) { this.game = game; this.spriteBatch = game.spriteBatch; this.camera = game.camera; pxlrect = new Rectangle(0, 0, 3, 3); whtpxl = game.Content.Load<Texture2D>("whtpxl"); state = State.STANDING; direction = Direction.RIGHT; status = Status.INACTIVE; loadPhysics(); isGravityOn = true; deltaX = 0.0f; deltaY = 0.0f; sensorA = botLeft; sensorB = botRight; setAABB(); }
public void LandTest() { GameManager game = new GameManager(); Entity target = new Entity(game); target.Land(); Assert.AreEqual(target.getState(), Entity.State.STANDING); }
// Default Constructor public Player(GameManager game) : base(game) { this.game = game; loadPlayer("Data\\player.txt"); }
public void MoveRightTest() { GameManager game = new GameManager(); Entity target = new Entity(game); float before = target.DeltaX; target.MoveRight(); Assert.AreEqual(target.DeltaX, before + Physics.xAcceleration); }
public void placeTest() { GameManager game = new GameManager(); Entity target = new Entity(game); Vector2 location = new Vector2(); target.place(location); Assert.AreEqual(target.position,location); }
public void MoveUpTest() { GameManager game = new GameManager(); Entity target = new Entity(game); float before = target.DeltaY; target.MoveUp(); Assert.AreEqual(target.DeltaY, before - Physics.yAcceleration); }