public void GamepadListener(GamePadState game,GamePadState previousstate, Player Opponent) { if (game.IsButtonDown(Buttons.RightTrigger) && !previousstate.IsButtonDown(Buttons.RightTrigger))//fire shot { if (bullets > 0) { bullets--; RemoveReticule(Opponent); } else { //Reload sGame.mSound.Play(Sound.SoundFX.Reload); // Sound.SoundFX.Move } } float x = game.ThumbSticks.Right.X; if ( x > 0) { position.X += ((int)8*x)+2; } else if (x < 0) { position.X += ((int)8 * x) + 2; } float y = game.ThumbSticks.Right.Y; if ( y> 0) { position.Y -= ((int)8 * y) + 2; ; } else if ( y < 0) { position.Y -= ((int)8 * y) + 2; } }
public void RemoveReticule(Player Opponent) { Xcoord = position.X; Ycoord = position.Y; // showing = 0; // finished = true; int color; Vector2 coords; coords = GetCoords(); coords.X = (coords.X - Opponent.mPlayfield.Xpos) / Opponent.mPlayfield.mBlockSize; coords.Y = (coords.Y - Opponent.mPlayfield.Ypos) / Opponent.mPlayfield.mBlockSize; color=Opponent.mPlayfield.ClearBlock((int)coords.X, (int)coords.Y); if(color==-1)//MISSED your shot { } else { sGame.mSound.Play(Sound.SoundFX.Laser); Color c=new Color(); c.R = Shape.colorTypes[color, 0]; c.G = Shape.colorTypes[color, 1]; c.B = Shape.colorTypes[color, 2]; c.A = 255; Vector2 destination = new Vector2(Opponent.Opponent.mPlayfield.Xpos + Opponent.Opponent.mPlayfield.Width * 24 + 30 + 12, Opponent.Opponent.mPlayfield.Ypos + (color * 50) + 12); sGame.particleManager.AddParticles(new Vector2(position.X-12, position.Y-12), SuperXblox360.Components.ParticleSystem.Particle.ParticleType.Explosion); sGame.particleManager.AddParticles(new Vector2(position.X-12, position.Y-12), SuperXblox360.Components.ParticleSystem.Particle.ParticleType.Lightning, destination, c); // mCurrentState = PlayerState.Playing; } }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); gameFont = ScreenManager.Game.Content.Load<SpriteFont>("gamefont"); mBackground = ScreenManager.Game.Content.Load<Texture2D>("Images/Background2"); mBackground2 = ScreenManager.Game.Content.Load<Texture2D>("Images/1"); one = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/1"); two = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/2"); three = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/3"); four = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/4"); five = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/5"); mBlock = ScreenManager.Game.Content.Load<Texture2D>("Images/Block_Textures/OneBlock"); //mMessageBox = ScreenManager.Game.Content.Load<Texture2D>("Images/MessageBox"); mIntro = ScreenManager.Game.Content.Load<Texture2D>("Images/IntroScreen"); con_front = ScreenManager.Game.Content.Load<Texture2D>("Images/ControllerImages/con_front_ortho"); xboxlogo = ScreenManager.Game.Content.Load<Texture2D>("Images/xbox360logo1"); con_spritefont = ScreenManager.Game.Content.Load<SpriteFont>("xboxControllerSpriteFont"); grid_texture = ScreenManager.Game.Content.Load<Texture2D>("Images/grid"); backbutton = ScreenManager.Game.Content.Load<Texture2D>("Images/ControllerImages/small_back"); startbutton = ScreenManager.Game.Content.Load<Texture2D>("Images/ControllerImages/small_start"); // reticule = (Reticule)ScreenManager.Game.Components[3]; //these will eventually be passed the current game Players[0] = new Player(400, 50 + 98, 10, 10, true, true, ((SuperXbloxGame)(ScreenManager.Game)).mSound, 1, PlayerIndex.One); mText = ScreenManager.Game.Content.Load<SpriteFont>("navText"); //give the players their graphics to use Players[0].load(mBlock, grid_texture); // Players[0].load(reticule); Players[0].linkedblocks = true; Players[0].gravity = true; Players[0].mPlayfield.game = Game; Players[0].game = Game; Players[0].mPlayfield.draw_collected = true; Players[0].mAutoFallThreshold =.050f; Players[0].shapelimit = 6; //Initialize the graphics, the game and the text objects // A real game would probably have more content than this sample, so // it would take longer to load. We simulate that by delaying for a // while, giving you a chance to admire the beautiful loading screen. Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); }
// showing = 1; // finished = false; ////} // public void AddReticule(int Xmin, int Xmax, int Ymin, int Ymax) // { // Initialize(Xmin, Xmax, Ymin, Ymax); // showing = 1; // finished = false; // //KeyboardState keys = Keyboard.GetState(); // //KeyboardListener(keys); // } public void KeyboardListener(KeyboardState keys, Player Opponent) { if (keys.IsKeyDown(Keys.Q)) RemoveReticule(Opponent); if (keys.IsKeyDown(Keys.Right)) { position.X += 2; //Draw(gameTime); } if (keys.IsKeyDown(Keys.Left)) { position.X -= 2; // Draw(gameTime); } if (keys.IsKeyDown(Keys.Up)) { position.Y -= 2; // Draw(gameTime); } if (keys.IsKeyDown(Keys.Down)) { position.Y += 2; // Draw(gameTime); } }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); gameFont = ScreenManager.Game.Content.Load<SpriteFont>("gamefont"); mBackground = ScreenManager.Game.Content.Load<Texture2D>("Images/Background_boring"); mBackground2 = ScreenManager.Game.Content.Load<Texture2D>("Images/1"); one = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/1"); two = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/2"); three = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/3"); four = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/4"); five = ScreenManager.Game.Content.Load<Texture2D>("Images/generic backgrounds/5"); mBlock = ScreenManager.Game.Content.Load<Texture2D>("Images/Block_Textures/OneBlock"); mIntro = ScreenManager.Game.Content.Load<Texture2D>("Images/IntroScreen"); con_front = ScreenManager.Game.Content.Load<Texture2D>("Images/ControllerImages/con_front_ortho"); xboxlogo = ScreenManager.Game.Content.Load<Texture2D>("Images/xbox360logo1"); con_spritefont = ScreenManager.Game.Content.Load<SpriteFont>("xboxControllerSpriteFont"); grid_texture = ScreenManager.Game.Content.Load<Texture2D>("Images/grid"); startbutton = ScreenManager.Game.Content.Load<Texture2D>("Images/ControllerImages/small_start"); backbutton = ScreenManager.Game.Content.Load<Texture2D>("Images/ControllerImages/small_back"); square = ScreenManager.Game.Content.Load<Texture2D>("Images/square"); //these will eventually be passed the current game Players[0] = new Player(120, 170, 20, 10, false, false, ((SuperXbloxGame)(ScreenManager.Game)).mSound, 24, PlayerIndex.One); Players[1] = new Player(390, 170, 20, 10, false, false, ((SuperXbloxGame)(ScreenManager.Game)).mSound, 24, PlayerIndex.Two); Players[2] = new Player(660, 170, 20, 10, false, false, ((SuperXbloxGame)(ScreenManager.Game)).mSound, 24, PlayerIndex.Three); Players[3] = new Player(930, 170, 20, 10, false, false, ((SuperXbloxGame)(ScreenManager.Game)).mSound, 24, PlayerIndex.Four); mText = ScreenManager.Game.Content.Load<SpriteFont>("navText"); //give the players their graphics to use Players[0].load(mBlock, grid_texture); Players[1].load(mBlock, grid_texture); Players[2].load(mBlock, grid_texture); Players[3].load(mBlock,grid_texture); //Initialize the graphics, the game and the text objects // A real game would probably have more content than this sample, so // it would take longer to load. We simulate that by delaying for a // while, giving you a chance to admire the beautiful loading screen. Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); }