Jump to content
  • Advertisement

ooleziloo

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

100 Neutral

About ooleziloo

  • Rank
    Newbie
  1. ooleziloo

    [SDL] slow down the code?

    void gameEvents::gameDraw(int srcX, int srcY, int desX,int desY,int width, int height, SDL_Surface* source, SDL_Surface* destination) { SDL_Rect src; src.x = srcX; src.y = srcY; src.w = width; src.h = height; SDL_Rect des; des.x = desX; des.y = desY; des.w = width; des.h = height; SDL_BlitSurface(source, &src, destination, &des);
  2. ooleziloo

    [SDL] slow down the code?

    background flashes and theres a bug somewhere in the for loop or the input because its not putting the bricks where they are suppose to go the txt file looks like this map01.dat 010101010101 010101010101 15x20 then the code like this, void gameEvents::gameUpdate() { Map map; if(menu) { player = SDL_LoadBMP("Marrow.bmp"); } if(newMap) { background = SDL_LoadBMP("data/maps/map01.bmp");//adds a basic background player = SDL_LoadBMP("artemis.bmp");// change from menu arrow to artemis, the players character item = SDL_LoadBMP("brick.bmp");//layer for background ifstream ifs ( "data/maps/map01.dat" , ifstream::in ); while (ifs.good()) { map.level[levelY][levelX] << ifs.get(); levelX += 1; if(levelX >= 20) { levelX = 1; levelY += 1; } } ifs.close(); newMap = false; } SDL_BlitSurface( background, NULL, screen, NULL ); for (levelY=0;levelY<15;levelY++) { for (levelX=0;levelX<20;levelX++) { if (map.level[levelY][levelX] == 1) { gameDraw(srcmapX,srcmapY,mapX,mapY,playerWidth,playerHeight,item,screen); //i know item is the same in both places, just using that to test mapX += 64; } if(map.level[levelY][levelX] == 0) { gameDraw(srcmapX,srcmapY,mapX,mapY,playerWidth,playerHeight,item,screen); //i know item is the same in both places, just using that to test mapX += 64; } } if(levelX >= 20) { levelX = 0; levelY += 1; mapY += 64; } } SDL_SetColorKey(player,SDL_SRCCOLORKEY,SDL_MapRGB(player->format, 200,0,200)); gameDraw(srcX,srcY,desX,desY,playerWidth,playerHeight,player,screen); SDL_Flip(screen); gameRunning = true; }
  3. ooleziloo

    [SDL] slow down the code?

    correct
  4. hey guys, well i guess that my program is updating my images too fast because you can watch them overlap each other, im trying to draw tiles on a stationary background and all i see is the background flash on top of the tiles then tie tiles flash on the background but neither ever stop flashing, ne ideas?: UPDATE - this is what i get if i dont blip the background every loop, you can see the the tiles, but they are popping up completely in the wrong order and they dont match the file at all(which could happen if its putting them on the screen wrong) excuse the 5 second programmer graphics lol
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!