public override void Draw() { SplashKit.DrawBitmap(_Image, X, Y); SplashKit.FillRectangle(Color.DarkBlue, BoxX, BoxY, BoxWidth, BoxHeight); SplashKit.DrawRectangle(Color.White, BoxX, BoxY, BoxWidth, BoxHeight); _HealthPercent = (double)_Health / _MaxHealth; SplashKit.DrawText($"{_Name} ", Color.White, MainFont, 40, _GameWindow.Width - BoxWidth - BoxOuterBuffer + BoxInnerBuffer, 3 * _GameWindow.Height / 4 - BoxHeight - BoxOuterBuffer + BoxInnerBuffer); SplashKit.DrawText($"HP:", Color.White, MainFont, 40, _GameWindow.Width - BoxWidth - BoxOuterBuffer + BoxInnerBuffer, 3 * _GameWindow.Height / 4 - BoxHeight - BoxOuterBuffer + BoxInnerBuffer + 40); SplashKit.DrawText($"Lv: {_Level}", Color.White, MainFont, 40, _GameWindow.Width - BoxOuterBuffer - BoxWidth / 2 + 50, 3 * _GameWindow.Height / 4 - BoxOuterBuffer - BoxHeight + BoxInnerBuffer); SplashKit.FillRectangle(Color.Red, _GameWindow.Width - BoxWidth - BoxOuterBuffer + 2 * BoxInnerBuffer + 40, 3 * _GameWindow.Height / 4 - BoxHeight - BoxOuterBuffer + 2 * BoxInnerBuffer + 40, _HealthPercent * HealthBarWidth, HealthBarHeight); SplashKit.DrawRectangle(Color.White, _GameWindow.Width - BoxWidth - BoxOuterBuffer + 2 * BoxInnerBuffer + 40, 3 * _GameWindow.Height / 4 - BoxHeight - BoxOuterBuffer + 2 * BoxInnerBuffer + 40, HealthBarWidth, HealthBarHeight); }
public void Display(GameFacade facade) { Frogger game = Frogger.Instance; GameTimer timer = GameTimer.Instance; game.RunGame(); timer.ResetTimer(); // sidebars SplashKit.FillRectangle(Color.Black, 0, 0, 25, 800); SplashKit.FillRectangle(Color.Black, 675, 0, 25, 800); if (SplashKit.KeyTyped(KeyCode.EscapeKey)) { facade.SetState(new GameMenuState()); } }
public void Update() { const int TOAST = 8; Vector2D movement = new Vector2D(); Matrix2D rotation = SplashKit.RotationMatrix(_angle); movement.X += TOAST; movement = SplashKit.MatrixMultiply(rotation, movement); _x += movement.X; _y += movement.Y; if ((_x > SplashKit.ScreenWidth() || _x < 0) || _y > SplashKit.ScreenHeight() || _y < 0) { _active = false; } }
public void Draw() { _GameWindow.Clear(Color.White); foreach (Robot robot in _Robot) { robot.Draw(); } for (int i = 1; i <= Lives; i++) { SplashKit.DrawBitmap(Life, 600 - (i * 50), 50); } SplashKit.DrawTextOnWindow(_GameWindow, Convert.ToString(_Score.Ticks / 1000), Color.Black, 50, 50); _Player.Draw(); _GameWindow.Refresh(60); }
public void LoadResource() { SplashKit.LoadBitmap("Player1", "Spaceship1.png"); SplashKit.LoadBitmap("Player2", "Spaceship2.png"); SplashKit.LoadBitmap("Player1S", "Spaceship1S.png"); SplashKit.LoadBitmap("Player2S", "Spaceship2S.png"); SplashKit.LoadBitmap("Enemy1", "fireball.png"); SplashKit.LoadBitmap("Enemy2", "Alien1.png"); SplashKit.LoadBitmap("Enemy3", "Alien2.png"); SplashKit.LoadBitmap("Reward1", "Fuel.png"); SplashKit.LoadBitmap("Reward2", "Star.png"); SplashKit.LoadBitmap("Space", "Space.png"); SplashKit.LoadFont("FontC", "calibri.ttf"); SplashKit.LoadFont("FontU", "unknown.ttf"); SplashKit.LoadFont("FontJ", "jeebra.ttf"); }
public ButchyMen(Window window) { _Window = window; _GameLevel = new GameLevel(window, levelCount, DoorDirection.South); _Player = new Player(window); // Create rand num of isopods int isopodCount = SplashKit.Rnd(3) + 1; for (int i = 0; i < isopodCount; i++) { _Isopods.Add(new Isopod(window, _Player)); } // Create rand num of obstacles int obstacleCount = SplashKit.Rnd(5) + 1; for (int i = 0; i < obstacleCount; i++) { _Obstacles.Add(new Obstacle(window)); } // Removal of obstacles that spawn on top of each other List <Obstacle> removeObstacles = new List <Obstacle> (); foreach (Obstacle obstaclei in _Obstacles) { foreach (Obstacle obstaclej in _Obstacles) { if (obstaclei != obstaclej & obstaclei.CollidedWith(obstaclej)) { removeObstacles.Add(obstaclei); } } if (_Player.CollidedWith(obstaclei)) { removeObstacles.Add(obstaclei); } } foreach (Obstacle obstacle in removeObstacles) { _Obstacles.Remove(obstacle); } if (levelCount == 1) { _startMonument = new Monument(window); } }
// pacman pellet collision private void PelletCollision() { // TODO: scoring for pellets, super pellet List <Pellet> pellets2Remove = new List <Pellet>(); // list of pellet objects to remove if (_Gameboard._Pellets.Count > 0) { Rectangle pacman = SplashKit.InsetRectangle(SplashKit.RectangleFrom(_Pacman.Position, _Pacman.WidthHeight, _Pacman.WidthHeight), 3); foreach (Pellet p in _Gameboard._Pellets) { Rectangle pellet = SplashKit.RectangleFrom(p.Position, p.WidthHeight, p.WidthHeight); if (SplashKit.RectanglesIntersect(pacman, pellet)) { pellets2Remove.Add(p); // add to player score here and super pellet activation if (p.SuperPellet) { Ghost._Vulnerable = true; // set ghosts to vulnerable _Pacman._Score += 50; SplashKit.PlaySoundEffect("vulnerable"); } else { _Pacman._Score += 10; if (!SplashKit.SoundEffectPlaying("vulnerable")) { SplashKit.PlaySoundEffect("eating"); } } } } // remove pellets foreach (Pellet p in pellets2Remove) { _Gameboard._Pellets.Remove(p); } } else { StartGame(false); // no pellets = new round. } }
public static void Main() { Dictionary <int, string> menuOptions = new Dictionary <int, string>() { { 1, "Verb Tense" }, { 2, "Prepositions" }, { 3, "Pronouns" }, { 4, "Adjectives" }, { 5, "Conditionals" }, { 6, "Phasal Verbs" }, { 7, "Quit" } }; QuestionManager questionManager = new QuestionManager(); DatabaseManager bdManager = new DatabaseManager(); bdManager.loadDatabase(); int option; do { if (menuOptions.Count == 1) { Console.WriteLine("----------------------------- Game over -----------------------------"); Console.WriteLine("OMG! You finilized all questions!!"); break; } option = ReadUserOption(menuOptions); if (option != 7) { Console.WriteLine($"----------------------------- {menuOptions[option]} -----------------------------"); menuOptions.Remove(option); questionManager.handleQuestions(bdManager.getQuestionsByTopic(option)); } }while(option != 7); Console.WriteLine($"Total Score: {questionManager.score}"); Console.WriteLine("Thanks for playing!"); SplashKit.FreeAllDatabases(); SplashKit.FreeAllQueryResults(); }
public void CheckHitObject(List <HitCube> list) { Rectangle player = new Rectangle { X = Player.X, Y = Player.Y, Width = Player.Width, Height = Player.Height }; foreach (HitCube o in list) { if (SplashKit.RectanglesIntersect(player, new Rectangle { X = o.X, Y = o.Y, Width = o.Width, Height = o.Height }) && !o.Hit) { o.Hit = true; if (o.Width == Size && o.Height == Size) { Score += (Combo * Base); Combo += 1; Hits++; SplashKit.PlaySoundEffect("hitsound"); } else if (o.Height == 25) { if (Lives == 5) { o.Hit = false; } else if (o.X == 375) { Lives = 5; } else { Lives++; } } else { Combo--; Lives--; LivesUsed++; SplashKit.PlaySoundEffect("miss"); } } } }
public void RandomAI() { bool rightLane = false; while (!rightLane) { double rnd = SplashKit.Rnd(); if (rnd > 0.4) { AI newAI = new AICar1(); if (CheckLane(newAI)) { _ai.Add(newAI); rightLane = true; } } if (rnd <= 0.4 && rnd > 0.2) { AI newAI = new AICar2(); if (CheckLane(newAI)) { _ai.Add(newAI); rightLane = true; } } if (rnd <= 0.2 && rnd > 0.1) { AI newAI = new AICar3(); if (CheckLane(newAI)) { _ai.Add(newAI); rightLane = true; } } if (rnd <= 0.1) { AI newAI = new Reward1(); if (CheckLane(newAI)) { _ai.Add(newAI); rightLane = true; } } } }
public void TopClicked() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = @"F:\Justin\Documents\osu!\Songs"; openFileDialog.Filter = "osu files (*.osu)|*.osu"; openFileDialog.RestoreDirectory = true; openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() == DialogResult.OK) { Game.getInstance().Level = new Level(openFileDialog.FileName); Game.getInstance().Reader = new Mp3FileReader(Path.GetDirectoryName(openFileDialog.FileName) + @"\" + Game.getInstance().Level.Beatmap.AudioFilename); SplashKit.LoadMusic("audio", Path.GetDirectoryName(openFileDialog.FileName) + @"\" + Game.getInstance().Level.Beatmap.AudioFilename); Game.getInstance().Duration = Game.getInstance().Reader.TotalTime; Game.getInstance().LoadLevel(false); Game.getInstance().SetState(new Countdown(false)); } }
public static void Main() { Window gameWindow = new Window("Game Window", 800, 600); Player Player1 = new Player(gameWindow); MeteorDodge Dodge1 = new MeteorDodge(gameWindow, Player1); // string healthFormat = string.Format("Health: ", Player1.Health); while (!gameWindow.CloseRequested) { SplashKit.ProcessEvents(); Dodge1.HandleInput(); Dodge1.Update(); Dodge1.Draw(); } gameWindow.Close(); }
public override void Draw() { double leftX, midX, rightX; double midY, eyeY, mouthY; leftX = _x + 17; midX = _x + 25; rightX = _x + 33; midY = _y + 25; eyeY = _y + 20; mouthY = _y + 35; SplashKit.FillCircle(Color.White, midX, midY, 25); SplashKit.DrawCircle(Color.Gray, midX, midY, 25); SplashKit.FillCircle(_mainColour, leftX, eyeY, 5); SplashKit.FillCircle(_mainColour, rightX, eyeY, 5); SplashKit.FillEllipse(Color.Gray, _x, eyeY, 50, 30); SplashKit.DrawLine(Color.Black, _x, mouthY, _x + 50, _y + 35); }
public Barrier ReleaseBarrier() { if (SplashKit.Rnd() < 0.33) { Box box = new Box(_GameWindow, _Player); return(box); } else if (SplashKit.Rnd() < 0.66) { Train train = new Train(_GameWindow, _Player); return(train); } else { Bus bus = new Bus(_GameWindow, _Player); return(bus); } }
public override void Draw() { double leftX, midX, rightX; double midY, eyeY, mouthY; leftX = X + 17; midX = X + 25; rightX = X + 33; midY = Y + 25; eyeY = Y + 20; mouthY = Y + 35; SplashKit.FillCircle(Color.White, midX, midY, 25); SplashKit.DrawCircle(Color.Gray, midX, midY, 25); // SplashKit.FillCircle(MainColor, leftX, eyeY, 5); // SplashKit.FillCircle(MainColor, rightX, eyeY, 5); SplashKit.FillEllipse(Color.Gray, X, eyeY, 50, 30); SplashKit.DrawLine(Color.Black, X, mouthY, X + 50, Y + 35); }
public void PotionHeal(Character _Caster) { Heal Heal = new Heal(_Caster, "Potion"); if (_Player.UsePotion()) { Heal.Execute(); DisplayMessage(Heal.Message()); DisplayBoxBehaviour(_Caster); _PotionButton.ChangeInput($"Potion ({_Player.potionAmount})"); SplashKit.PlaySoundEffect("Heal", _soundLevel); } else { NoPotionsMessage(); } _Player.CounteredOff(); }
public Game() { Objects = new List <Block>(); HitObjects = new List <HitCube>(); HP = new List <HitCube>(); Buttons = new List <Button>(); ButtonColor = new List <Color>(); DisplayText = new List <Text>(); Player = new Player(); Timer = new SplashKitSDK.Timer("level"); Speed = new int[2]; SplashKit.LoadSoundEffect("hitsound", Path.Combine(Environment.CurrentDirectory, @"Resources\normal-hitnormal.wav")); SplashKit.LoadSoundEffect("miss", Path.Combine(Environment.CurrentDirectory, @"Resources\combobreak.wav")); SplashKit.LoadFont("Bungee", Path.Combine(Environment.CurrentDirectory, @"Resources\Bungee-Regular.otf")); SplashKit.LoadBitmap("Background", Path.Combine(Environment.CurrentDirectory, @"Resources\Paradigm-Background.png")); SetState(new MainMenu()); SetModifier(new Normal()); }
public static void Main() { Window gameWindow = new Window("Surf Game", 1250, 650); SurfGame _game = new SurfGame(gameWindow); while (!gameWindow.CloseRequested && _game.Quit == false) { SplashKit.ProcessEvents(); _game.HandleInput(); _game.Update(); _game.Draw(); } _game.FinalScore(); SplashKit.Delay(5000); gameWindow.Close(); gameWindow = null; }
/// <summary> /// Checks if the passed point is withing the bounds of the /// slider /// </summary> /// <param name="pt">Position to check against</param> /// <returns>True if the slider is at the passed point, else false</returns> public override bool IsAt(Point2D pt) { bool isAtPoint = false; double midY = _y + _height / 2; Rectangle rect = new Rectangle(); rect.X = _x; rect.Y = midY - _height / 8; rect.Width = _width; rect.Height = _height / 4; if (SplashKit.PointInRectangle(pt, rect)) { isAtPoint = true; } return(isAtPoint); }
// tracks game according to frogs life state public void FrogState() { // frog icons representing lives in bottom left corner for (int i = 0, x = 30; i < _frog.Lives; i++, x += 60) { SplashKit.DrawBitmap(SplashKit.BitmapNamed("frogicon"), x, 755); } // frog will be drawn as long as it has lives otherwise game will be over if (_frog.Lives > 0) { _frog.Draw(); } else { Loses(); } }
public static void Main() { var window = new Window("window", 1600, 1000); var player = new Player(window); Game game = new Game(window, player); while (!window.CloseRequested && player.Quit != true) { SplashKit.ProcessEvents(); window.Clear(Color.White); game.Draw(); game.HandleInput(); game.Update(); window.Refresh(60); } }
private void HandleBet(BetType type) { if (type == BetType.PARITY) { if (_rouletteRoll.DetermineParity() == _surroundingNumbers[0]) { _payOut = (_betAmount * RouletteDependencies.BetMultiplier(type)); Console.WriteLine($"Congratulations, you have won ${_payOut} on your ${_betAmount} bet!"); _user.BalanceAdjust(true, _payOut + _betAmount); _rouletteRoll.ChangeRolling(false); SplashKit.PlaySoundEffect(new SoundEffect("RouletteWin", "RouletteWin.mp3")); return; } } else if (type == BetType.COLOUR) { if (_rouletteRoll.DetermineColour() == _surroundingNumbers[0]) { _payOut = (_betAmount * RouletteDependencies.BetMultiplier(type)); Console.WriteLine($"Congratulations, you have won ${_payOut} on your ${_betAmount} bet!"); _user.BalanceAdjust(true, _payOut + _betAmount); _rouletteRoll.ChangeRolling(false); SplashKit.PlaySoundEffect(new SoundEffect("RouletteWin", "RouletteWin.mp3")); return; } } else { for (int i = 0; i < _surroundingNumbers.Length; i++) { if (_surroundingNumbers[i] == _roll) { _payOut = (_betAmount * RouletteDependencies.BetMultiplier(type)); Console.WriteLine($"Congratulations, you have won ${_payOut} on your ${_betAmount} bet!"); _user.BalanceAdjust(true, _payOut + _betAmount); _rouletteRoll.ChangeRolling(false); SplashKit.PlaySoundEffect(new SoundEffect("RouletteWin", "RouletteWin.mp3")); return; } } } Console.WriteLine($"Sorry, you have lost ${_betAmount}."); _rouletteRoll.ChangeRolling(false); }
//Generate new row of boxes // Using random to choose the number of box // Using random to create Plusy box ( box used for get more bullets) or normal Boxy box public void GenerateBox() { double temp = _gameWindow.Width / 50; int maxBox = Convert.ToInt32(Math.Floor(temp)); int numBox = SplashKit.Rnd(1, maxBox); int minPos = 0; int maxPos = maxBox - numBox; for (int i = 1; i <= numBox; i++) { int pos; if (maxPos == minPos) { pos = maxPos; } else { pos = SplashKit.Rnd(minPos, maxPos); } if (minPos <= pos) { minPos = pos + 1; } maxPos += 1; Box box; if ((SplashKit.Rnd() < 0.2) && (_Bullets.Count <= 30)) { box = new Plusy(_gameWindow, pos * 50, 50, 1); } else { if (_Bullets.Count == 1) { box = new Boxy(_gameWindow, pos * 50, 50, 1); } else { box = new Boxy(_gameWindow, pos * 50, 50, SplashKit.Rnd(1, _Bullets.Count)); } } _Boxes.Add(box); } }
public void HandleMethod() { if (SplashKit.KeyDown(KeyCode.RightKey)) { X += Speed; } if (SplashKit.KeyDown(KeyCode.RightKey) && SplashKit.KeyDown(KeyCode.LeftShiftKey)) { X += Boost; } if (SplashKit.KeyDown(KeyCode.LeftKey)) { X -= Speed; } if (SplashKit.KeyDown(KeyCode.LeftKey) && SplashKit.KeyDown(KeyCode.LeftShiftKey)) { X -= Boost; } if (SplashKit.KeyDown(KeyCode.UpKey)) { Y -= Speed; } if (SplashKit.KeyDown(KeyCode.UpKey) && SplashKit.KeyDown(KeyCode.LeftShiftKey)) { Y -= Boost; } if (SplashKit.KeyDown(KeyCode.DownKey)) { Y += Speed; } if (SplashKit.KeyDown(KeyCode.DownKey) && SplashKit.KeyDown(KeyCode.LeftShiftKey)) { Y += Boost; } if (SplashKit.KeyTyped(KeyCode.EscapeKey)) { Quit = true; } if (SplashKit.MouseClicked(MouseButton.LeftButton)) { _Bullet.Draw(); } }
public void Update() { if (SplashKit.Rnd(100) < 2) { _Robots.Add(RandomRobot()); } foreach (var _TestRobot in _Robots) { _TestRobot.Update(); } if (_Bullets != null) { foreach (var _Bullet in _Bullets) { _Bullet.Update(); } } CheckCollisions(); }
public static void Main() { Window windowOne = new Window("game", 600, 900); Game newGame = new Game(windowOne); SoundEffect backGroundMusic = new SoundEffect("game", "game.wav"); newGame.myTimer.Start(); backGroundMusic.Play(); while (!newGame.Quit) { SplashKit.ProcessEvents(); newGame.Draw(); newGame.HandleInput(); newGame.Update(); } newGame.GameOverEffect(); windowOne.Close(); }
public override void Draw() { double leftX, midX, rightX; double midY, eyeY, mouthY; leftX = X + 17; midX = X + 25; rightX = X + 33; midY = Y + 25; eyeY = Y + 20; mouthY = Y + 35; SplashKit.FillCircle(Color.Red, midX, midY, 25); SplashKit.FillCircle(Color.Blue, midX, midY, 20); SplashKit.FillCircle(Color.Green, midX, midY, 15); SplashKit.FillCircle(Color.Yellow, midX, midY, 10); SplashKit.FillCircle(Color.White, midX, midY, 5); }
public void SwapPlayer(Bitmap p, GetBitmapName getname) { if (getname(p) == "Player1") { SpaceShipBitmap = SplashKit.BitmapNamed("Player2"); } if (getname(p) == "Player2") { SpaceShipBitmap = SplashKit.BitmapNamed("Player1"); } if (getname(p) == "Player1S") { SpaceShipBitmap = SplashKit.BitmapNamed("Player2S"); } if (getname(p) == "Player2S") { SpaceShipBitmap = SplashKit.BitmapNamed("Player1S"); } }
public void RoadMove() { if (_myTimer.Ticks < 200) { _road = SplashKit.BitmapNamed("Road1"); } if (_myTimer.Ticks >= 200 && _myTimer.Ticks < 400) { _road = SplashKit.BitmapNamed("Road2"); } if (_myTimer.Ticks >= 400 && _myTimer.Ticks < 600) { _road = SplashKit.BitmapNamed("Road3"); } if (_myTimer.Ticks >= 600) { _myTimer.Start(); } }
public void DrawInstructions() { SplashKit.FillRectangle(Color.DarkBlue, _InstructionsX, _InstructionsY, 3 * gameWindow.Width / 4, 3 * gameWindow.Height / 4); SplashKit.DrawRectangle(Color.White, _InstructionsX, _InstructionsY, 3 * gameWindow.Width / 4, 3 * gameWindow.Height / 4); SplashKit.DrawText($"Welcome to C# Battler", Color.White, _MainFont, 40, _InstructionsX + 20, _InstructionsY); SplashKit.DrawText($"Use the menu to navigate", Color.White, _MainFont, 22, _InstructionsX + 20, _InstructionsY + 2 * _LineHeight); SplashKit.DrawText($"The Charge Attack is a mostly accurate but low damage attack", Color.White, _MainFont, 22, _InstructionsX + 20, _InstructionsY + 4 * _LineHeight); SplashKit.DrawText($"The Slash Attack is a semi accurate and high damage attack", Color.White, _MainFont, 22, _InstructionsX + 20, _InstructionsY + 5 * _LineHeight); SplashKit.DrawText($"The Spell Attack is a semi accurate low attack that ignores counters", Color.White, _MainFont, 22, _InstructionsX + 20, _InstructionsY + 6 * _LineHeight); SplashKit.DrawText("A counter is 50% likely to reflect back an attack for half damage", Color.White, _MainFont, 22, _InstructionsX + 20, _InstructionsY + 8 * _LineHeight); SplashKit.DrawText($"You begin with 10 potions which each heal 30 Health", Color.White, _MainFont, 22, _InstructionsX + 20, _InstructionsY + 10 * _LineHeight); SplashKit.DrawText($"A magic heal will heal a random amount relative to your level", Color.White, _MainFont, 22, _InstructionsX + 20, _InstructionsY + 11 * _LineHeight); SplashKit.DrawText("The button labelled Instructions in the top left will toggle this box", Color.White, _MainFont, 22, _InstructionsX + 20, _InstructionsY + 13 * _LineHeight); SplashKit.DrawText("Enjoy!", Color.White, _MainFont, 22, _InstructionsX + 20, _InstructionsY + 14 * _LineHeight); }