private void FinishMessageAction() { FinishMessage.Visible = false; LoadNextLevel(); isMessageShowed = false; GameTime.Start(); }
private void StartGame() { FreezeTime.Start(); GameTime.Start(); Start.Start(); lbl_ScoreCounter.Text = "0"; lbl_FreezeTime.Text = "5"; lbl_moves.Text = "0"; lbl_PlayerName.Text = OPlayer.Name; lbl_size.Text = SIZE.ToString(); Board = new Board[SIZE, SIZE]; for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { PictureBox Pictureboxs = new PictureBox(); Pictureboxs.Name = "pic_" + i.ToString() + "-" + j.ToString(); Pictureboxs.Location = new Point(i * 105, j * 155); Pictureboxs.Size = new Size(100, 150); Pictureboxs.Parent = this; Pictureboxs.Tag = SetRandomImages(); Pictureboxs.BackgroundImage = Image.FromFile(Pictureboxs.Tag.ToString()); Pictureboxs.BackgroundImageLayout = ImageLayout.Stretch; Pictureboxs.Enabled = false; Pictureboxs.Click += new EventHandler(btnClick); Board[i, j] = new Board(); Board[i, j].PictureBox = Pictureboxs; } } }
static void Main(string[] args) { // initialize window and view win = new RenderWindow(new VideoMode((uint)windowSize.X, (uint)windowSize.Y), "Hadoken!!!"); view = new View(); ResetView(); gui = new GUI(win, view); // prevent window resizing win.Resized += (sender, e) => { (sender as Window).Size = windowSize; }; // exit Program, when window is being closed //win.Closed += new EventHandler(closeWindow); win.Closed += (sender, e) => { (sender as Window).Close(); }; // initialize GameState HandleNewGameState(); // initialize GameTime GameTime = new GameTime(); GameTime.Start(); // debug Text Text debugText = new Text("debug Text", new Font("Fonts/calibri.ttf")); while (running && win.IsOpen()) { KeyboardInputManager.Update(); // update GameTime GameTime.Update(); float deltaTime = (float)GameTime.EllapsedTime.TotalSeconds; currentGameState = state.Update(deltaTime); if (currentGameState != prevGameState) { HandleNewGameState(); } // gather drawStuff from State win.Clear(new Color(100, 149, 237)); //cornflowerblue ftw!!! 1337 state.Draw(win, view, deltaTime); state.DrawGUI(gui, deltaTime); // some DebugText debugText.DisplayedString = "fps: " + (1.0F / deltaTime); win.Draw(debugText); // do the actual drawing win.SetView(view); win.Display(); // check for window-events. e.g. window closed win.DispatchEvents(); Update_view(); } }
public static string rootPath = "../../"; // path for development version //public static string rootPath = ""; // path for shipping version static void Main(string[] args) { // initialize window and view win = new RenderWindow(new VideoMode(800, 600), "2D Game Project"); view = new View(); resetView(); gui = new GUI(win, view); Text debugText = new Text("", calibriFont); debugText.Color = new Color(252, 143, 80); // exit Program, when window is being closed //win.Closed += new EventHandler(closeWindow); win.Closed += (sender, e) => { (sender as Window).Close(); }; // initialize GamePadInputManager, in case, there are GamePads connected gamePadInputManager = new GamePadInputManager(); // initialize GameState handleNewGameState(); // initialize GameTime gameTime = new GameTime(); gameTime.Start(); while (running && win.IsOpen()) { gamePadInputManager.update(); // TODO: reevaluate gamepads every once in a while currentGameState = state.update(); if (currentGameState != prevGameState) { handleNewGameState(); } // draw current frame win.Clear(new Color(100, 149, 237)); //cornflowerblue ftw!!! 1337 state.draw(win, view); state.drawGUI(gui); { //HACK debugText.DisplayedString = "fps:" + (1.0 / gameTime.EllapsedTime.TotalSeconds); debugText.DisplayedString += "\ntest"; gui.draw(debugText); } win.SetView(view); win.Display(); // check for window-events. e.g. window closed win.DispatchEvents(); // update GameTime gameTime.Update(); } }
private void InitialiseForm() { CurrentPath = new DirectoryInfo(Directory.GetCurrentDirectory()).FullName.ToString(); GetAllSprites(); Map = new Map(); player = new Player(Map.StartPosition, sizeValue); camera = new Rectangle(new Point(0, 0), Screen.Size); GameTime.Start(); Cursor.Hide(); TimeLabel.Font = new Font("Calibri", 48F * Screen.Width / 1920, FontStyle.Bold, GraphicsUnit.Point); }
public GamePanel() : base() { this.DoubleBuffered = true; buffedContext = BufferedGraphicsManager.Current; _gameTime = new GameTime(); gameState = new GameWorldState(this, _gameTime); inputManager = new InputManager(gameState); _gameTime.Interval = 1000 / 80; _gameTime.Tick += _gameTime_Tick; _gameTime.Start(); }
private void GameRestart() { player.Left = 114; player.Top = 377; enemy1.Left = 221; enemy1.Top = 406; GameTime.Start(); }
public Form1() { InitializeComponent(); new Settings(); GameTime.Interval = 1000 / Settings.Speed; GameTime.Tick += UpdateScreen; GameTime.Start(); StartGame(); }
private void BeginServerLoop() { _netThread = new Thread(() => { float millisecondsPerUpdate = 1000f / Settings.TickRate; float nextUpdateTime = 0; var gameTime = new GameTime(); gameTime.Start(); while (!Server.ShutDown) { if (gameTime.TotalElapsedTime >= nextUpdateTime) { _netHandler.Update(); nextUpdateTime = gameTime.TotalElapsedTime + millisecondsPerUpdate; gameTime.Update(); } } }); _worldThread = new Thread(() => { float millisecondsPerUpdate = 1000f / Settings.TickRate; float nextUpdateTime = 0; var gameTime = new GameTime(); gameTime.Start(); while (!Server.ShutDown) { if (gameTime.TotalElapsedTime >= nextUpdateTime) { Server.ServiceLocator.GetService <WorldManager>().Update(gameTime); GameTimerManager.Instance.Update(gameTime); nextUpdateTime = gameTime.TotalElapsedTime + millisecondsPerUpdate; gameTime.Update(); } } // Save the game world Server.ServiceLocator.GetService <WorldManager>().Save(); }); _netThread.Start(); _worldThread.Start(); }
/// <summary> /// Start your game with this method. /// Starts the gametime, keeps the window open, dispatches the window events. /// Updates the gametime and the derived class aswell. Calls the draw method of the derived class and displays the window. /// </summary> public void run() { gameTime.Start(); while (window.IsOpen()) { window.DispatchEvents(); gameTime.Update(); update(gameTime); draw(gameTime, window); wheelDelta = 0; window.Display(); } }
public void Setup(int default_screen_w, int default_screen_h, int max_screen_w = 1920) { GameTime.Start(); SetResolution(default_screen_w, default_screen_h, max_screen_w); AntiCheatManager.Instance.Setup(); TimerManager.Instance.Setup(); MultyBuildManager.Instance.Setup(); ResourceManager.Instance.Setup(); UIManager.Instance.Setup(); DropSimulationManager.Instance.Setup(); SoundManager.Instance.Setup(); InputSimulateManager.Instance.Setup(); InputSimulateManager.Instance.Enable = false; HttpDownloadManager.Instance.Setup(); TransformerManager.Instance.Setup(); ObjectManager.Instance.Setup(); }
private void PlayingGame() { GameTime.Start(); bool areGameBoardsReady = false; while (StatusOfGame == GameStatus.DuringGame) { DisplayBoardContent(); if (!areGameBoardsReady) { areGameBoardsReady = gameStarter.PreparingToPlayGame(); } else { PlayingRound(); } } GameTime.Stop(); }
public override EGameStates update(GameTime gameTime) { Vec2f mousepos = Game.mouseInput.getMousePos(); inGameButton = false; creditsButton = false; exitButton = false; highscore = false; if (button_x <= mousepos.X && mousepos.X <= button_x + button_width) { if (button_y_distance <= mousepos.Y && mousepos.Y <= button_y_distance + button_height) { inGameButton = true; if (Game.mouseInput.leftClicked() || Game.joystickInput.isClicked(JoystickButton.A)) { gameTime.Stop(); gameTime.Start(); return(EGameStates.InGame); } } else if (button_y_distance * 2 + button_height <= mousepos.Y && mousepos.Y <= button_y_distance * 2 + button_height * 2) { creditsButton = true; if (Game.mouseInput.leftClicked() || Game.joystickInput.isClicked(JoystickButton.A)) { return(EGameStates.Credits); } } else if (button_y_distance * 3 + button_height * 2 <= mousepos.Y && mousepos.Y <= button_y_distance * 3 + button_height * 3) { highscore = true; if (Game.mouseInput.leftClicked() || Game.joystickInput.isClicked(JoystickButton.A)) { return(EGameStates.Score); } } else if (button_y_distance * 4 + button_height * 3 <= mousepos.Y && mousepos.Y <= button_y_distance * 4 + button_height * 4) { exitButton = true; if (Game.mouseInput.leftClicked() || Game.joystickInput.isClicked(JoystickButton.A)) { return(EGameStates.Exit); } } } player.update(gameTime); player.Position = playerPos; entities.AddRange(player.spawnNewEnemy()); for (int i = entities.Count - 1; i >= 0; --i) { entities[i].update(gameTime); if (entities.ElementAt(i).ToDelete) { entities[i].onDeath(); entities.RemoveAt(i); } } List <Keyboard.Key> pressedKeys = Game.keyboardInput.allClickedKeys(); if (pressedKeys.Count != 0) { if (pressedKeys[0] != Keyboard.Key.Escape && pressedKeys[0] != Keyboard.Key.Back) { Game.playerName += keyToChar(pressedKeys[0], Game.keyboardInput.isPressed(Keyboard.Key.RShift) || Game.keyboardInput.isPressed(Keyboard.Key.LShift)); } } if (Game.keyboardInput.isClicked(Keyboard.Key.Back) && Game.playerName.Length > 0) { Game.playerName = Game.playerName.Substring(0, Game.playerName.Length - 1); } if (Game.keyboardInput.isClicked(Keyboard.Key.Escape)) { return(EGameStates.Exit); } return(EGameStates.MainMenu); }
static void Main(string[] args) { // init screen related constants Constants.windowSizeY = (int)VideoMode.DesktopMode.Height; Constants.windowSizeX = Constants.windowSizeY * 4 / 3; Constants.windowScaleFactor = Constants.windowSizeY / 600f; Constants.screenRatio = (float)Constants.windowSizeY / Constants.windowSizeX; Constants.worldToScreenRatio = Constants.windowSizeX / Constants.worldSizeX; Constants.worldSizeY = Constants.worldSizeX * Constants.screenRatio; // initialize window and view win = new RenderWindow(new VideoMode((uint)Constants.windowSizeX, (uint)Constants.windowSizeY), "Shøøp"); view = new View(); resetView(); gui = new GUI(win, view); // exit Program, when window is being closed //win.Closed += new EventHandler(closeWindow); win.Closed += (sender, e) => { (sender as Window).Close(); }; // initialize GameState handleNewGameState(); // initialize GameTime gameTime = new GameTime(); float deltaTime = 0f; gameTime.Start(); while (running && win.IsOpen()) { // gameTime.Update(); GamePadInputManager.update(); KeyboardInputManager.update(); if (currentGameState == GameState.InGame) { inGameFrameCount++; } currentGameState = state.update(deltaTime * Constants.gameSpeedFactor); if (currentGameState != prevGameState) { handleNewGameState(); } // draw current frame win.Clear(new Color(100, 149, 237)); //cornflowerblue ftw!!! 1337 state.draw(win, view); state.drawGUI(gui); win.SetView(view); win.Display(); // check for window-events. e.g. window closed win.DispatchEvents(); System.Threading.Thread.Sleep(5); // update GameTime gameTime.Update(); deltaTime = (float)gameTime.EllapsedTime.TotalSeconds; // int waitTime = (int)(16.667f - gameTime.EllapsedTime.TotalMilliseconds); // if (waitTime > 0) System.Threading.Thread.Sleep(waitTime); // win.SetTitle(waitTime.ToString()); // win.SetTitle((count/60f).ToString("0.0") + " | " + gameTime.TotalTime.TotalSeconds.ToString("0.0")); } }
static void Main(string[] args) { // initialize window and view win = new RenderWindow(new VideoMode((uint)windowSize.X, (uint)windowSize.Y), "RAMification!!!"); view = new View(); ResetView(); gui = new GUI(win, view); // prevent window resizing win.Resized += (sender, e) => { (sender as Window).Size = windowSize; }; // exit Program, when window is being closed //win.Closed += new EventHandler(closeWindow); win.Closed += (sender, e) => { (sender as Window).Close(); }; // initialize GameState HandleNewGameState(); // initialize GameTime GameTime = new GameTime(); GameTime.Start(); logger = Logger.Instance; // TODO: set level to 0 and writemodes to false logger.SetLevel(0); // writeToFile should be optional logger.SetWriteMode(false, false); // debug Text Text debugText = new Text("debug Text", new Font("Assets/Fonts/calibri.ttf")); win.SetMouseCursorVisible(false); while (running && win.IsOpen()) { KeyboardInputManager.Update(); // update GameTime GameTime.Update(); float deltaTime = (float)GameTime.EllapsedTime.TotalSeconds; // logger needs Timespan for Timestamp! logger.UpdateTime(GameTime.TotalTime); currentGameState = state.Update(win, deltaTime); if (currentGameState != prevGameState) { HandleNewGameState(); } // gather drawStuff from State win.Clear(new Color(0, 0, 0)); //cornflowerblue ftw!!! 1337 state.Draw(win, view, deltaTime); state.DrawGUI(gui, deltaTime); // some DebugText //debugText.DisplayedString = "fps: " + (1.0F / deltaTime); //gui.Draw(debugText); // do the actual drawing win.SetView(view); win.Display(); // check for window-events. e.g. window closed win.DispatchEvents(); Update_view(); } }
private void GameScreen_Load(object sender, EventArgs e) { Random RandomSpawn = new Random(); music1 = new SoundPlayer(Miner.Properties.Resources.music1); music2 = new SoundPlayer(Miner.Properties.Resources.music2); PlayerStandSmokeAnimation[0] = Miner.Properties.Resources.Smoke1; PlayerStandSmokeAnimation[1] = Miner.Properties.Resources.Smoke2; PlayerStandSmokeAnimation[2] = Miner.Properties.Resources.Smoke3; PlayerStandSmokeAnimation[3] = Miner.Properties.Resources.Smoke4; PlayerStandSmokeAnimation[4] = Miner.Properties.Resources.Smoke5; PlayerStandSmokeAnimation[5] = Miner.Properties.Resources.Smoke6; AnimationStar[0] = Miner.Properties.Resources.Star1; AnimationStar[1] = Miner.Properties.Resources.Star2; AnimationStar[2] = Miner.Properties.Resources.Star3; AnimationStar[3] = Miner.Properties.Resources.Star4; AnimationStar[4] = Miner.Properties.Resources.Star5; AnimationStar[5] = Miner.Properties.Resources.Star6; if (Style3DClick) { Earth = Miner.Properties.Resources.Earth3D; Gold = Miner.Properties.Resources.Gold3D; TimeLock = Miner.Properties.Resources.TimeLock3D; Sprint = Miner.Properties.Resources.Sprint3D; Music = Miner.Properties.Resources.Music3D; Mine = Miner.Properties.Resources.Mine3D; Obsidian = Miner.Properties.Resources.Obsidian3D; TrueSight = Miner.Properties.Resources.TrueSight3D; } TheGold = 0; string[] SettingString = Miner.Properties.Resources.Settings.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < SettingString.Length; i++) { string[] splitString = SettingString[i].Split(new string[] { " = " }, StringSplitOptions.RemoveEmptyEntries); SettingString[i] = splitString[1]; } ManyGeneration = Convert.ToInt32(SettingString[0]); RuneGeneration = Convert.ToInt32(SettingString[1]); PlayerTime = 0; BrushTextScreen = new SolidBrush(Color.White); FontTextScreen = new Font(SettingString[2], Convert.ToInt32(SettingString[3])); BlockSize = (Height / Convert.ToInt32(SettingString[5])); TimeRune = Convert.ToInt32(SettingString[6]); PlayerSpeed = (BlockSize * 0.05) * Convert.ToDouble(SettingString[4]); TimeSmoke = Convert.ToInt32(SettingString[7]); timeJump = Convert.ToInt32(SettingString[8]); PlayerSpeedRune = BlockSize * Convert.ToDouble(SettingString[9]); MineGeneration = Convert.ToInt32(multiplication * Convert.ToDouble(SettingString[10])); block = new GameBlock[BlockHeight, BlockWidth]; for (int i = 0; i < BlockHeight; i++) { for (int j = 0; j < BlockWidth; j++) { if (i <= HeightBlockSky) { if (i != HeightBlockSky) { block[i, j].impact = false; block[i, j].type = TypeBlock.Sky; block[i, j].path = new GraphicsPath(); } else { block[i, j].impact = false; block[i, j].type = TypeBlock.Grass; block[i, j].path = new GraphicsPath(); } } else { block[i, j].impact = true; if (RandomSpawn.Next(1001) > MineGeneration) { block[i, j].type = TypeBlock.Earth; } else { block[i, j].type = TypeBlock.Mine; } block[i, j].path = new GraphicsPath(); if (PlayerName == "test" && i == HeightBlockSky + 1) { block[i, j].type = TypeBlock.Sprint; } } if (i == 0 || i == BlockHeight - 1 || j == 0 || j == BlockWidth - 1) { block[i, j].impact = true; } block[i, j].points = new Point[4]; } } for (int i = HeightBlockSky + 6; i < BlockHeight - 2; i += 5) { for (int j = 0; j < ManyGeneration; j++) { int SaveRandom = RandomSpawn.Next(3, BlockWidth - 3); block[i, BlockWidth - SaveRandom].type = TypeBlock.Gold; block[i, BlockWidth - SaveRandom - 1].type = TypeBlock.Gold; block[i, BlockWidth - SaveRandom + 1].type = TypeBlock.Gold; block[i, BlockWidth - SaveRandom + 2].type = TypeBlock.Gold; block[i + RandomSpawn.Next(-1, 2), BlockWidth - SaveRandom].type = TypeBlock.Gold; block[i + RandomSpawn.Next(-1, 2), BlockWidth - SaveRandom - 1].type = TypeBlock.Gold; block[i + RandomSpawn.Next(-1, 2), BlockWidth - SaveRandom + 1].type = TypeBlock.Gold; block[i + RandomSpawn.Next(-1, 2), BlockWidth - SaveRandom + 2].type = TypeBlock.Gold; } } for (int i = HeightBlockSky + 3; i < BlockHeight; i++) { for (int j = 0; j < BlockWidth; j++) { if (i != 0 || i != BlockHeight - 1 || j != 0 || j != BlockWidth - 1) { if (RandomSpawn.Next(1001) < RuneGeneration) { int saveRandom = RandomSpawn.Next(30); if (saveRandom >= 10) { block[i, j].type = TypeBlock.Music; } else { if (saveRandom >= 5) { block[i, j].type = TypeBlock.TrueSight; } else { if (saveRandom >= 3) { block[i, j].type = TypeBlock.TimeLock; } else { block[i, j].type = TypeBlock.Sprint; } } } } } } } for (int i = 0; i < BlockHeight; i++) { block[i, 0].type = TypeBlock.Obsidian; block[i, BlockWidth - 1].type = TypeBlock.Obsidian; } for (int i = 0; i < BlockWidth; i++) { block[0, i].type = TypeBlock.Obsidian; block[BlockHeight - 1, i].type = TypeBlock.Obsidian; } for (int i = 0; i < BlockHeight; i++) { for (int j = 0; j < BlockWidth; j++) { if (block[i, j].type == TypeBlock.Gold) { TheGold++; } } } pointsLeftImpact = new Point[4]; pointsRightImpact = new Point[4]; pointsUpImpact = new Point[2]; pointsDownImpact = new Point[2]; pointsUpImpact[0] = new Point(Width / 2 - (int)(BlockSize / 3), Height / 2 - (int)(BlockSize * 1.4)); pointsUpImpact[1] = new Point(Width / 2 + (int)(BlockSize / 3), Height / 2 - (int)(BlockSize * 1.4)); pointsDownImpact[0] = new Point(Width / 2 - (int)(BlockSize / 3), Height / 2 + (int)(BlockSize * 1.4)); pointsDownImpact[1] = new Point(Width / 2 + (int)(BlockSize / 3), Height / 2 + (int)(BlockSize * 1.4)); pointsLeftImpact[0] = new Point(Width / 2 - (int)(BlockSize / 2), Height / 2 - (int)(BlockSize * 1.25)); pointsLeftImpact[1] = new Point(Width / 2 - (int)(BlockSize / 2), Height / 2 - (int)(BlockSize * 0.5)); pointsLeftImpact[2] = new Point(Width / 2 - (int)(BlockSize / 2), Height / 2 + (int)(BlockSize * 0.5)); pointsLeftImpact[3] = new Point(Width / 2 - (int)(BlockSize / 2), Height / 2 + (int)(BlockSize * 1.25)); pointsRightImpact[0] = new Point(Width / 2 + (int)(BlockSize / 2), Height / 2 - (int)(BlockSize * 1.25)); pointsRightImpact[1] = new Point(Width / 2 + (int)(BlockSize / 2), Height / 2 - (int)(BlockSize * 0.5)); pointsRightImpact[2] = new Point(Width / 2 + (int)(BlockSize / 2), Height / 2 + (int)(BlockSize * 0.5)); pointsRightImpact[3] = new Point(Width / 2 + (int)(BlockSize / 2), Height / 2 + (int)(BlockSize * 1.25)); RangePick.Reset(); RangePick.StartFigure(); RangePick.AddRectangle(new Rectangle(Width / 2 - (int)(BlockSize * 2), Height / 2 - (int)(BlockSize * 2), (int)(BlockSize * 4), (int)(BlockSize * 4))); RangePick.CloseFigure(); GameTime.Interval = 10; GameTime.Start(); }