public override void Update(GameTime gameTime) { base.Update(gameTime); _bat.Velocity.X = 0; //TODO : Touch controls if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Left, Keys.A }) && _bat.X > 10) { _bat.Velocity.X = -BAT_SPEED; } else if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Right, Keys.D }) && _bat.X < 270) { _bat.Velocity.X = BAT_SPEED; } if (FlxG.Keyboard.JustReleased(Keys.R)) { FlxG.ResetState(); } if (_bat.X < 10) { _bat.X = 10; } if (_bat.X > 270) { _bat.X = 270; } FlxG.Collide(_ball, _walls); FlxG.Collide(_bat, _ball, Ping); FlxG.Collide(_ball, _bricks, Hit); }
public override void Update(GameTime gameTime) { if (FlxG.Keyboard.Pressed(Keys.W)) { spriteA.Y -= 1; } if (FlxG.Keyboard.Pressed(Keys.S)) { spriteA.Y += 1; } if (FlxG.Keyboard.Pressed(Keys.A)) { spriteA.X -= 1; } if (FlxG.Keyboard.Pressed(Keys.D)) { spriteA.X += 1; } if (FlxG.Keyboard.Pressed(Keys.Q)) { spriteA.Angle -= 1; } if (FlxG.Keyboard.Pressed(Keys.E)) { spriteA.Angle += 1; } if (FlxG.Keyboard.Pressed(Keys.Up)) { //spriteB.Y -= 1; FlxG.Camera.Y -= 1; } if (FlxG.Keyboard.Pressed(Keys.Down)) { //spriteB.Y += 1; FlxG.Camera.Y += 1; } if (FlxG.Keyboard.Pressed(Keys.Left)) { //spriteB.X -= 1; FlxG.Camera.X -= 1; } if (FlxG.Keyboard.Pressed(Keys.Right)) { //spriteB.X += 1; FlxG.Camera.X += 1; } if (FlxG.Keyboard.Pressed(Keys.O)) { //spriteB.Angle -= 1; FlxG.Camera.Rotation -= MathHelper.ToRadians(1); } if (FlxG.Keyboard.Pressed(Keys.P)) { //spriteB.Angle += 1; FlxG.Camera.Rotation += MathHelper.ToRadians(1); } text1.Text = $"1 spriteA :{spriteA.Position} Renderposition {spriteA.RenderPosition}"; text2.Text = $"2 camera :{FlxG.Camera.Position} rotation :{FlxG.Camera.Rotation} viewoffset {FlxG.Camera.ViewOffset}"; bool intersects = spriteA.BoundingBox.Intersects(spriteB.BoundingBox); //bool collision = flxg.pixelperfectoverlap(spritea, spriteb); bool collision = FlxG.Collide(spriteA, spriteB); if (collision) { spriteA.Color = Color.Red; } else { spriteA.Color = Color.White; } text3.Text = $"3 intersects: {intersects} collision : {collision}"; text4.Text = $"4 Mouse : {FlxG.Mouse.Position} ScreenPos : {FlxG.Mouse.ScreenPosition}"; base.Update(gameTime); }