public World() { Controller = new Controller (); Input = new Input (); View = new View (); RegisterEvents (); Audio.PlayMusic (); }
void DrawProjectiles(Controller c) { foreach (ActiveObject obj in c.Projectiles) obj.Draw (); }
/// <summary> /// Pres the render and draw background and tiles. /// </summary> void PreRenderAndDrawBackground(RenderWindow context, Controller c) { if (PreRenderTexture == null || c.ResetGraphics) { c.ResetGraphics = false; PreRenderTexture = new RenderTexture ((uint)Game.Width, (uint)Game.Height, false); PreRenderTexture.Draw (DAO.GetSprite (Element.HDOcean)); foreach (Tile tile in c.LevelMap.CollisionTiles.Values) { tile.UpdatePosition (); PreRenderTexture.Draw (tile.DstSprite); } PreRenderTexture.Display (); BackgroundAndTilesSprite = new Sprite (PreRenderTexture.Texture); } else { context.Draw (BackgroundAndTilesSprite); } }
void DrawLevelTimer(RenderWindow context, Controller c) { LevelTime.DisplayedString = c.LevelTimer.CurrentTime.ToString (); context.Draw (LevelTime); }
/// <summary> /// Draws the player lives and scores. /// </summary> void DrawPlayerLivesAndScores(RenderWindow context, Controller c, List<int> playersIDs) { foreach (int p in playersIDs) { PlayerUIs [p].Lives.DisplayedString = Controller.Lives [p].ToString (); context.Draw (PlayerUIs [p].Lives); } foreach (int p in playersIDs) { PlayerUIs [p].Score.DisplayedString = Controller.Scores [p].ToString (); context.Draw (PlayerUIs [p].Score); } }
void DrawEnemies(Controller c) { foreach (ActiveObject obj in c.Enemies) obj.Draw (); }
// static void JoystickPress (uint joystickNum) // { // if (Joystick.IsConnected (joystickNum)) { // if (Joystick.GetAxisPosition (joystickNum, Joystick.Axis.X) == -100 // || Joystick.GetAxisPosition (joystickNum, Joystick.Axis.Y) == -100) // ButtonsDown [joystickNum] = true; // else // if (Joystick.GetAxisPosition (joystickNum, Joystick.Axis.X) == 100 // || Joystick.GetAxisPosition (joystickNum, Joystick.Axis.Y) == 100) // ButtonsDown [joystickNum] = true; // } // } // void DrawJoystickDebugInfo (RenderWindow context) // { // ButtonsDown = new bool[]{ false, false, false, false }; // // for (uint i = 0; i < 4; i++) // JoystickPress (i); // // for (uint i = 0; i < ButtonsDown.Length; i++) { // if (ButtonsDown [i]) { // RectangleShape shape = new RectangleShape (new Vector2f (32, 32)); // shape.FillColor = ColoursPlayer [i]; // shape.Position = PosScores [i]; // context.Draw (shape); // } // if (Joystick.IsConnected (i)) { // Text text = new Text (Joystick.GetAxisPosition (i, Joystick.Axis.X).ToString (), GameFont, 24); // text.Color = ColoursPlayer [i]; // text.Position = new Vector2f (PosScores [i].X, PosScores [i].Y + 32); // context.Draw (text); // } // } // } void DrawDebug(RenderWindow context, Controller c, List<int> playersIDs) { DEBUG_TimeTillNextLevelTimer.DisplayedString = c.TimeTillNextLevelTimer.CurrentTime.ToString (); context.Draw (DEBUG_TimeTillNextLevelTimer); Color colorHitbox = new Color (255, 0, 0, 255); Color colorActionPoint = new Color (0, 255, 0, 255); Color colorPushDetector = new Color (0, 0, 255, 255); Color colorFeet = new Color (255, 0, 255, 255); foreach (Cage cage in c.Cages) { RectangleShape rect = new RectangleShape (new Vector2f (cage.HitBox.Width, cage.HitBox.Height)); rect.Position = new Vector2f (cage.HitBox.Left, cage.HitBox.Top); rect.FillColor = colorHitbox; context.Draw (rect); } // foreach (Tile tile in c.LevelMap.CollisionTiles.Values) { // RectangleShape rect = new RectangleShape (new Vector2f (tile.HitBox.Width, tile.HitBox.Height)); // rect.Position = new Vector2f (tile.HitBox.Left, tile.HitBox.Top); // rect.FillColor = colorHitbox; // context.Draw (rect); // } foreach (int p in playersIDs) { PlayerObj player = c.AllPlayers [p]; IntRect feetrect = player.Get2PixelBelowRect (); RectangleShape feetBox = new RectangleShape (new Vector2f (feetrect.Width, feetrect.Height)); feetBox.Position = new Vector2f (feetrect.Left, feetrect.Top); feetBox.FillColor = colorFeet; context.Draw (feetBox); RectangleShape rect = new RectangleShape (new Vector2f (player.HitBox.Width, player.HitBox.Height)); rect.Position = new Vector2f (player.HitBox.Left, player.HitBox.Top); rect.FillColor = colorHitbox; context.Draw (rect); RectangleShape actionPoint = new RectangleShape (new Vector2f (10, 10)); actionPoint.Position = player.GetActionPoint (); actionPoint.FillColor = colorActionPoint; context.Draw (actionPoint); RectangleShape pushRect = new RectangleShape (new Vector2f (player.PushRect.Width, player.PushRect.Height)); pushRect.Position = new Vector2f (player.PushRect.Left, player.PushRect.Top); pushRect.FillColor = colorPushDetector; context.Draw (pushRect); if (player.EnemyPushed != null) { RectangleShape enemyPushedRect = new RectangleShape (new Vector2f (player.EnemyPushed.HitBox.Width, player.EnemyPushed.HitBox.Height)); enemyPushedRect.Position = new Vector2f (player.EnemyPushed.HitBox.Left, player.EnemyPushed.HitBox.Top); enemyPushedRect.FillColor = colorPushDetector; context.Draw (enemyPushedRect); } } foreach (Enemy enemy in c.Enemies) { RectangleShape rect = new RectangleShape (new Vector2f (enemy.HitBox.Width, enemy.HitBox.Height)); rect.Position = new Vector2f (enemy.HitBox.Left, enemy.HitBox.Top); rect.FillColor = colorHitbox; context.Draw (rect); IntRect feetrect = enemy.Get2PixelBelowRect (); RectangleShape feetBox = new RectangleShape (new Vector2f (feetrect.Width, feetrect.Height)); feetBox.Position = new Vector2f (feetrect.Left, feetrect.Top); feetBox.FillColor = colorFeet; context.Draw (feetBox); } foreach (ActiveObject obj in c.Projectiles) { RectangleShape rect = new RectangleShape (new Vector2f (obj.HitBox.Width, obj.HitBox.Height)); rect.Position = new Vector2f (obj.HitBox.Left, obj.HitBox.Top); rect.FillColor = colorHitbox; context.Draw (rect); } }
void DrawCoins(Controller c) { foreach (Coin coin in c.Collectables) coin.Draw (); }
void DrawCage(Controller c) { foreach (Cage cage in c.Cages) cage.Draw (); }
static void DrawPlayers(Controller c, List<int> playersIDs) { foreach (int p in playersIDs) c.AllPlayers [p].Draw (); }