//Constructors public Score(string key, IntPtr render) : base() { color = new SDL_Color { r = 255, g = 255, b = 255, a = 0 }; SpriteEntity scoreSprite; TextureStruct textTexture = TextGenerator.GenerateTexture(render, TextGenerator.lazyFont, "void", color); if (!SpriteEntity.TextureExists(key)) { scoreSprite = new SpriteEntity("scorePlayer1", textTexture); } else { // If it already exists, simply use existing one scoreSprite = AllSprites["scorePlayer1"]; } name = key; AddSprite(key, scoreSprite); ResetPoint(render); }
//Constructors public Ball(string key, IntPtr render) : base() //TODO: key not needed. Remove it { SpriteEntity ballSprite; if (!SpriteEntity.TextureExists("ball")) { ballSprite = new SpriteEntity("ball", render, "assets/images/ball.bmp", 0, 255, 0); } else { ballSprite = new SpriteEntity("ball"); } ballSprite.Pos.h = 25; ballSprite.Pos.w = 25; ballSprite.SubRect.h = 100; ballSprite.SubRect.w = 100; AddSprite("ball", ballSprite); ResetBall(); }
//Constructors public Paddle(string key, IntPtr render, int offset) : base() { SpriteEntity paddleSprite; if (!SpriteEntity.TextureExists("paddle")) { paddleSprite = new SpriteEntity("paddle", render, "assets/images/paddle.bmp", 0, 255, 0); } else { paddleSprite = new SpriteEntity("paddle"); } paddleSprite.Pos.h = 100; paddleSprite.Pos.w = 2; paddleSprite.SubRect.h = 100; paddleSprite.SubRect.w = 20; paddleSprite.Pos.x = offset; paddleSprite.Pos.y = GameConstants.PONG_TABLE_Y / 2 - paddleSprite.Pos.h / 2; AddSprite("paddle", paddleSprite); }