public PainterGameWorld() { //create objects backround = new SpriteGameObject("spr_background"); cannonBarrel = new RotatableSpriteObject("spr_cannon_barrel"); cannonBarrel.Position = new Vector2(74, 404); cannonBarrel.Origin = new Vector2(34, 34); scoreBoard = new SpriteGameObject("spr_scorebar"); livesSprites = new GameObjectList(); livesSprites.Position = new Vector2(0, 16); ball = new Ball(); cannonColor = new ThreeColorGameObject("spr_cannon_red", "spr_cannon_green", "spr_cannon_blue"); cannonColor.Position = new Vector2(58, 388); //start waarde geven om error te voorkomen. cannonColor.Color = Color.Blue; can1 = new PaintCan(450f, Color.Red); can2 = new PaintCan(575f, Color.Green); can3 = new PaintCan(700f, Color.Blue); scoreText = new TextGameObject("GameFont"); scoreText.Position = new Vector2(8, 8); //add objects this.Add(backround); this.Add(cannonBarrel); this.Add(cannonColor); this.Add(can1); this.Add(can2); this.Add(can3); this.Add(scoreBoard); this.Add(scoreText); this.Add(ball); //give values this.score = 0; scoreText.Text = "Score: " + "0"; this.lives = 5; this.maxLives = lives; for (int lifeNr = 0; lifeNr < maxLives; lifeNr++) { SpriteGameObject life = new SpriteGameObject("spr_lives", 0, lifeNr.ToString()); life.Position = new Vector2(lifeNr * life.BoundingBox.Width, 30); livesSprites.Add(life); } this.Add(livesSprites); }
public void Shoot(InputHelper inputhelper, ThreeColorGameObject cannonColor, RotatableSpriteObject cannonBarrel) { Shooting = true; Color = cannonColor.Color; velocity = (inputhelper.MousePosition - cannonColor.GlobalPosition) * 1.2f; float opp = (float)Math.Sin(cannonBarrel.Angle) * cannonBarrel.Width * 0.6f; float adj = (float)Math.Cos(cannonBarrel.Angle) * cannonBarrel.Width * 0.6f; position = cannonColor.Position + new Vector2(adj, opp) + new Vector2(3, 3); visible = true; //Painter.AssetManager.PlaySound("snd_shoot_paint"); }