/// <summary> /// Draws the background for the current state of the game /// </summary> /// <remarks> /// Isuru: Updated Draw frame rate function; /// </remarks> public static void DrawBackground() { int fpsX = 725; int fpsY = 585; switch (GameController.CurrentState) { case GameState.ViewingMainMenu: case GameState.ViewingGameMenu: case GameState.AlteringSettings: 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; } //Terrence: //Have changed the way the framerate is drawn to make it much less confusing //as the swingame method gives you too much irrelevant information. SwinGame.DrawText("FPS:" + SwinGame.GetFramerate().ToString(), Color.Green, fpsX, fpsY); }
public static void Main() { //Open the game window SwinGame.OpenGraphicsWindow("GameMain", 1600, 900); SwinGame.ShowSwinGameSplashScreen(); Lander l = new Lander((SwinGame.ScreenWidth() / 2) - (30 / 2), 10); // 30 is lander bitmap width hardcoded //Run the game loop while (false == SwinGame.WindowCloseRequested()) { //Fetch the next batch of UI interaction SwinGame.ProcessEvents(); //Clear the screen and draw the framerate SwinGame.ClearScreen(Color.White); SwinGame.DrawFramerate(0, 0); l.CalculatePosition(); // Move the lander l.DrawLander(); // Draw the lander //Draw onto the screen SwinGame.RefreshScreen(60); } SwinGame.ReleaseAllResources(); SwinGame.ReleaseAllSprites(); }
/// <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.ClearScreen(Color.White); // Draw the top card Card top = myGame.TopCard; if (top != null) { SwinGame.DrawText("Top Card is " + top.ToString(), Color.RoyalBlue, "GameFont", 0, 20); SwinGame.DrawText("Player 1 score: " + myGame.Score(0), Color.RoyalBlue, "GameFont", 0, 30); SwinGame.DrawText("Player 2 score: " + myGame.Score(1), Color.RoyalBlue, "GameFont", 0, 40); SwinGame.DrawCell(SwinGame.BitmapNamed("Cards"), top.CardIndex, 350, 50); } 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, 160, 50); //Draw onto the screen SwinGame.RefreshScreen(60); }
/// <summary> /// Draws the background for the current state of the game /// </summary> public static void DrawBackground() { switch (GameController.CurrentState) { case GameState.ViewingMainMenu: case GameState.ViewingGameMenu: case GameState.AlteringSettings: 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, GameResources.GameFont("CourierSmall")); }
/// <summary> /// ''' Draws the background for the current state of the game /// ''' </summary> public static void DrawBackground() { switch (CurrentState) { case object _ when GameState.ViewingMainMenu: case object _ when GameState.ViewingGameMenu: case object _ when GameState.AlteringSettings: case object _ when GameState.ViewingHighScores: { SwinGame.DrawBitmap(GameImage("Menu"), 0, 0); break; } case object _ when GameState.Discovering: case object _ when GameState.EndingGame: { SwinGame.DrawBitmap(GameImage("Discovery"), 0, 0); break; } case object _ when GameState.Deploying: { SwinGame.DrawBitmap(GameImage("Deploy"), 0, 0); break; } default: { SwinGame.ClearScreen(); break; } } SwinGame.DrawFramerate(675, 585, GameFont("CourierSmall")); }
public void GameOver() { if (gameover == 1) { SwinGame.ClearScreen(Color.White); SwinGame.DrawText("You lost, unlucky m8 game over! press space to restart", Color.Black, 200, 300); } }
public void Draw() { SwinGame.ClearScreen(Mybackground); foreach (Shape s in _shapes) { s.Drawshape(); } }
public void Draw() { SwinGame.ClearScreen(_background); foreach (Shape shape in _shapes) { shape.Draw(); } }
public void Draw() { SwinGame.ClearScreen(Color.White); foreach (Shape s in _shapes) { s.Draw(); } }
public virtual void Draw() { SwinGame.ClearScreen(_background); for (int i = 0; i < _shapes.Count; i++) { _shapes[i].Draw(); } }
/// <summary> /// Draws game screen. /// </summary> public override void Draw() { SwinGame.ClearScreen(Colour.Black); foreach (string btn in _buttonNames) { _buttons[btn].Draw(); } }
/// <summary> /// Draw this instance. /// </summary> public void Draw() { SwinGame.ClearScreen(BackgroundColor); foreach (Shape s in _shapes) { s.Draw(); } }
public static object[] GetTheNumbers(string SectionName, string[] Names, object[] NTList) { int count; if (Names.Length < NTList.Length) { count = Names.Length; } else { count = NTList.Length; } //object [] Values = new object [count]; //for (int i = 0; i < count; i++) { // if(NTList[i] is float){ // Values [i] = NTList[i]; // }else if (NTList [i] is int) { // Values [i] = NTList [i]; // } //} bool Nexted = false; int screenWidthHalf = SwinGame.WindowWidth(GameMain.WindowName) / 2; Button Next = new Button(Color.White, screenWidthHalf - 100f, count * 32f + 128f, 200f, 64f, "Next", Color.White); while (!Nexted) { SwinGame.ProcessEvents(); for (int i = 0; i < count; i++) { NumberReturn NR = new NumberReturn(); if (NTList [i] is float) { NTList [i] = NR.GetValue((float)NTList [i], screenWidthHalf, 128f + (float)i * 32f, Names [i]); } else if (NTList[i] is int) { NTList [i] = NR.GetValue((int)NTList [i], screenWidthHalf, 128f + (float)i * 32f, Names [i]); } } SwinGame.DrawText(SectionName, Color.White, screenWidthHalf - 64f, 32f); Next.Draw(); if (SwinGame.WindowCloseRequested()) { Nexted = true; break; } if (SwinGame.MouseClicked(MouseButton.LeftButton)) { Nexted = Next.clicked(); } SwinGame.RefreshScreen(GameMain.ScreenRefreshRate); SwinGame.ClearScreen(Color.Black); } return(NTList); }
/// <summary> /// Draws the background for the current state of the game /// </summary> public static void DrawBackground() { switch (GameController.CurrentState) { case GameState.ViewingMainMenu: case GameState.ViewingGameMenu: case GameState.AlteringSetting: case GameState.BGMSettings: case GameState.AlteringSetup: 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; case GameState.HowToPlay: SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0); GameResources.GameFont("New").FontStyle = FontStyle.BoldFont | FontStyle.UnderlineFont; SwinGame.DrawText("How To Play : BATTLESHIP", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 10 + HOWTOPLAYOFFSET_TOP); GameResources.GameFont("New").FontStyle = FontStyle.BoldFont; SwinGame.DrawText("*DIFFICULTY", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 50 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("Choose between Easy, Medium and Hard", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 70 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("*HIGH SCORES", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 100 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("Click on the scores button to view the Player's high score", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 120 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("*OBJECTIVE", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 150 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("Destroy the opponent's ships", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 170 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("*SCORING", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 200 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("Each time the player hits the opponent's ship, 1 point will be given", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 220 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("*Special Moves", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 250 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("Rotate or Shuffle the ship's position", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 280 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("*MUTE", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 310 + HOWTOPLAYOFFSET_TOP); SwinGame.DrawText("Click on the mute button to turn off the sound and music", MENU_COLOR, GameResources.GameFont("New"), HOWTOPLAYOFFSET_LEFT, 340 + HOWTOPLAYOFFSET_TOP); if (SwinGame.KeyTyped(KeyCode.vk_ESCAPE)) { GameController.EndCurrentState(); } break; } SwinGame.DrawFramerate(675, 585, GameResources.GameFont("CourierSmall")); }
public static void Main() { InitializeGame(); //Open the game window SwinGame.OpenGraphicsWindow("GameMain", 900, 600); //SwinGame.ShowSwinGameSplashScreen (); //Run the game loop while (false == SwinGame.WindowCloseRequested()) { //Fetch the next batch of UI interaction SwinGame.ProcessEvents(); //Clear the screen and draw the framerate SwinGame.ClearScreen(Color.DarkGray); SwinGame.DrawFramerate(0, 0); gameBoard.Draw(); DrawSideBar(); if (turn == 1) { gameBoard.AIMove(); } if (SwinGame.MouseClicked(MouseButton.LeftButton)) { gameBoard.SelectCell(SwinGame.MousePosition()); } if ((SwinGame.MouseX() >= 604 && SwinGame.MouseX() <= 705) && (SwinGame.MouseY() >= 150 && SwinGame.MouseY() <= 250)) { SwinGame.DrawText("Revive", Color.Black, SwinGame.MouseX(), SwinGame.MouseY() + 20); if (SwinGame.MouseClicked(MouseButton.LeftButton)) { gameBoard.CastMagic(MagicType.Revive); } } else if ((SwinGame.MouseX() >= 794 && SwinGame.MouseX() <= 865) && (SwinGame.MouseY() >= 165 && SwinGame.MouseY() <= 235)) { SwinGame.DrawText("Invulnerability", Color.Black, SwinGame.MouseX() - 40, SwinGame.MouseY() + 20); if (SwinGame.MouseClicked(MouseButton.LeftButton)) { gameBoard.CastMagic(MagicType.Invulnerability); } } if (SwinGame.MouseClicked(MouseButton.RightButton)) { SwinGame.DrawText(SwinGame.MouseX().ToString() + "," + SwinGame.MouseY().ToString(), Color.Black, SwinGame.MouseX() + 10, SwinGame.MouseY()); //SwinGame.Delay (50); } //Draw onto the screen SwinGame.RefreshScreen(60); } }
public void Update() { SwinGame.ClearScreen(bkgdColor); foreach (Star s in stars) { s.Update(); } }
public static void DrawGameOver() { SwinGame.ClearScreen(BG_CLR); SwinGame.DrawText("GAME OVER", FONT_CLR, T_FONT, _winX / 10, _winY / 5); SwinGame.DrawText(string.Format("Your score: {0}", _grid.Score_String), FONT_CLR, N_FONT, _winX / 2 - F_SZ_N * 3, _winY / 2); SwinGame.DrawText("Click anywhere to return to the main menu", FONT_CLR, N_FONT, _winX / 2 - F_SZ_S * 11, _winY - 100); }
/// <summary> /// Ends the loading screen. /// </summary> /// <param name="width">Width.</param> /// <param name="height">Height.</param> private static void EndLoadingScreen(int width, int height) { SwinGame.ProcessEvents(); SwinGame.Delay(500); SwinGame.ClearScreen(); SwinGame.RefreshScreen(); FreeCurrentResource(); SwinGame.ChangeScreenSize(width, height); }
public static void DrawInstructionImg() { SwinGame.ClearScreen(); SwinGame.DrawBitmap("Instruction.png", 0, 0); SwinGame.DrawBitmap("Instruction2.png", 400, 300); SwinGame.DrawText("Here are the details you need to understand", Color.Azure, GameResources.GameFont("Instruction"), 415, 150); SwinGame.DrawText("You are now ready to play.", Color.Azure, GameResources.GameFont("Instruction"), 15, 400); SwinGame.DrawText("Press M to go to Menu and start playing.", Color.Azure, GameResources.GameFont("Instruction"), 15, 430); SwinGame.DrawText("We wish you the best of luck!", Color.Azure, GameResources.GameFont("Instruction"), 15, 460); }
/// <summary> /// Draws the screen. /// </summary> public override void Draw() { //TODO: Add graphical menu. SwinGame.ClearScreen(Colour.Black); foreach (string btn in _buttonNames) { _buttons[btn].Draw(); } }
public void Render() { SwinGame.ClearScreen(Color.Black); foreach (GameObject obj in _gameObjects) { obj.Render(); } _ui.Render(); SwinGame.RefreshScreen(); }
// Draw solution Path to the GUI public void DrawSolution(int mapLengthX, int mapLengthY, List <Grid> solutionPaths) { SwinGame.ClearScreen(Color.White); SwinGame.ProcessEvents(); for (int i = 0; i < mapLengthX * 100; i += 100) { SwinGame.ProcessEvents(); for (int j = 0; j < mapLengthY * 100; j += 100) { SwinGame.ProcessEvents(); DrawGrid(Color.White, i, j); foreach (Grid g in solutionPaths) { DrawGrid(Color.Pink, g.X * 100, g.Y * 100); } } } for (int i = 0; i < mapLengthX * 100; i += 100) { SwinGame.ProcessEvents(); for (int j = 0; j < mapLengthY * 100; j += 100) { SwinGame.ProcessEvents(); foreach (Grid g in _map.GridList) { SwinGame.ProcessEvents(); if (g.GridName == "ROBOT") { DrawGrid(Color.Red, g.X * 100, g.Y * 100); } if (g.GridName == "WALL") { DrawGrid(Color.Grey, g.X * 100, g.Y * 100); } if (g.GridName == "GOAL") { DrawGrid(Color.Green, g.X * 100, g.Y * 100); } } } } for (int i = 0; i < mapLengthX * 100; i += 100) { SwinGame.ProcessEvents(); for (int j = 0; j < mapLengthY * 100; j += 100) { SwinGame.ProcessEvents(); foreach (Grid g in solutionPaths) { DrawAction(g.MoveDirection, g.X * 100, g.Y * 100); } } } SwinGame.RefreshScreen(60); }
/*=================*/ /* Private Methods */ /*=================*/ private static void Loop() { Scene activeScene = _scenes.Peek(); // get active scene SwinGame.ProcessEvents(); // process SwinGame events activeScene.Update(); // update active scene SwinGame.ClearScreen(Color.Black); // clear the screen activeScene.Render(); // draw the active scene SwinGame.DrawFramerate(0, 0); // draw the framerate SwinGame.RefreshScreen(60); // refresh the screen }
public static void Main() { Drawing myDrawing = new Drawing(); //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(); //Clear the screen and draw the framerate SwinGame.ClearScreen(Color.White); SwinGame.DrawFramerate(0, 0); myDrawing.Draw(); //Draw onto the screen SwinGame.RefreshScreen(60); if (SwinGame.MouseClicked(MouseButton.LeftButton)) { SwinGame.FillCircle(Color.AliceBlue, 50, 50, 50); Shape myShape = new Shape(); myShape.X = SwinGame.MouseX(); myShape.Y = SwinGame.MouseY(); myDrawing.AddShape(myShape); } if (SwinGame.KeyTyped(KeyCode.vk_SPACE)) { SwinGame.GUISetBackgroundColor(SwinGame.RandomRGBColor(255)); } if (SwinGame.MouseClicked(MouseButton.RightButton)) { myDrawing.SelectShapesAt(SwinGame.MousePosition()); } if (SwinGame.KeyDown(KeyCode.vk_DELETE)) { foreach (Shape s in myDrawing.SelectedShapes) { myDrawing.RemoveShape(s); } } } }
public void DisplayGame(GameData game) { SwinGame.ClearScreen(SwinGame.ColorWhite()); SwinGame.DrawBitmap("background", 0, 0); game.ply.drawPlayer(); game.bl.drawBall(game.ball); game.blk.DrawBlocks(game); game.itm.drawItem(game); SwinGame.DrawText("Score: " + game.ply.player.score.ToString() + " Lives: " + game.ply.player.lives.ToString(), SwinGame.ColorBlack(), 0, 0); SwinGame.RefreshScreen(60); }
//Draws the background for the current state of the game public static void DrawBackground() { switch (GameController.CurrentState) { case GameState.ViewingMainMenu: case GameState.ViewingGameMenu: case GameState.AlteringSettings: case GameState.AlteringMenuColor: 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; case GameState.Instructions: SwinGame.DrawBitmap(GameResources.GameImage("InstructionsPage"), 0, 0); SwinGame.DrawText("--Instructions for Battleship--", Color.Blue, GameResources.GameFont("Courier"), 250, 10); SwinGame.DrawText("--BASIC STUFF--", Color.Yellow, GameResources.GameFont("Courier"), 100, 40); SwinGame.DrawText("--DIFFICULTY--", Color.Yellow, GameResources.GameFont("Courier"), 100, 60); SwinGame.DrawText("Choose between 3 Difficulties; Easy, Medium and Hard", Color.White, GameResources.GameFont("Courier"), 100, 80); SwinGame.DrawText("--HIGH SCORES--", Color.Yellow, GameResources.GameFont("Courier"), 100, 100); SwinGame.DrawText("Click on the scores button to view the Player's high score", Color.White, GameResources.GameFont("Courier"), 100, 120); SwinGame.DrawText("--AIM OF THE GAME--", Color.Yellow, GameResources.GameFont("Courier"), 100, 140); SwinGame.DrawText("Destroy all the opponent's ships in order to win", Color.White, GameResources.GameFont("Courier"), 100, 160); SwinGame.DrawText("--SCORING--", Color.Yellow, GameResources.GameFont("Courier"), 100, 190); SwinGame.DrawText("Each time the player hits the opponent's ship, 1 point will be given", Color.White, GameResources.GameFont("Courier"), 100, 210); SwinGame.DrawText("--GAME INSTRUCTIONS--", Color.Yellow, GameResources.GameFont("Courier"), 100, 300); SwinGame.DrawText("1. During Ship deployment stage, you can either place the ship on the grid", Color.White, GameResources.GameFont("Courier"), 100, 320); SwinGame.DrawText("horizontally or vertically. Or you can select the random shuffle which deploys", Color.White, GameResources.GameFont("Courier"), 100, 340); SwinGame.DrawText("all the ship on the grid for you. Note: All ship must be deployed before", Color.White, GameResources.GameFont("Courier"), 100, 360); SwinGame.DrawText("starting the game.", Color.White, GameResources.GameFont("Courier"), 100, 380); SwinGame.DrawText("2.During the attack stage, you will just need to Click on the grid", Color.White, GameResources.GameFont("Courier"), 100, 430); SwinGame.DrawText("in order to attack enemy's ship.", Color.White, GameResources.GameFont("Courier"), 100, 450); break; default: SwinGame.ClearScreen(); break; } SwinGame.DrawFramerate(675, 585); }
public void DrawGame() { SwinGame.ClearScreen(Color.Black); if (GameState == EnumState.GameMenu) { _menu.DrawAll(); } else { _game.DrawAll(); } SwinGame.RefreshScreen(60); }
/// <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.ClearScreen(Color.White); SwinGame.DrawBitmap("cardsBoard.png", 0, 0); // Draw the top card Card top = myGame.TopCard; if (top != null) {
/// <summary> /// Handle the end loading screen /// </summary> /// <param name="width"></param> /// <param name="height"></param> private static void EndLoadingScreen(int width, int height) { SwinGame.ProcessEvents(); SwinGame.Delay(500); SwinGame.ClearScreen(); SwinGame.RefreshScreen(); SwinGame.FreeFont(_LoadingFont); SwinGame.FreeBitmap(_Background); SwinGame.FreeBitmap(_LoaderEmpty); SwinGame.FreeBitmap(_LoaderFull); Audio.FreeSoundEffect(_StartSound); SwinGame.ChangeScreenSize(width, height); }
/// <summary> /// Main Function, main acces point for the program /// </summary> public static void Main() { GameObjects.Polyhedra.Add(new A9(35)); GameObjects.Polyhedra[0].Offset(new Vector(80, 80)); //Open the game window SwinGame.OpenGraphicsWindow(Title + " v" + Version, 800, 600); //SwinGame.ToggleFullScreen(); //SwinGame.ShowSwinGameSplashScreen(); //Load the game assets GameResources.LoadResources(); GameScores.Initalise(); //Run the game loop while (false == SwinGame.WindowCloseRequested()) { //Fetch the next batch of UI interaction SwinGame.ProcessEvents(); InputController.ProcessMovement(); //Clear the screen and draw the framerate SwinGame.ClearScreen(Color.Black); SwinGame.DrawFramerate(0, 0); if (SwinGame.KeyDown(KeyCode.vk_z)) { GameObjects.Polyhedra[0].Scale(1.01); } if (SwinGame.KeyDown(KeyCode.vk_x)) { GameObjects.Polyhedra[0].Scale(0.99); } //Update Game GameObjects.Draw(Color.Goldenrod, Color.DarkGoldenrod); tick++; //Draw onto the screen SwinGame.RefreshScreen(60); } GameResources.FreeResources(); }