Пример #1
0
        public void SetGetError()
        {
            string error = "Hi there";

            SdlImage.IMG_SetError(error);
            Assert.AreEqual(SdlImage.IMG_GetError(), error);
        }
Пример #2
0
 public Fondo()
 {
     ancho  = 2000;
     alto   = 600;
     imagen = SdlImage.IMG_Load("img/BG.png");
     x      = -600;
     y      = 0;
 }
Пример #3
0
        public void isBMP()
        {
            string file = "test.bmp";

            Assert.IsFalse(SdlImage.IMG_isBMP(Sdl.SDL_RWFromFile(file, "rb")) == IntPtr.Zero);
            Assert.AreEqual(SdlImage.IMG_isBMP(Sdl.SDL_RWFromFile("test.jpg", "rb")), IntPtr.Zero);
            this.Quit();
        }
Пример #4
0
 public void Load(string fileName)
 {
     ImagePtr = SdlImage.IMG_Load(fileName);
     if (ImagePtr == IntPtr.Zero)
     {
         Hardware.FatalError("Image not found: " + fileName);
     }
 }
Пример #5
0
 public void Load(string fileName)
 {
     internalPointer = SdlImage.IMG_Load(fileName);
     if (internalPointer == IntPtr.Zero)
     {
         SdlHardware.FatalError("Image not found: " + fileName);
     }
 }
Пример #6
0
 public Menu()
 {
     ancho  = 800;
     alto   = 600;
     imagen = SdlImage.IMG_Load("img/BG.png");
     x      = 0;
     y      = 0;
 }
Пример #7
0
 public Bloque()
 {
     seccion[0] = SdlImage.IMG_Load("img/Bloque1.png");
     seccion[1] = SdlImage.IMG_Load("img/Bloque2.png");
     seccion[2] = SdlImage.IMG_Load("img/Bloque3.png");
     seccion[3] = SdlImage.IMG_Load("img/Bloque4.png");
     suelo      = true;
     ancho      = 128;
     alto       = 128;
     y          = 470;
 }
Пример #8
0
 public Image(string fileName, short width, short height)
 {
     ImagePtr = SdlImage.IMG_Load(fileName);
     if (ImagePtr == IntPtr.Zero)
     {
         Console.WriteLine("Image not found");
         Environment.Exit(1);
     }
     ImageWidth  = width;
     ImageHeight = height;
 }
Пример #9
0
 public Sprite(string nombreFichero, short ancho, short alto)
 {
     imagen = SdlImage.IMG_Load(nombreFichero);
     if (imagen == IntPtr.Zero)
     {
         System.Console.WriteLine("Imagen inexistente");
         Environment.Exit(1);
     }
     this.ancho = ancho;
     this.alto  = alto;
 }
Пример #10
0
        public void load(ResourceComponent rc, string path)
        {
            IntPtr surf = SdlImage.IMG_Load(path);

            if (surf == IntPtr.Zero)
            {
                throw new Exception("Error: failed to load resource at " + path + ": " + Sdl.SDL_GetError());
            }

            initFromSurface(surf);
        }
Пример #11
0
        public Texture2D(string path)
        {
            IntPtr surf = SdlImage.IMG_Load(path);

            if (surf == IntPtr.Zero)
            {
                throw new Exception("Error: failed to load resource: " + Sdl.SDL_GetError());
            }

            initFromSurface(surf);
        }
Пример #12
0
    public Image(string fileName, short width, short height)
    {
        internalPointer = SdlImage.IMG_Load(fileName);
        if (internalPointer == IntPtr.Zero)
        {
            Console.WriteLine("Image not found");
        }

        this.width  = width;
        this.height = height;
    }
Пример #13
0
    /// Carga una imagen (o sale con codigo de error si no existe)
    public static IntPtr CargarImagen(string fichero)
    {
        IntPtr imagen;

        imagen = SdlImage.IMG_Load(fichero);
        if (imagen == IntPtr.Zero)
        {
            ErrorFatal("Imagen inexistente: " + fichero);
        }
        return(imagen);
    }
Пример #14
0
    public static IntPtr CargarImagen(string fichero)
    {
        IntPtr imagen;

        imagen = SdlImage.IMG_Load(fichero);
        if (imagen == IntPtr.Zero)
        {
            System.Console.WriteLine("Imagen inexistente: {0}", fichero);
            Environment.Exit(4);
        }
        return(imagen);
    }
Пример #15
0
        public void Load()
        {
            string file       = "test.bmp";
            IntPtr surfacePtr = VideoSetup();
            IntPtr imagePtr   = SdlImage.IMG_Load(file);

            Assert.IsFalse(imagePtr == IntPtr.Zero);
            Sdl.SDL_Rect rect1  = new Sdl.SDL_Rect(0, 0, 200, 200);
            Sdl.SDL_Rect rect2  = new Sdl.SDL_Rect(0, 0, 200, 200);
            int          result = Sdl.SDL_BlitSurface(imagePtr, ref rect1, surfacePtr, ref rect2);

            Sdl.SDL_UpdateRect(surfacePtr, 0, 0, 200, 200);
            Thread.Sleep(sleepTime);
            Assert.AreEqual(result, 0);
            this.Quit();
        }
Пример #16
0
        public Personaje()
        {
            ancho = 43;
            alto  = 67;

            x = 100;
            y = 406;

            saltar   = false;
            subiendo = false;

            for (int i = 1; i < 11; i++)
            {
                correr[i - 1] = SdlImage.IMG_Load("img/Walk-" + i + ".png");
            }

            imagen = correr[contador];
            contador++;
        }
Пример #17
0
 public Bonus()
 {
     //Carga de las distintas imágenes de las recompensas
     imgPremio[0] = SdlImage.IMG_Load("img/Jelly1.png");
     imgPremio[1] = SdlImage.IMG_Load("img/Jelly2.png");
     imgPremio[2] = SdlImage.IMG_Load("img/Jelly3.png");
     imgPremio[3] = SdlImage.IMG_Load("img/Jelly4.png");
     imgPremio[4] = SdlImage.IMG_Load("img/Jelly5.png");
     imgPremio[5] = SdlImage.IMG_Load("img/Jelly6.png");
     imgPremio[6] = SdlImage.IMG_Load("img/Bloque4.png");
     imagen       = imgPremio[1];
     ancho        = 35;
     alto         = 35;
     x            = pos;
     //De esta forma evitamos que siempre salgan a la misma altura
     y = Convert.ToInt16(random.Next(280, 380));
     //Así evitamos que se solapen los objetos bonús
     pos += Convert.ToInt16(random.Next(800, 2000));
 }
Пример #18
0
        } //Stuff that goes before load content

        static void Init_LoadContent()
        {
            vera     = SdlTtf.TTF_OpenFont("Content/Fonts/Vera.ttf", 24);                           //Load in 12-point Vera font.
            veraData = (SdlTtf.TTF_Font)Marshal.PtrToStructure(vera, typeof(SdlTtf.TTF_Font));      //Put the font data in its place

            veraSmall     = SdlTtf.TTF_OpenFont("Content/Fonts/Vera.ttf", 10);                      //Load in 12-point Vera font.
            veraSmallData = (SdlTtf.TTF_Font)Marshal.PtrToStructure(vera, typeof(SdlTtf.TTF_Font)); //Put the font data in its place

            DrawText(veraSmall, "Pre-initialization complete", new Point2D(15, 15));
            DrawText(veraSmall, "Fonts loaded; loading images...", new Point2D(15, 30));
            Sdl.SDL_Flip(screen); //Update screen

            IntPtr rwop    = Sdl.SDL_RWFromFile("Content/Tiles/ASCII_Tileset.PNG", "rb");
            IntPtr tileSet = SdlImage.IMG_LoadPNG_RW(rwop);

            short n = 0;

            target.w = source.w = TILEWIDTH;  //I love this combination thing
            target.h = source.h = TILEHEIGHT; //It's so elegant

            for (byte y = 0; y < 16; y++)
            {
                for (byte x = 0; x < 16; x++)                                                                      //16x16 tiles
                {
                    source.x = (short)(x * 17);                                                                    //X to grab from
                    source.y = (short)(y * 17);                                                                    //Y to grab from

                    image[n] = Sdl.SDL_CreateRGBSurface(Sdl.SDL_SWSURFACE, TILEWIDTH, TILEHEIGHT, 32, 0, 0, 0, 0); //Allocate image area
                    Sdl.SDL_BlitSurface(tileSet, ref source, image[n], ref target);
                    image[n]     = Sdl.SDL_DisplayFormatAlpha(image[n]);
                    imageData[n] = (Sdl.SDL_Surface)Marshal.PtrToStructure(image[n], typeof(Sdl.SDL_Surface)); //Put the image data in its place
                    Transparencify(n, Color.Magenta);                                                          //Magenta is the transparent color
                    image[n]     = Sdl.SDL_DisplayFormatAlpha(image[n]);
                    imageData[n] = (Sdl.SDL_Surface)Marshal.PtrToStructure(image[n], typeof(Sdl.SDL_Surface)); //Put the image data in its place
                    n++;
                }
            }

            DrawText(veraSmall, "Creatures loaded. External content loading complete.", new Point2D(15, 120));
            DrawText(veraSmall, "Post-initializing...", new Point2D(15, 135));
            Sdl.SDL_Flip(screen); //Update screen
        } //Loads in the external content
Пример #19
0
        public void LoadTyped_RW()
        {
            string file       = "test.gif";
            IntPtr surfacePtr = VideoSetup();
            IntPtr imagePtr   = SdlImage.IMG_LoadTyped_RW(Sdl.SDL_RWFromFile(file, "rb"), 1, "gif");

            Assert.IsFalse(imagePtr == IntPtr.Zero);
            Sdl.SDL_Rect rect1  = new Sdl.SDL_Rect(0, 0, 200, 200);
            Sdl.SDL_Rect rect2  = new Sdl.SDL_Rect(0, 0, 200, 200);
            int          result = Sdl.SDL_BlitSurface(imagePtr, ref rect1, surfacePtr, ref rect2);

            Sdl.SDL_UpdateRect(surfacePtr, 0, 0, 200, 200);
            Thread.Sleep(sleepTime);
            Assert.AreEqual(result, 0);
            file       = "test.png";
            surfacePtr = VideoSetup();
            imagePtr   = SdlImage.IMG_LoadTyped_RW(Sdl.SDL_RWFromFile(file, "rb"), 1, "png");
            Assert.IsFalse(imagePtr == IntPtr.Zero);
            result = Sdl.SDL_BlitSurface(imagePtr, ref rect1, surfacePtr, ref rect2);
            Sdl.SDL_UpdateRect(surfacePtr, 0, 0, 200, 200);
            Thread.Sleep(sleepTime);
            Assert.AreEqual(result, 0);
            this.Quit();
        }