protected void avaliarJogada() { KeyboardState newState = Keyboard.GetState(); if (newState.IsKeyDown(Keys.Right)) { aviao.direita(); } if (newState.IsKeyDown(Keys.Left)) { aviao.esquerda(); } if (newState.IsKeyDown(Keys.Up)) { aviao.frente(); } if (newState.IsKeyDown(Keys.Down)) { aviao.tras(); } if ((newState.IsKeyDown(Keys.Space)) && (!tiroPreparado) && (tempoTiro <= 0)) { tiroPreparado = true; tiro = aviao.atirar(gt); if (tiro != null) { tiro.Disparar(); } tiroPreparado = false; tempoTiro = 30; //tempoTiro = 100; } if ((newState.IsKeyUp(Keys.Space)) && (tiroPreparado)) { /*tiro = aviao.atirar(); * tiro.Disparar(); * gt.Add(tiro); * soundBank.PlayCue("Explosion"); * tiroPreparado = false; * tempoTiro = 10;*/ } if (newState.IsKeyDown(Keys.Escape)) { this.Exit(); } }
public GerenciadorTiro() { lista = new List <Tiro>(numTiros); for (int i = 0; i < numTiros; i++) { Tiro t = new Tiro(0, 0); lista.Add(t); } }
public Tiro atirar(GerenciadorTiro gt) { Tiro t = gt.getTiro(); if (t != null) { t.pos = this.pos; t.pos.X += 10; t.pos.Y += 5; t.Disparar(); } return(t); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here aviao = new Aviao(); tiro = null; obstaculo = null; tiroPreparado = false; tempoTiro = 0; gt = new GerenciadorTiro(); go = new GerenciadorObstaculo(); rnd = new Random(); IsMouseVisible = true; posbutton = new Rectangle(250, 400, 300, 100); posButton2 = new Rectangle(250, 200, 300, 100); posButton3 = new Rectangle(250, 300, 300, 100); base.Initialize(); }
public static void draw(Tiro tiro, SpriteBatch spriteBatch, Texture2D texture) { Rectangle r = new Rectangle((int)tiro.pos.X, (int)tiro.pos.Y, tiro.largura, tiro.altura); spriteBatch.Draw(texture, r, Color.White); }
public void Add(Tiro t) { lista.Add(t); }