protected override void Initialize() { device = graphics.GraphicsDevice; state = GameState.MMenu; this.Window.Title = "Rat Run Racer"; graphics.PreferredBackBufferWidth = 1280;//720p graphics.PreferredBackBufferHeight = 720; graphics.ApplyChanges(); mainMenu = new MainMenu(new Vector2(640, 280), new Vector2(640, 380)); myPlayer = new Rat(Color.White, new Vector2(100, 500),new Vector2(0,0)); cam = new Camera2d(); cam._pos.Y = -200; cam._pos.X = 650; base.Initialize(); }
public static void resetLobbyPlayer() { myp = new Rat(Color.White, new Vector2(100, 500), new Vector2(0, 0)); myp.makePlayerControled(); myp.username = myName; OtherRats.allrats.Clear(); OtherRats.Newrats.Clear(); isReady = false; }
protected override void Update(GameTime gameTime) { KeyboardState ks = Keyboard.GetState(); if (state == GameState.lobby) { if (Lobby.Update()) { myPlayer = Lobby.myp; state = GameState.playing; } } if (state == GameState.playing) { if (myPlayer.update(World1)) { OtherRats.update(World1); if (myPlayer.pos.X > 650) { cam._pos.X = myPlayer.pos.X; } else { cam._pos.X = 650; } if (myPlayer.pos.Y < 1235) { cam._pos.Y = myPlayer.pos.Y; } else { cam._pos.Y = 1235; } World1.update(); } else { state = GameState.lobby; } if (Lobby.goBackToLobby()) { state = GameState.lobby; } } //Selection switch case for main menu if (state == GameState.MMenu) { mainMenu.Update(); if ( ks.IsKeyDown(Keys.Enter)) { switch (mainMenu.getSelection()) { case 1: state = GameState.lobby; break; case 2: this.Exit(); break; default: break; } } } base.Update(gameTime); }
public static bool goBackToLobby() { if(isFinshed) { //reset stuff to get ready for new lobby isFinshed = false; string myname = myp.username; myp = new Rat(Color.White, new Vector2(100, 500), new Vector2(0, 0)); //make a new rat player myp.username = myname; myp.makePlayerControled(); OtherRats.allrats.Clear(); OtherRats.Newrats.Clear(); return true; } return false; }