Esempio n. 1
0
        // Constructor
        //-------------------------------------
        public Tank(Rectangle pos, int countFrameX, float timePerFrame, Keys right, Keys left, Keys up, Keys down, Keys shoot, GraphicsDevice graphicsDevice)
        {
            this.graphicsDevice = graphicsDevice;
            standLeft           = new BasicSprite(pos);
            standRight          = new BasicSprite(pos);

            moveRight = new BasicAnimatedSprite(pos, countFrameX, timePerFrame);
            moveLeft  = new BasicAnimatedSprite(pos, countFrameX, timePerFrame);


            fusilLeft  = new Rotacion();
            fusilRight = new Rotacion();



            abajo = new BasicSprite(new Rectangle(pos.X, pos.Height - 17, pos.Width - 22, 14));
            medio = new BasicSprite(new Rectangle(pos.X, pos.Height - 37, pos.Width + 15, 14));

            flecha = new BasicSprite(new Rectangle(0, 0, 30, 30));

            this.left  = left;
            this.right = right;
            this.up    = up;
            this.down  = down;
            this.shoot = shoot;
            this.Pos   = pos;
        }
 public Scene2(BasicFile the_file) : base(the_file)
 {
     BasicSprite.SetBoundaries(new Viewport(new Rectangle(0, 0, width, height)));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(true, 2));
     the_enemies.Add(new Enemy(true, 2));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(true, 2.5));
     the_enemies.Add(new Enemy(true, 2.5));
     the_enemies.Add(new Enemy(true, 2.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_enemies.Add(new Enemy(false, 1.5));
     the_boxes.Add(new Box(new Rectangle(1702, 390, 90, 90), Color.SaddleBrown));
     the_boxes.Add(new Box(new Rectangle(1702, 500, 90, 90), Color.SaddleBrown));
     the_boxes.Add(new Box(new Rectangle(292, 808, 90, 90), Color.SaddleBrown));
     the_boxes.Add(new Box(new Rectangle(292, 908, 90, 90), Color.SaddleBrown));
 }
Esempio n. 3
0
        protected bool Out     = false;    // Boolean in order to indicate if the user decides to exit

        //Constructor
        //-----------------------------------------------
        public Menu(GraphicsDevice graphicsDevice)
        {
            botonJugar = new BasicSprite(new Rectangle((graphicsDevice.Viewport.Width / 2) - 30, graphicsDevice.Viewport.Height / 2, 90, 60));
            botonSalir = new BasicSprite(new Rectangle((graphicsDevice.Viewport.Width / 2 - 30), graphicsDevice.Viewport.Height / 2 + 90, 90, 60));
            FondoMenu  = new Background(new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height));
            Cursor     = new BasicSprite(new Rectangle(0, 0, 15, 15));
        }
 public HUD(Vector2 pos, double time)
 {
     this.pos  = pos;
     this.time = time;
     SetText(prefix + time.ToString("0.00") + "         Progreso:" + porcentaje + "%", Color.Black);
     timeBackground = new BasicSprite(new Rectangle((int)pos.X, (int)pos.Y, 200, 50), Color.White);
     progressBar    = new BasicSprite(new Rectangle((int)pos.X + 200, (int)pos.Y, 200, 50), Color.White);
     fillingBar     = new BasicSprite(new Rectangle((int)pos.X + 200, (int)pos.Y, 2 * (int)porcentaje, 50), Color.LightGreen);
 }
Esempio n. 5
0
        float grados = 10;             // angle of the shot as units

        // Constructor
        //-----------------------------------------------------
        public Shot(int x, int y, bool lado, float velocidad, float angulo)
        {
            estado     = Estate.NORMAL;
            bullet     = new BasicSprite(new Rectangle(x, y, 12, 12));
            fire       = new SingleShot(new Rectangle(x, y, 20, 20), false, 16, 1, 64, 64, 0.04f);
            this.lado  = lado;
            this.alpha = MathHelper.ToRadians(angulo); // the angle at which the object is thrown (measured in radians)
            this.vx    = 5 * velocidad * Math.Cos(this.alpha);
            this.vy    = 5 * velocidad * Math.Sin(this.alpha);
        }
Esempio n. 6
0
        public bool CollidingWithTrans(double xVal, double yVal, double characterWidth, double characterHeight)
        {
            //Console.WriteLine("window sizes " + BasicSprite.GetBoundaries().Width + " " + BasicSprite.GetBoundaries().Height);
            //Console.WriteLine("texture sizes " + trans.GetWidth() + " " + trans.GetHeight());
            double width_factor  = (double)BasicSprite.GetBoundaries().Width / trans.GetWidth();
            double height_factor = (double)BasicSprite.GetBoundaries().Height / trans.GetHeight();

            //Console.WriteLine("orig vals: " + xVal + " " + yVal); Console.WriteLine("orig vals: " + xVal + " " + yVal);
            xVal /= width_factor;
            yVal /= height_factor;
            //Console.WriteLine("new vals: " + xVal + " " + yVal);
            //Console.WriteLine("orig sizes: " + characterWidth + " " + characterHeight);
            characterWidth  /= width_factor;
            characterHeight /= height_factor;
            //Console.WriteLine("new sizes: " + characterWidth + " " + characterHeight);
            Color col1, col2, col3, col4, col5, col6, col7, col8;
            int   xTex, yTex;

            ///left point
            xTex = (int)xVal;
            yTex = (int)yVal;
            col1 = overData[yTex * trans.GetWidth() + xTex];
            ///right point
            xTex = (int)(xVal + characterWidth);
            yTex = (int)yVal;
            col2 = overData[yTex * trans.GetWidth() + xTex];
            ///down left point
            xTex = (int)xVal;
            yTex = (int)(yVal + characterHeight);
            col3 = overData[yTex * trans.GetWidth() + xTex];
            ///down right point
            xTex = (int)(xVal + characterWidth);
            yTex = (int)(yVal + characterHeight);
            col4 = overData[yTex * trans.GetWidth() + xTex];
            ///up center
            xTex = (int)(xVal + characterWidth / 2);
            yTex = (int)yVal;
            col5 = overData[yTex * trans.GetWidth() + xTex];
            //left center
            xTex = (int)xVal;
            yTex = (int)(yVal + characterHeight / 2);
            col6 = overData[yTex * trans.GetWidth() + xTex];
            ///down center
            xTex = (int)(xVal + characterWidth / 2);
            yTex = (int)(yVal + characterHeight);
            col7 = overData[yTex * trans.GetWidth() + xTex];
            ///right center
            xTex = (int)(xVal + characterWidth);
            yTex = (int)(yVal + characterHeight / 2);
            col8 = overData[yTex * trans.GetWidth() + xTex];
            //Console.WriteLine("cols " + col1+" "+col2+" "+col3+" "+col4+" "+col5+" "+col6+" "+col7+" "+col8);
            return(col1.A != 0 && col2.A != 0 && col3.A != 0 && col4.A != 0 && col5.A != 0 && col6.A != 0 && col7.A != 0 && col8.A != 0); /// alpha in trans is differente from zero
        }
Esempio n. 7
0
 public void LoadContent(ContentManager Content, string filenameTrans, string filenameNoTrans, string filenameStetic, Color color)
 {
     trans   = new BasicSprite(Rectangle.Empty, color);
     notrans = new BasicSprite(Rectangle.Empty, color);
     stetic  = new BasicSprite(Rectangle.Empty, color);
     stetic.LoadContent(Content, filenameStetic);
     trans.LoadContent(Content, filenameTrans);
     overData = new Color[trans.GetWidth() * trans.GetHeight()];
     notrans.LoadContent(Content, filenameNoTrans);
     trans.GetData(overData);
     trans.setPos(new Rectangle(0, 0, trans.GetTexture().Width, trans.GetTexture().Height));
     notrans.setPos(new Rectangle(0, 0, notrans.GetTexture().Width, notrans.GetTexture().Height));
     //Console.WriteLine("trans pos"+trans.getPos());
 }
 public Scene1(BasicFile the_file) : base(the_file)
 {
     the_enemies.Add(new Enemy(true, 2.5));
     the_enemies.Add(new Enemy(false, 2.5));
     the_enemies.Add(new Enemy(true, 2.5));
     the_enemies.Add(new Enemy(false, 2.5));
     the_enemies.Add(new Enemy(true, 2.5));
     the_enemies.Add(new Enemy(false, 2.5));
     the_enemies.Add(new Enemy(true, 2.5));
     the_enemies.Add(new Enemy(false, 2.5));
     the_enemies.Add(new Enemy(true, 2.5));
     the_enemies.Add(new Enemy(false, 2.5));
     the_boxes.Add(new Box(new Rectangle(100, 300, boxSide, boxSide), Color.White));  ///left box
     the_boxes.Add(new Box(new Rectangle(1900, 300, boxSide, boxSide), Color.White)); ///right box
     the_boxes.Add(new Box(new Rectangle(900, 100, boxSide, boxSide), Color.White));  ///up box
     the_boxes.Add(new Box(new Rectangle(900, 1500, boxSide, boxSide), Color.White)); ///down box
     BasicSprite.SetBoundaries(new Viewport(new Rectangle(0, 0, 2100, 1620)));
 }
Esempio n. 9
0
        public Scene3(BasicFile the_file) : base(the_file)
        {
            int widthSectionSize = width / 9;

            the_buttons.Add(new Button(new Rectangle(widthSectionSize - buttonWidth / 2, 0, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize - buttonWidth / 2, height / 2 - buttonHeight / 2, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize - buttonWidth / 2, height - buttonHeight, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize * 3 - buttonWidth / 2, 0, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize * 3 - buttonWidth / 2, height / 2 - buttonHeight / 2, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize * 3 - buttonWidth / 2, height - buttonHeight, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize * 5 - buttonWidth / 2, 0, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize * 5 - buttonWidth / 2, height / 2 - buttonHeight / 2, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize * 5 - buttonWidth / 2, height - buttonHeight, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize * 7 - buttonWidth / 2, 0, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize * 7 - buttonWidth / 2, height / 2 - buttonHeight / 2, buttonWidth, buttonHeight)));
            the_buttons.Add(new Button(new Rectangle(widthSectionSize * 7 - buttonWidth / 2, height - buttonHeight, buttonWidth, buttonHeight)));
            BasicSprite.SetBoundaries(new Viewport(new Rectangle(0, 0, 2100, 1620)));
        }
Esempio n. 10
0
        /// <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

            BasicSprite.SetBoundaries(new Viewport(new Rectangle(0, 0, 2100, 1620)));
            graphics.PreferredBackBufferWidth  = windowWidth;
            graphics.PreferredBackBufferHeight = windowHeight;
            graphics.ApplyChanges();
            Scene.setViewport(GraphicsDevice.Viewport);
            BasicGUIButton.SetLimitForNextPressing(0.1);
            the_menu = new Menu(the_file);
            //scene2 = new Scene2();
            //the_game_over_menu = new GameOver();
            //scene1 = new Scene1();
            //scene2 = new Scene2();
            //scene3 = new Scene3();
            //graphics.PreferredBackBufferHeight =253 ;
            //graphics.PreferredBackBufferWidth = 320;
            //graphics.ApplyChanges();
            base.Initialize();
        }
Esempio n. 11
0
 public bool InsideRightLimit(Rectangle pos)
 {
     //Console.WriteLine("character pos: "+pos+" basic sprite right limit " + BasicSprite.GetBoundaries().Width + BasicSprite.GetBoundaries().X+" bool " + (pos.X + pos.Width < BasicSprite.GetBoundaries().Width + BasicSprite.GetBoundaries().X));
     return(pos.X + pos.Width < BasicSprite.GetBoundaries().Width + BasicSprite.GetBoundaries().X);
 }
Esempio n. 12
0
 public bool InsideLeftLimit(Rectangle pos)
 {
     //Console.WriteLine("character pos: " + pos + " basic sprite left limit " + BasicSprite.GetBoundaries().X+" bool " + (pos.X > BasicSprite.GetBoundaries().Y));
     return(pos.X > BasicSprite.GetBoundaries().X);
 }
Esempio n. 13
0
 public bool InsideUpLimit(Rectangle pos)
 {
     //Console.WriteLine("character pos: " + pos + " basic sprite up limit " + BasicSprite.GetBoundaries().Y+" bool "+ (pos.Y > BasicSprite.GetBoundaries().Y));
     return(pos.Y > BasicSprite.GetBoundaries().Y);
 }
Esempio n. 14
0
 public bool InsideDownLimit(Rectangle pos)
 {
     return(pos.Y + pos.Height < BasicSprite.GetBoundaries().Height + BasicSprite.GetBoundaries().Y);
 }
 public BasicMenu(BasicFile the_file)
 {
     this.the_file = the_file;
     background = new BasicSprite(new Rectangle(Scene.GetViewport().X,Scene.GetViewport().Y,Scene.GetViewport().Width,Scene.GetViewport().Height), Color.White);
 }
Esempio n. 16
0
 public BasicMap(int x, int y, int width, int height, Color color)
 {
     trans   = new BasicSprite(new Rectangle(x, y, width, height), color);
     notrans = new BasicSprite(new Rectangle(x, y, width, height), color);
 }
Esempio n. 17
0
 public BasicMap(Viewport viewport, Color color)
 {
     trans   = new BasicSprite(new Rectangle(viewport.X, viewport.Y, viewport.Width, viewport.Height), color);
     notrans = new BasicSprite(new Rectangle(viewport.X, viewport.Y, viewport.Width, viewport.Height), color);
 }