/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. InputDevice2.Initalize(); HighScoresState.InitalizeHighScores(); //replace this with a join screen later #if XBOX InputDevice2.LockController(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerPad.GamePad1); #elif WINDOWS InputDevice2.LockController(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerPad.Keyboard); #endif spriteBatch = new SpriteBatch(GraphicsDevice); AnimationLib al = new AnimationLib(GraphicsDevice, spriteBatch); AnimationLib.cacheAtlasFiles(); //some of these assets are critical to render anything to the screen, and thus are not stored in a seperate thread saveIcon = Content.Load <Texture2D>("gfx/saveIcon"); debugFont = Content.Load <SpriteFont>("testFont"); whitePixel = Content.Load <Texture2D>("whitePixel"); pleaseWaitDialog = Content.Load <Texture2D>("pleaseWait"); asteroidsSpriteSheet = Content.Load <Texture2D>("ppg_asteroids"); for (int i = 0; i < starCount; i++) { stars[i] = new Vector2(rand.Next() % 2000 - 1000, rand.Next() % 2000 - 1000); starRotation[i] = (float)(rand.NextDouble() % (Math.PI * 2)); } new Thread(loadSpine2).Start(); new Thread(loadContent2).Start(); }
protected override void doUpdate(GameTime currentTime) { button_pressed_timer += currentTime.ElapsedGameTime.Milliseconds; zoom += currentTime.ElapsedGameTime.Milliseconds; switch (zoom_state) { case popUpZoomState.zoomIn: if (zoom > zoom_duration) { pop_up_menu = true; zoom_state = popUpZoomState.zoomStay; zoom = 0.0f; } break; case popUpZoomState.zoomStay: zoom = 0.0f; break; case popUpZoomState.zoomOut: if (zoom > zoom_duration) { zoom_state = popUpZoomState.zoomStay; pop_up_menu = false; pop_up_screen = false; zoom = 0.0f; } break; } if (!pop_up_menu) { if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection)) { if (!down_pressed) { button_pressed_timer = 0.0f; } down_pressed = true; } if ((down_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection)) || (down_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.DownDirection) && button_pressed_timer > max_button_pressed_timer)) { button_pressed_timer = 0.0f; down_pressed = false; AudioLib.playSoundEffect(menuBlipSound); menu_item_select++; if (menu_item_select >= options_list.Count()) { menu_item_select = menu_item_select % options_list.Count(); } else if (menu_item_select < 0) { menu_item_select += options_list.Count(); } } if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection)) { if (!up_pressed) { button_pressed_timer = 0.0f; } up_pressed = true; } if ((up_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection)) || (up_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.UpDirection) && button_pressed_timer > max_button_pressed_timer)) { button_pressed_timer = 0.0f; up_pressed = false; AudioLib.playSoundEffect(menuBlipSound); menu_item_select--; if (menu_item_select > 0) { menu_item_select = menu_item_select % options_list.Count(); } else if (menu_item_select < 0) { menu_item_select += options_list.Count(); } } if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm)) { confirm_pressed = true; } else if (confirm_pressed) { confirm_pressed = false; switch (options_list[menu_item_select].text) { case "HIGH SCORE": isComplete = true; break; case "ERASE HIGH SCORE": pop_up_screen = true; popup_item_selected = 0; zoom_state = popUpZoomState.zoomIn; HighScoresState.ResetHighScores(); SaveGameModule.saveGame(); break; case "CREDITS": isComplete = true; break; case "BACK": isComplete = true; break; default: break; } } for (int i = 0; i < options_list.Count(); i++) { if (i == menu_item_select) { options_list[menu_item_select].select = true; } else { options_list[i].select = false; } options_list[i].update(currentTime); } } /*************************************************************************************************************/ else { if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.LeftDirection)) { if (!down_pressed) { button_pressed_timer = 0.0f; } down_pressed = true; } if ((down_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.LeftDirection)) || (down_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.LeftDirection) && button_pressed_timer > max_button_pressed_timer)) { button_pressed_timer = 0.0f; down_pressed = false; popup_item_selected++; if (popup_item_selected >= popup_options.Count()) { popup_item_selected = popup_item_selected % popup_options.Count(); } else if (menu_item_select < 0) { popup_item_selected += popup_options.Count(); } } if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.RightDirection)) { if (!up_pressed) { button_pressed_timer = 0.0f; } up_pressed = true; } if ((up_pressed && !InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.RightDirection)) || (up_pressed && InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.RightDirection) && button_pressed_timer > max_button_pressed_timer)) { button_pressed_timer = 0.0f; up_pressed = false; popup_item_selected--; if (popup_item_selected > 0) { popup_item_selected = popup_item_selected % popup_options.Count(); } else if (popup_item_selected < 0) { popup_item_selected += popup_options.Count(); } } if (InputDevice2.IsPlayerButtonDown(InputDevice2.PPG_Player.Player_1, InputDevice2.PlayerButton.Confirm)) { confirm_pressed = true; } else if (confirm_pressed) { confirm_pressed = false; switch (popup_options[popup_item_selected].text) { case "NO": zoom_state = popUpZoomState.zoomOut; break; case "YES": zoom_state = popUpZoomState.zoomOut; break; default: break; } } for (int i = 0; i < popup_options.Count(); i++) { if (i == popup_item_selected) { popup_options[popup_item_selected].select = true; } else { popup_options[i].select = false; } popup_options[i].update(currentTime); } } }