Jump to content
  • Advertisement
Sign in to follow this  
Thekill473

c++ error please help

This topic is 2618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello everybody right now i'm having with clipping my tile sheet. Its probably a really dumb error on my part but anyways here is the code.

graphic_functions.h
#include"SDL.h"
#include <string>
#include "SDL_image.h"
#include "tile_load.h"
#include "class_tile.h"

using namespace::std;

// used for clipping
SDL_Rect clips[TILE_SPRITES];

void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL)
{
//Holds offsets
SDL_Rect offset;

//Get offsets
offset.x = x;
offset.y = y;

//Blit
SDL_BlitSurface( source, clip, destination, &offset );
}

void draw_sprite(int srcX, int srcY, int dstX, int dstY, 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 dst;
dst.x = dstX;
dst.y = dstY;
src.w = width;
src.h = height;

SDL_BlitSurface(source, &src, destination, &dst);

}

SDL_Surface *load_image( std::string filename )
{
//The image that's loaded
SDL_Surface* loadedImage = NULL;

//The optimized surface that will be used
SDL_Surface* optimizedImage = NULL;

//Load the image
loadedImage = IMG_Load( filename.c_str() );

//If the image loaded
if( loadedImage != NULL )
{
//Create an optimized surface
optimizedImage = SDL_DisplayFormat( loadedImage );

//Free the old surface
SDL_FreeSurface( loadedImage );

//If the surface was optimized
if( optimizedImage != NULL )
{
//Color key surface
SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB( optimizedImage->format, 0, 0xFF, 0xFF ) );
}
}

//Return the optimized surface
return optimizedImage;
}


void clip_tiles()
{
//Clip the sprite sheet
clips[tile_green].x = 0;
clips[tile_green].y = 0;
clips[tile_green].w = TILE_WIDTH;
clips[tile_green].h = TILE_HEIGHT;

clips[tile_black].x = 0;
clips[tile_black].y = 32;
clips[tile_black].w = TILE_WIDTH;
clips[tile_black].h = TILE_HEIGHT;

}




please help.

Share this post


Link to post
Share on other sites
Advertisement

This topic is 2618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • 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!