public void Shoot(InputHelper inputHelper, ThreeColorGameObject cannonColor, RotatableSpriteGameObject 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");
        }
Exemple #2
0
        public void Shoot(InputHelper inputHelper,
                          ThreeColorGameObject cannonColor,
                          RotatableSpriteGameObject 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");
        }
        public GameWorld()
        {
            background            = new SpriteGameObject("spr_background");
            cannonBarrel          = new RotatableSpriteGameObject("spr_cannon_barrel");
            cannonBarrel.Position = new Vector2(74, 404);
            cannonBarrel.Origin   = new Vector2(34, 34);

            cannonColor          = new ThreeColorGameObject("spr_cannon_red", "spr_cannon_green", "spr_cannon_blue");
            cannonColor.Position = new Vector2(58, 388);

            paintCan1 = new PaintCan(450, Color.Red);
            paintCan2 = new PaintCan(575, Color.Green);
            paintCan3 = new PaintCan(700, Color.Blue);

            scorebar = new SpriteGameObject("spr_scorebar");

            ball = new Ball();

            scoreText = new TextGameObject("GameFont");

            livesObjectList = new GameObjectList();

            for (int i = 0; i < maxLives; i++)
            {
                newLive          = new SpriteGameObject("spr_lives", 0, i.ToString());
                newLive.Position = new Vector2(i * newLive.BoundingBox.Width, 50);
                livesObjectList.Add(newLive);
            }

            this.Add(background);
            this.Add(cannonBarrel);
            this.Add(cannonColor);

            this.Add(paintCan1);
            this.Add(paintCan2);
            this.Add(paintCan3);

            this.Add(ball);

            this.Add(scorebar);

            this.Score = 0;
            this.lives = maxLives;


            this.Add(livesObjectList);

            this.Add(scoreText);
        }
        public Cannon()
            : base()
        {
            cannonBarrel = new RotatableSpriteGameObject("spr_cannon_barrel");
            cannonBarrel.Position = new Vector2(74, 404);
            cannonBarrel.Origin = new Vector2(34, 34);

            cannonColor = new ThreeColorGameObject("spr_cannon_red", "spr_cannon_green", "spr_cannon_blue");
            cannonColor.Position = new Vector2(50, 398);

            ball = new Ball();

            Add(ball);
            Add(cannonBarrel);
            Add(cannonColor);
        }
Exemple #5
0
        public PainterGameWorld()
        {
            cannonBarrel          = new RotatableSpriteGameObject("spr_cannon_barrel");
            cannonBarrel.Position = new Vector2(74, 404);
            cannonBarrel.Origin   = new Vector2(34, 34);

            cannonColor          = new ThreeColorGameObject("spr_cannon_red", "spr_cannon_green", "spr_cannon_blue");
            cannonColor.Position = new Vector2(58, 388);

            can1 = new PaintCan(Color.Red, 450f);
            can2 = new PaintCan(Color.Green, 575f);
            can3 = new PaintCan(Color.Blue, 700f);

            ball = new Ball();

            scoreText          = new TextGameObject("GameFont");
            scoreText.Text     = "Score: 0";
            scoreText.Position = new Vector2(24, 6);
            SpriteGameObject scoreBar = new SpriteGameObject("spr_scorebar");

            livesSprites = new GameObjectList();
            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.score = 0;
            this.lives = maxLives;

            this.Add(new SpriteGameObject("spr_background"));
            this.Add(cannonBarrel);
            this.Add(cannonColor);
            this.Add(can1);
            this.Add(can2);
            this.Add(can3);
            this.Add(ball);
            this.Add(scoreBar);
            this.Add(scoreText);
            this.Add(livesSprites);
        }
        public PainterGameWorld()
        {
            background = new SpriteGameObject("spr_background");
            scoreBar   = new SpriteGameObject("spr_scorebar");
            // sgo = new SpriteGameObject("spr_lives");
            cannonBarrel          = new RotatableSpriteGameObject("spr_cannon_barrel");
            cannonBarrel.Position = new Vector2(74, 404);
            cannonBarrel.Origin   = new Vector2(34, 34);
            cannonColor           = new ThreeColorGameObject("spr_cannon_red", "spr_cannon_green", "spr_cannon_blue");
            cannonColor.Position  = new Vector2(52, 398);

            ball                  = new Ball();
            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);
            livesSprites          = new GameObjectList();
            livesSprites.Position = new Vector2(0, 16);

            this.Add(background);
            this.Add(cannonBarrel);
            this.Add(cannonColor);
            this.Add(can1);
            this.Add(can2);
            this.Add(can3);
            this.Add(ball);
            this.Score = 0;
            this.lives = 5;
            this.Add(scoreBar);
            // this.Add(sgo);
            this.maxLives = lives;
            this.Add(scoreText);
            this.Add(livesSprites);
            cannonColor.Color = Color.Blue;
            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);
            }
        }