Sign in to follow this  

SDL resource comsumptions and compatibilty.

Recommended Posts

Hi!. I´ve been busy during the last few days crafting what would be my first prototipe of something that actually does work using the SDL library... Two questions have come to mind about it: -How much SDL is compatible among computers?. I tried it in several computers and worked without a problem but in one of them wouldn´t even run or would run in strange ways. -How much resources does the drawing consume?. The code for my application is purposedly consuming (see below) to test the SDL a bit. In my computer (a 1.60ghz laptop with 1gb of RAM) it runs fine but in an Athlon K7 (512 RAM) it´s just slow... Are the requirements for the SDL always high?. As for the code itself... Let me explain in wich way it is unneficient: the program is a tile based game, quite like the classic "Snake" that comes in the mobile phones but even uglier. The whole gaming board is a 40x30 matrix and the drawing process goes like: -Load the tileset. -Loop: -Check one matrix place. -Set the offsets on the tileset depending on the content. -Draw to the screen what was just selected. -Check next. -End loop. It does that for every single instance of the main game loop and, to test further, there´s no use of the "SDL_Delay" function. So to say, the program is calling a blit like 130 times per each passing through the game loop... It´s a lot but, don´t arcade-like games draw a lot of sprites on the screen each time too?. Finally, I have ways to improve the code (:D) and can upload it somewhere along with the .exe so everyone can take a look at it, in case I did something wrong. Edit: I´ve decided to paste that piece of code, just in case. "marco" is a frame for selecting the tiles and "coordenadas" is just the coordinates where the stuff will be put. "filas" is rows and "columnas" is columns.
            for(filas=0; filas<30; filas++)                                             
                  for(columnas=0; columnas<40; columnas++)
                              case 0: marco.x=0; marco.y=0; break;
                              case 1: marco.x=48; marco.y=0; break;
                              case 3: marco.x=16; marco.y=0; break;
                              case 4: marco.x=32; marco.y=0; break;
                              case 5: marco.x=32; marco.y=16; break;
                        coordenadas.x=(columnas*16)+80; coordenadas.y=(filas*16)+48;
                        SDL_BlitSurface(objeto, &marco, pantalla, &coordenadas);                 

Just to clarify, the whole code is as newbish as this part, so full of "switch" sentences and the like.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this