public override void Init()
        {
            //Crear Sprite animado
            animatedSprite = new TgcAnimatedSprite(MediaDir + "\\Texturas\\Sprites\\Explosion.png", //Textura de 256x256
                                                   new Size(64, 64),                                //Tamaño de un frame (64x64px en este caso)
                                                   16,                                              //Cantidad de frames, (son 16 de 64x64px)
                                                   10                                               //Velocidad de animacion, en cuadros x segundo
                                                   );

            //Ubicarlo centrado en la pantalla
            var textureSize = animatedSprite.Sprite.Texture.Size;

            animatedSprite.Position = new Vector2(D3DDevice.Instance.Width / 2 - textureSize.Width / 2,
                                                  D3DDevice.Instance.Height / 2 - textureSize.Height / 2);

            //Modifiers para variar parametros del sprite
            Modifiers.addFloat("frameRate", 1, 30, 10);
            Modifiers.addVertex2f("position", new Vector2(0, 0),
                                  new Vector2(D3DDevice.Instance.Width, D3DDevice.Instance.Height), animatedSprite.Position);
            Modifiers.addVertex2f("scaling", new Vector2(0, 0), new Vector2(4, 4), animatedSprite.Scaling);
            Modifiers.addFloat("rotation", 0, 360, 0);

            //Creamos un Box3D para que se vea como el Sprite es en 2D y se dibuja siempre arriba de la escena 3D
            box = TgcBox.fromSize(new Vector3(10, 10, 10), TgcTexture.createTexture(MediaDir + "\\Texturas\\pasto.jpg"));

            //Hacer que la camara se centre en el box3D
            Camara = new TgcRotationalCamera(box.BoundingBox.calculateBoxCenter(),
                                             box.BoundingBox.calculateBoxRadius() * 2);
        }
Example #2
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Crear Sprite animado
            animatedSprite = new TgcAnimatedSprite(
                GuiController.Instance.ExamplesMediaDir + "\\Texturas\\Sprites\\Explosion.png", //Textura de 256x256
                new Size(64, 64),                                                               //Tamaño de un frame (64x64px en este caso)
                16,                                                                             //Cantidad de frames, (son 16 de 64x64px)
                10                                                                              //Velocidad de animacion, en cuadros x segundo
                );

            //Ubicarlo centrado en la pantalla
            Size screenSize  = GuiController.Instance.Panel3d.Size;
            Size textureSize = animatedSprite.Sprite.Texture.Size;

            animatedSprite.Position = new Vector2(screenSize.Width / 2 - textureSize.Width / 2, screenSize.Height / 2 - textureSize.Height / 2);

            //Modifiers para variar parametros del sprite
            GuiController.Instance.Modifiers.addFloat("frameRate", 1, 30, 10);
            GuiController.Instance.Modifiers.addVertex2f("position", new Vector2(0, 0), new Vector2(screenSize.Width, screenSize.Height), animatedSprite.Position);
            GuiController.Instance.Modifiers.addVertex2f("scaling", new Vector2(0, 0), new Vector2(4, 4), animatedSprite.Scaling);
            GuiController.Instance.Modifiers.addFloat("rotation", 0, 360, 0);


            //Creamos un Box3D para que se vea como el Sprite es en 2D y se dibuja siempre arriba de la escena 3D
            box = TgcBox.fromSize(new Vector3(10, 10, 10), TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "\\Texturas\\pasto.jpg"));

            //Hacer que la camara se centre en el box3D
            GuiController.Instance.RotCamera.targetObject(box.BoundingBox);
        }
Example #3
0
        public static void renderExplosion(TgcAnimatedSprite animatedSprite, Vector3 pos3D)
        {
            float   x     = pos3D.X / pos3D.Z;
            float   y     = pos3D.Y / pos3D.Z;
            Vector2 pos2D = new Vector2(x, y);

            GuiController.Instance.Drawer2D.beginDrawSprite();
            animatedSprite.Position = pos2D;
            animatedSprite.updateAndRender();
            GuiController.Instance.Drawer2D.endDrawSprite();
        }
Example #4
0
            public static void Cargar()
            {
                SpriteDrawer = new Drawer2D();

                AnimatedSprite          = new TgcAnimatedSprite(Utiles.TexturasDir("moneda_sprite.png"), new Size(32, 32), 16, 10);
                AnimatedSprite.Position = new Vector2(GuiController.Instance.Panel3d.Width - 32 * 2, 0);

                Puntos2d          = new TgcText2d();
                Puntos2d.Text     = Puntos.ToString();
                Puntos2d.Color    = Color.Yellow;
                Puntos2d.Align    = TgcText2d.TextAlign.RIGHT;
                Puntos2d.Position = new Point(GuiController.Instance.Panel3d.Width - 32, 0);
                Puntos2d.Size     = new Size(30, 20);
                Puntos2d.changeFont(new System.Drawing.Font("Sans-serif ", 15, FontStyle.Bold));
            }
Example #5
0
        public static TgcAnimatedSprite crearExplosion()
        {
            //Crear Sprite animado
            TgcAnimatedSprite animatedSprite = new TgcAnimatedSprite(
                GuiController.Instance.ExamplesMediaDir + "\\Texturas\\Sprites\\Explosion.png", //Textura de 256x256
                new Size(64, 64),                                                               //Tamaño de un frame (64x64px en este caso)
                16,                                                                             //Cantidad de frames, (son 16 de 64x64px)
                10                                                                              //Velocidad de animacion, en cuadros x segundo
                );

            animatedSprite.setFrameRate(10);
            animatedSprite.Scaling  = new Vector2(1, 1);
            animatedSprite.Rotation = 0;
            //animatedSprite.Position = posicion;
            return(animatedSprite);
        }
Example #6
0
        private void crearSprites()
        {
            boton1         = new TgcSprite();
            boton1.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\boton.png");
            Size textureSize = boton1.Texture.Size;

            boton1.Position = new Vector2(screenSize.Width - textureSize.Width, screenSize.Height - textureSize.Height);

            boton2          = new TgcSprite();
            boton2.Texture  = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\boton2.png");
            textureSize     = boton2.Texture.Size;
            boton2.Position = new Vector2((screenSize.Width - boton1.Texture.Size.Width) - textureSize.Width, screenSize.Height - textureSize.Height);

            timon          = new TgcSprite();
            timon.Texture  = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\timon.png");
            textureSize    = timon.Texture.Size;
            timon.Position = new Vector2(0, screenSize.Height - textureSize.Height);

            barra          = new TgcSprite();
            barra.Texture  = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\barra.png");
            textureSize    = barra.Texture.Size;
            barra.Position = new Vector2(0, screenSize.Height - textureSize.Height);

            //Crear Sprite animado para la lluvia
            animatedSprite = new TgcAnimatedSprite(
                GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\LLUVIA2.png", //Textura de 512 X 512
                new Size(128, 128),                                                                   //Tamaño de un frame (128x128px en este caso)
                16,                                                                                   //Cantidad de frames, (son 16 de 128x128px)
                20                                                                                    //Velocidad de animacion, en cuadros x segundo
                );

            animatedSprite.Position = new Vector2(-10, 0);
            animatedSprite.Scaling  = new Vector2(8, 4);

            //Crear Sprite animado para la gaviota
            animatedSprite2 = new TgcAnimatedSprite(
                GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\gaviotas2.png", //Textura de 1024 X 1024
                new Size(256, 256),                                                                     //Tamaño de un frame (128x128px en este caso)
                16,                                                                                     //Cantidad de frames, (son 16 de 128x128px)
                1                                                                                       //Velocidad de animacion, en cuadros x segundo
                );
        }
Example #7
0
        public void crearExplosion(Vector3 posicion3D)
        {
            float x = 450; // posicion3D.X / posicion3D.Z;
            float y = 200; // posicion3D.Y / posicion3D.Z;

            Vector2 posicion2D = new Vector2(x, y);

            //Crear Sprite animado
            animatedSprite = new TgcAnimatedSprite(
                GuiController.Instance.ExamplesMediaDir + "\\Texturas\\Sprites\\Explosion.png", //Textura de 256x256
                new Size(64, 64),                                                               //Tamaño de un frame (64x64px en este caso)
                16,                                                                             //Cantidad de frames, (son 16 de 64x64px)
                10                                                                              //Velocidad de animacion, en cuadros x segundo
                );

            animatedSprite.setFrameRate(10);
            animatedSprite.Scaling  = new Vector2(1, 1);
            animatedSprite.Rotation = 0;
            animatedSprite.Position = posicion2D;
        }
Example #8
0
        public Escenario(Barco barco)
        {
            {
                d3dDevice = GuiController.Instance.D3dDevice;

                //Asignar barco del usuario
                barcoUser = barco;

                crearSkyBoxNoche();
                crearTerreno();
                crearSonido();
                cargarMeshes();
                cargarShader();
                cargarShadowMap();
                Camara.initialize();
                cargarPreview();
                Lluvia.cargar(barcoUser.getPosition());
                ContadorEnemigos.cargar();
                animatedSprite = Utiles.crearExplosion();
                crearQuadtree();
            }
        }
Example #9
0
        private void coordenadasMouse() //se fija si hace clic sobre un boton
        {
            TgcD3dInput d3dInput = GuiController.Instance.D3dInput;
            //Obtener variacion XY del mouse
            float mouseX = 0f;
            float mouseY = 0f;
            float botonX = boton1.Position.X + boton1.Texture.Width;
            float botonY = boton1.Position.Y + boton1.Texture.Height;

            float boton2X = boton2.Position.X + boton2.Texture.Width;
            float boton2Y = boton2.Position.Y + boton2.Texture.Height;

            if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT))
            {
                mouseX = d3dInput.Xpos; // XposRelative;
                mouseY = d3dInput.Ypos; // YposRelative;

                if ((mouseX > boton1.Position.X) && (mouseX < botonX) && (mouseY > boton1.Position.Y) && (mouseY < botonY))
                {
                    oceano.rayo = true;
                    //MessageBox.Show("CLIC EN SPRITE CUADRADO DERECHO");
                }
                if ((mouseX > boton2.Position.X) && (mouseX < boton2X) && (mouseY > boton2.Position.Y) && (mouseY < boton2Y))
                {
                    traslacion = -150;
                    //Crear Sprite animado para la gaviota
                    animatedSprite2 = new TgcAnimatedSprite(
                        GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\gaviotas2.png", //Textura de 1024 X 1024
                        new Size(256, 256),                                                                     //Tamaño de un frame (128x128px en este caso)
                        16,                                                                                     //Cantidad de frames, (son 16 de 128x128px)
                        1                                                                                       //Velocidad de animacion, en cuadros x segundo
                        );
                    //MessageBox.Show("CLIC EN SPRITE CUADRADO IZQUIERDO");
                }
            }
        }