// <summary> // Draws the current state of the game to the screen. // </summary> // <remarks> // What is drawn depends upon the state of the game. // </remarks> public static void DrawScreen() { UtilityFunctions.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.DrawMainMenu(); break; case GameState.ViewingGameMenu: MenuController.DrawGameMenu(); break; case GameState.AlteringSettings: MenuController.DrawSettings(); break; case GameState.ViewingHowTo: HowToController.DrawHowTo(); break; case GameState.Deploying: DeploymentController.DrawDeployment(); break; case GameState.Discovering: DiscoveryController.DrawDiscovery(); break; case GameState.EndingGame: EndingGameController.DrawEndOfGame(); break; case GameState.ViewingHighScores: HighScoreController.DrawHighScores(); break; } UtilityFunctions.DrawAnimations(); SwinGame.RefreshScreen(30); }
/// <summary> /// Draws the current state of the game to the screen. /// </summary> /// <remarks> /// What is drawn depends upon the state of the game. /// </remarks> public static void DrawScreen() { UtilityFunctions.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: MenuController.DrawMainMenu(); break; case GameState.ViewingGameMenu: MenuController.DrawGameMenu(); break; case GameState.AlteringSettings: MenuController.DrawSettings(); break; case GameState.Deploying: DeploymentController.DrawDeployment(); break; case GameState.Discovering: DiscoveryController.DrawDiscovery(); SwinGame.DrawBitmap(GameResources.GameImage("HomeButton"), HOME_BUTTON_LEFT, TOP_BUTTONS_TOP); break; case GameState.EndingGame: EndingGameController.DrawEndOfGame(); break; case GameState.ViewingHighScores: HighScoreController.DrawHighScores(); break; } UtilityFunctions.DrawAnimations(); SwinGame.RefreshScreen(); }
// '' <summary> // '' Read the user's name for their highsSwinGame. // '' </summary> // '' <param name="value">the player's sSwinGame.</param> // '' <remarks> // '' This verifies if the score is a highsSwinGame. // '' </remarks> public static void ReadHighScore(int value) { const int ENTRY_TOP = 500; if ((_Scores.Count == 0)) { HighScoreController.LoadScores(); } // is it a high score if ((value > _Scores.Item[(_Scores.Count - 1)].Value)) { Score s = new Score(); s.Value = value; AddNewState(GameState.ViewingHighScores); int x; x = (SCORES_LEFT + SwinGame.TextWidth(GameFont("Courier"), "Name: ")); SwinGame.StartReadingText(Color.White, NAME_WIDTH, GameFont("Courier"), x, ENTRY_TOP); // Read the text from the user while (SwinGame.ReadingText()) { SwinGame.ProcessEvents(); DrawBackground(); HighScoreController.DrawHighScores(); SwinGame.DrawText("Name: ", Color.White, GameFont("Courier"), SCORES_LEFT, ENTRY_TOP); SwinGame.RefreshScreen(); } s.Name = SwinGame.TextReadAsASCII(); if ((s.Name.Length < 3)) { s.Name = (s.Name + new string(((char)(" ")), (3 - s.Name.Length))); } _Scores.RemoveAt((_Scores.Count - 1)); _Scores.Add(s); _Scores.Sort(); EndCurrentState(); } }
// <summary> // Handles the user SwinGame. // </summary> // <remarks> // Reads key and mouse input and converts these into // actions for the game to perform. The actions // performed depend upon the state of the game. // </remarks> public static void HandleUserInput() { // Read incoming input events SwinGame.ProcessEvents(); switch (CurrentState) // read state { case GameState.ViewingMainMenu: MenuController.HandleMainMenuInput(); break; case GameState.ViewingGameMenu: MenuController.HandleGameMenuInput(); break; case GameState.AlteringSettings: MenuController.HandleSetupMenuInput(); break; case GameState.Deploying: DeploymentController.HandleDeploymentInput(); break; case GameState.Discovering: DiscoveryController.HandleDiscoveryInput(); break; case GameState.EndingGame: EndingGameController.HandleEndOfGameInput(); break; case GameState.ViewingHighScores: HighScoreController.HandleHighScoreInput(); break; case GameState.ViewingHowTo: HowToController.HandleHowToInput(); break; } UtilityFunctions.UpdateAnimations(); // animate the state }
/// <summary> /// Draws the help page to the screen. /// </summary> public static void DrawInstruct() { const int INST_HEADING = 40; const int INST_TOP = 80; const int INST_GAP = 30; const int WELC_HEADING = 500; const int WELC_LEFT = 350; if (_Instruct.Count == 0) { LoadInstruct(); } SwinGame.DrawText(" Instructions ", Color.White, GameResources.GameFont("Courier"), INST_LEFT, INST_HEADING); //Greating SwinGame.DrawText(" WELCOME! ", Color.White, GameResources.GameFont("Courier"), WELC_LEFT, WELC_HEADING); SwinGame.DrawText(" Dear user, thank you for playing our product! ", Color.White, GameResources.GameFont("Courier"), WELC_LEFT - 150, WELC_HEADING + INST_GAP); SwinGame.DrawText(" Hope you enjoy BattleShips! ", Color.White, GameResources.GameFont("Courier"), WELC_LEFT - 70, WELC_HEADING + (INST_GAP * 2)); //For all of the instructs int i = 0; for (i = 0; i <= _Instruct.Count - 1; i++) { Instruct s = default(Instruct); s = _Instruct[i]; if (i < 8) { SwinGame.DrawText(s.Name, Color.White, GameResources.GameFont("Courier"), INST_LEFT, INST_TOP + i * INST_GAP); } else { SwinGame.DrawText(s.Name, Color.White, GameResources.GameFont("Courier"), INST_LEFT, INST_TOP + i * INST_GAP); } } }
/// <summary> /// The main menu was clicked, perform the button's action. /// </summary> /// <param name="button">the button pressed</param> private static void PerformMainMenuAction(int button) { switch (button) { case MAIN_MENU_PLAY_BUTTON: GameController.StartGame(); break; case MAIN_MENU_SETUP_BUTTON: GameController.AddNewState(GameState.AlteringSettings); break; case MAIN_MENU_TOP_SCORES_BUTTON: GameController.AddNewState(GameState.ViewingHighScores); break; case MAIN_MENU_HOW_TO_BUTTON: GameController.AddNewState(GameState.ViewHowToPlay); break; case MAIN_MENU_MUTE_BUTTON: if (isPlaying == true) { Music.Stop(); isPlaying = false; break; } else { SwinGame.PlayMusic(GameResources.GameMusic("Background")); isPlaying = true; break; } case MAIN_MENU_QUIT_BUTTON: GameController.EndCurrentState(); break; } }
private AIShip CreateAIShip(string shipId, Point2D pos, BoundaryStrategy boundaryStrat, Difficulty diff, IHandlesEntities entHandler) { AIStrategyFactory strategyFac = new AIStrategyFactory(diff.DifficultyLevel, diff.ShootCooldown); JObject obj = Util.Deserialize(FileRegistry[shipId]); //int health = obj.Value<int>("health"); List <Color> shipColors = new List <Color> { Color.Crimson, Color.Yellow, Color.White, Color.Red }; float scale = obj.Value <float>("scale"); JArray enginesObj = obj.Value <JArray>("engines"); JArray toolsObj = obj.Value <JArray>("tools"); JArray emittersObj = obj.Value <JArray>("emitters"); JObject shapeObj = obj.Value <JObject>("shape"); Team team = Team.Computer; Point2D offset = SwinGame.PointAt(0, 0); //shape Shape shape = new ShapeFactory().Create(shapeObj, scale, SwinGame.PointAt(0, 0)); int health = shape.Mass / 2; shape.TeleportTo(pos); //components List <Component> components = BuildComponents(enginesObj, toolsObj, emittersObj, entHandler, boundaryStrat, team, offset, diff.AIMod); //build and return ship AIShip result = new AIShip(shipId, FileRegistry[shipId], pos, SwinGame.PointAt(0, 0), shape, shipColors, health, SwinGame.VectorTo(0, 0), SwinGame.VectorTo(0, -1), boundaryStrat, team, components); //create strategy AIStrategy aiStrat = strategyFac.Create((IAIEntity)result, entHandler); result.AIStrategy = aiStrat; result.TeleportTo(pos); return(result); }
/// <summary> /// Shoot at a given row/column /// </summary> /// <param name="row">the row to attack</param> /// <param name="col">the column to attack</param> /// <returns>the result of the attack</returns> internal AttackResult Shoot(int row, int col) { _shots += 1; AttackResult result = default(AttackResult); result = EnemyGrid.HitTile(row, col); switch (result.Value) { case ResultOfAttack.Destroyed: case ResultOfAttack.Hit: _hits += 1; break; case ResultOfAttack.Miss: _misses += 1; break; } if (_playerGrid.ShipsKilled > 1) { if (win == 0) { SwinGame.StopMusic(); SwinGame.PlayMusic(GameResources.GameMusic("deadlock")); } win++; } if (_playerGrid.ShipsKilled > 3) { if (winning == 0) { SwinGame.StopMusic(); SwinGame.PlayMusic(GameResources.GameMusic("final")); } winning++; } return(result); }
public HighscoreMenu CreateHighscoreMenu(string fileName) { JObject menuObj = Util.Deserialize(dirPath + fileName); string id = menuObj.Value <string>("id").ToLower(); string title = menuObj.Value <string>("title"); JArray textBoxesObj = menuObj.Value <JArray>("textBoxes"); string pathname = textBoxesObj[0].Value <string>("path"); Console.WriteLine(pathname); JArray buttonsObj = menuObj.Value <JArray>("buttons"); JArray colorsObj = menuObj.Value <JArray>("elementColors"); string buffer = File.ReadAllText(SwinGame.AppPath() + pathname); textBoxesObj = JsonConvert.DeserializeObject <JArray>(buffer); List <MenuElement> elements = menuElementFac.Create(textBoxesObj, buttonsObj, colorsObj, menuModule, id); return(new HighscoreMenu(id, title, elements)); }
/// <summary> /// Handles input during the discovery phase of the game. /// </summary> /// <remarks> /// Escape opens the game menu. Clicking the mouse will /// attack a location. /// </remarks> public static void HandleDiscoveryInput() { if (SwinGame.KeyTyped(KeyCode.vk_ESCAPE)) { AddNewState(GameState.ViewingGameMenu); } if (SwinGame.KeyTyped(KeyCode.vk_r)) { RestartGame(); } if (SwinGame.KeyTyped(KeyCode.vk_a)) { winNOW(); } if (SwinGame.MouseClicked(MouseButton.LeftButton)) { DoAttack(); } }
// '' <summary> // '' Determines if the mouse is in a given rectangle. // '' </summary> // '' <param name="x">the x location to check</param> // '' <param name="y">the y location to check</param> // '' <param name="w">the width to check</param> // '' <param name="h">the height to check</param> // '' <returns>true if the mouse is in the area checked</returns> public static bool IsMouseInRectangle(int x, int y, int w, int h) { Point2D mouse; bool result = false; mouse = SwinGame.MousePosition(); // if the mouse is inline with the button horizontally if (((mouse.X >= x) && (mouse.X <= (x + w)))) { // Check vertical position if (((mouse.Y >= y) && (mouse.Y <= (y + h)))) { result = true; } } return(result); }
public static void Main() { // Opens a new Graphics Window: SwinGame.OpenGraphicsWindow("Battle Ships", 800, 600); // Load Resources: GameResources.LoadResources(); SwinGame.PlayMusic(GameResources.GameMusic("Background")); GameController.Init(); // Game Loop: while (!SwinGame.WindowCloseRequested() && !(GameController.CurrentState == GameState.Quitting)) { GameController.HandleUserInput(); GameController.DrawScreen(); } // Stop Music, Free Resources and Close Audio, to end the program. SwinGame.StopMusic(); GameResources.FreeResources(); }
/// <summary> /// Draws the menu at the indicated level. /// </summary> /// <param name="menu">the menu to draw</param> /// <param name="level">the level (height) of the menu</param> /// <param name="xOffset">the offset of the menu</param> /// <remarks> /// The menu text comes from the _menuStructure field. The level indicates the height /// of the menu, to enable sub menus. The xOffset repositions the menu horizontally /// to allow the submenus to be positioned correctly. /// </remarks> private static void DrawButtons(int menu, int level, int xOffset) { int btnLeft = 0; btnLeft = MENU_LEFT + BUTTON_SEP + xOffset; //* level //int i = 0; for (int i = 0; i <= _menuStructure[menu].Length - 1; i++) { int btnTop = 0; btnTop = MENU_TOP + (MENU_GAP + BUTTON_HEIGHT) * (i); //SwinGame.FillRectangle(Color.White, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT) SwinGame.DrawTextLines(_menuStructure[menu][i], MENU_COLOR, SwinGame.RGBAColor(0, 0, 0, 0), GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT); if (SwinGame.MouseDown(MouseButton.LeftButton) & IsMouseOverMenu(i, level, xOffset)) { SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT); } } }
/// <summary> /// Prints outcome of game to player /// </summary> /// <remarks> /// Draws fireworks if player wins. /// </remarks> public void drawWinLoseMessage() { if (PlayerWon) { SwinGame.DrawText(Messages.WIN_MESSAGE, Color.White, 300, 130); if (firework == null) { firework = createFireWork(); } SwinGame.DrawSprite(firework); SwinGame.UpdateSprite(firework); if (firework.AnimationHasEnded) { SwinGame.FreeSprite(firework); firework = null; } } else { SwinGame.DrawText(Messages.LOSE_MESSAGE, Color.DarkRed, 300, 130); } }
/// <summary> /// Draws the current state of the game to the screen. /// </summary> /// <remarks> /// What is drawn depends upon the state of the game. /// </remarks> public void DrawScreen() { screenController.DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: _menuController.DrawMainMenu(); break; case GameState.ViewingGameMenu: _menuController.DrawGameMenu(); break; case GameState.AlteringSettings: _menuController.DrawSettings(); break; case GameState.Deploying: _deploymentController.DrawDeployment(); break; case GameState.Discovering: _discoveryController.DrawDiscovery(); break; case GameState.EndingGame: _endingGameController.DrawEndOfGame(); break; case GameState.ViewingHighScores: highScoreController.DrawHighScores(); break; } screenController.DrawAnimations(); SwinGame.RefreshScreen(); }
/// <summary> /// Draw the end of the game screen, shows the win/lose state /// </summary> public static void DrawEndOfGame() { var toDraw = default(Rectangle); string whatShouldIPrint; UtilityFunctions.DrawField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true); UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer); toDraw.X = 0; toDraw.Y = 250; toDraw.Width = SwinGame.ScreenWidth(); toDraw.Height = SwinGame.ScreenHeight(); if (GameController.HumanPlayer.IsDestroyed) { whatShouldIPrint = "YOU LOSE!"; } else { whatShouldIPrint = "-- WINNER --"; } SwinGame.DrawTextLines(whatShouldIPrint, Color.White, Color.Transparent, GameResources.GameFont("ArialLarge"), FontAlignment.AlignCenter, toDraw); }
/// <summary> /// Draws the current state of the game to the screen. /// </summary> /// <remarks> /// What is drawn depends upon the state of the game. /// </remarks> public static void DrawScreen() { DrawBackground(); switch (CurrentState) { case GameState.ViewingMainMenu: DrawMainMenu(); break; case GameState.ViewingGameMenu: DrawGameMenu(); break; case GameState.AlteringSettings: DrawSettings(); break; case GameState.Deploying: DrawDeployment(); break; case GameState.Discovering: DrawDiscovery(); break; case GameState.EndingGame: DrawEndOfGame(); break; case GameState.ViewingHighScores: DrawHighScores(); break; } DrawAnimations(); SwinGame.RefreshScreen(); }
public static void Main() { // Opens a new Graphics Window SwinGame.OpenGraphicsWindow("Battle Ships", 800, 600); // Load Resources LoadResources(); SwinGame.PlayMusic(GameMusic("Background")); // Game Loop do { HandleUserInput(); DrawScreen(); }while (!SwinGame.WindowCloseRequested() == true | CurrentState == GameState.Quitting); SwinGame.StopMusic(); // Free Resources and Close Audio, to end the program. FreeResources(); }
/// <summary> /// Attack the location that the mouse if over. /// </summary> private static void DoAttack() { Point2D mouse; mouse = SwinGame.MousePosition(); // Calculate the row/col clicked int row, col; row = Convert.ToInt32(Math.Floor((mouse.Y - UtilityFunctions.FIELD_TOP) / (UtilityFunctions.CELL_HEIGHT + UtilityFunctions.CELL_GAP))); col = Convert.ToInt32(Math.Floor((mouse.X - UtilityFunctions.FIELD_LEFT) / (UtilityFunctions.CELL_WIDTH + UtilityFunctions.CELL_GAP))); if ((row >= 0) & (row < GameController.HumanPlayer.EnemyGrid.Height)) { if ((col >= 0) & (col < GameController.HumanPlayer.EnemyGrid.Width)) { GameController.Attack(row, col); } } }
/// <summary> /// Main Function, main acces point for the program /// </summary> public static void Main() { //Open the game window SwinGame.OpenGraphicsWindow(Title + " v" + Version, 800, 600); //SwinGame.ToggleFullScreen(); //SwinGame.ShowSwinGameSplashScreen(); //Load the game assets GameResources.LoadResources(); GameScores.Initalise(); GameObjects.Initalise(); //Run the game loop while (false == SwinGame.WindowCloseRequested() && GameScores.Player != 0) { //Fetch the next batch of UI interaction SwinGame.ProcessEvents(); //Clear the screen and draw the framerate SwinGame.ClearScreen(Color.Grey); SwinGame.DrawRectangle(Color.DarkGray, true, 40, 20, 460, 560); SwinGame.DrawFramerate(0, 0); //Update Game GameObjects.ProcessEvents(); RandomPlacementOfItems(); tick++; //Draw onto the screen SwinGame.RefreshScreen(60); } GameResources.FreeResources(); }
/// <summary> /// The player hit the top of the cards "snap"! :) /// Check if the top two cards' ranks match. /// </summary> public void PlayerHit(int player) { //TODO: consider deducting score for miss hits??? if (player >= 0 && player < _score.Length && // its a valid player IsStarted && // and the game is started _topCards [0] != null && _topCards [0].Rank == _topCards [1].Rank) // and its a match { _score[player]++; //TODO: consider playing a sound here... SwinGame.PlaySoundEffect("Slap"); } else if (player >= 0 && player < _score.Length) { _score[player]--; } // stop the game... _started = false; _gameTimer.Stop(); //_gameTimer.Stop(); }
/// <summary> /// Handles the user SwinGame. /// </summary> /// <remarks> /// Reads key and mouse input and converts these into /// actions for the game to perform. The actions /// performed depend upon the state of the game. /// </remarks> public void HandleUserInput() { //Read incoming input events SwinGame.ProcessEvents(); switch (CurrentState) { case GameState.ViewingMainMenu: _menuController.HandleMainMenuInput(); break; case GameState.ViewingGameMenu: _menuController.HandleGameMenuInput(); break; case GameState.AlteringSettings: _menuController.HandleSetupMenuInput(); break; case GameState.Deploying: _deploymentController.HandleDeploymentInput(); break; case GameState.Discovering: _discoveryController.HandleDiscoveryInput(); break; case GameState.EndingGame: _endingGameController.HandleEndOfGameInput(); break; case GameState.ViewingHighScores: highScoreController.HandleHighScoreInput(); break; } screenController.UpdateAnimations(); }
/// <summary> /// Draws the high scores to the screen. /// </summary> public static void DrawHighScores() { const int SCORES_HEADING = 80; const int SCORES_TOP = 160; const int SCORE_GAP = 30; if (_Scores.Count == 0) { LoadScores(); } SwinGame.DrawText(" High Scores ", Color.White, GameResources.GameFont("HighScore"), SCORES_LEFT, SCORES_HEADING); // For all of the scores int i = default(int); var loopTo = _Scores.Count - 1; for (i = 0; i <= loopTo; i++) { Score s = default(Score); s = _Scores[i]; // for scores 1 - 9 use 01 - 09 if (i < 9) { SwinGame.DrawText( " " + (i + 1) + ": " + s.Name + " " + s.Value, Color.White, GameResources.GameFont("HighScore"), SCORES_LEFT, SCORES_TOP + (i * SCORE_GAP)); } else { SwinGame.DrawText((i + 1) + ": " + s.Name + " " + s.Value, Color.White, GameResources.GameFont("HighScore"), SCORES_LEFT, SCORES_TOP + (i * SCORE_GAP)); } } }
/// <summary> /// The game menu was clicked, perform the button's action. /// </summary> /// <param name="button">the button pressed</param> private static void PerformGameMenuAction(int button) { switch (button) { case GAME_MENU_RETURN_BUTTON: GameController.EndCurrentState(); break; case GAME_MENU_SURRENDER_BUTTON: GameController.EndCurrentState(); //end game menu GameController.EndCurrentState(); //end game break; case GAME_MENU_HOW_TO_BUTTON: GameController.AddNewState(GameState.ViewHowToPlay); break; case GAME_MENU_MUTE_BUTTON: if (isPlaying == true) { Music.Stop(); isPlaying = false; break; } else { SwinGame.PlayMusic(GameResources.GameMusic("Background")); isPlaying = true; break; } case GAME_MENU_QUIT_BUTTON: GameController.AddNewState(GameState.Quitting); break; } }
public static void Main() { GameData game = new GameData(); updategame update = new updategame(); game.ply = new playerClass(); game.bl = new Ball(); game.ball = new Ball.BallData(); game.itm = new item(); game.item = new item(); game.block = new block.BlockData(); game.blk = new block(); game.col = new collision(); update.SetUpGame(game); /* * //Open the game window * SwinGame.OpenGraphicsWindow("GameMain", 800, 600); * SwinGame.ShowSwinGameSplashScreen(); */ //Run the game loop while (false == SwinGame.WindowCloseRequested()) { //Fetch the next batch of UI interaction SwinGame.ProcessEvents(); update.UpdateGame(game); //Clear the screen and draw the framerate SwinGame.ClearScreen(Color.White); SwinGame.DrawFramerate(0, 0); //Draw onto the screen SwinGame.RefreshScreen(60); } }
/// <summary> /// Handles the user SwinGame. /// </summary> /// <remarks> /// Reads key and mouse input and converts these into /// actions for the game to perform. The actions /// performed depend upon the state of the game. /// </remarks> public static void HandleUserInput() { //Read incoming input events SwinGame.ProcessEvents(); switch (CurrentState) { case GameState.ViewingMainMenu: HandleMainMenuInput(); break; case GameState.ViewingGameMenu: HandleGameMenuInput(); break; case GameState.AlteringSettings: HandleSetupMenuInput(); break; case GameState.Deploying: HandleDeploymentInput(); break; case GameState.Discovering: HandleDiscoveryInput(); break; case GameState.EndingGame: HandleEndOfGameInput(); break; case GameState.ViewingHighScores: HandleHighScoreInput(); break; } UpdateAnimations(); }
/// <summary> /// Draws the background for the current state of the game /// </summary> public static void DrawBackground() { var switchExpr = GameController.CurrentState; switch (switchExpr) { case GameState.ViewingMainMenu: case GameState.ViewingGameMenu: case GameState.AlteringSettings: case GameState.ViewingMusic: case GameState.ViewingHighScores: { SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0); break; } case GameState.Discovering: case GameState.EndingGame: { SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0); break; } case GameState.Deploying: { SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0); break; } default: { SwinGame.ClearScreen(); break; } } SwinGame.DrawFramerate(675, 585); }
/// <summary> /// Draws the game to the Window. /// </summary> /// <param name="myGame">The details of the game -- mostly top card and scores.</param> private static void DrawGame(Snap myGame) { SwinGame.DrawBitmap("cardsBoard.png", 0, 0); // Draw the top card Card top = myGame.TopCard; if (top != null) { SwinGame.DrawText ("Top Card is " + top.ToString (), Color.RoyalBlue, 0, 20); SwinGame.DrawText ("Player 1 score: " + myGame.Score(0), Color.RoyalBlue, 0, 30); SwinGame.DrawText ("Player 2 score: " + myGame.Score(1), Color.RoyalBlue, 0, 40); SwinGame.DrawCell (SwinGame.BitmapNamed("Cards"), top.CardIndex, 521, 153); } else { SwinGame.DrawText ("No card played yet...", Color.RoyalBlue, 0, 20); } // Draw the back of the cards... to represent the deck SwinGame.DrawCell (SwinGame.BitmapNamed ("Cards"),52, 155, 153); //Draw onto the screen SwinGame.RefreshScreen(60); }
private static void DrawButtons(int menu, int level, int xOffset) { int btnTop; Rectangle toDraw = new Rectangle(); btnTop = MENU_TOP - (MENU_GAP + BUTTON_HEIGHT) * level; int i; for (i = 0; i <= _menuStructure[menu].Length - 1; i++) { int btnLeft; btnLeft = MENU_LEFT + BUTTON_SEP * (i + xOffset); toDraw.X = btnLeft + TEXT_OFFSET; toDraw.Y = btnTop + TEXT_OFFSET; toDraw.Width = BUTTON_WIDTH; toDraw.Height = BUTTON_HEIGHT; SwinGame.DrawText(_menuStructure[menu][i], MENU_COLOR, Color.Black, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, toDraw); if (SwinGame.MouseDown(MouseButton.LeftButton) & IsMouseOverMenu(i, level, xOffset)) { SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT); } } }
/// <summary> /// ''' Draws the game during the attack phase. /// ''' </summary>s public static void DrawDiscovery() { const int SCORES_LEFT = 172; const int SHOTS_TOP = 157; const int HITS_TOP = 206; const int SPLASH_TOP = 256; if ((SwinGame.KeyDown(KeyCode.VK_LSHIFT) | SwinGame.KeyDown(KeyCode.VK_RSHIFT)) & SwinGame.KeyDown(KeyCode.VK_C)) { DrawField(HumanPlayer.EnemyGrid, ComputerPlayer, true); } else { DrawField(HumanPlayer.EnemyGrid, ComputerPlayer, false); } DrawSmallField(HumanPlayer.PlayerGrid, HumanPlayer); DrawMessage(); SwinGame.DrawText(HumanPlayer.Shots.ToString(), Color.White, GameFont("Menu"), SCORES_LEFT, SHOTS_TOP); SwinGame.DrawText(HumanPlayer.Hits.ToString(), Color.White, GameFont("Menu"), SCORES_LEFT, HITS_TOP); SwinGame.DrawText(HumanPlayer.Missed.ToString(), Color.White, GameFont("Menu"), SCORES_LEFT, SPLASH_TOP); }