Maybe I should give you a little code to go on in an email. Trimmed, of
course:
#ifndef BATTLE_H
#define BATTLE_H
#include <SDL/SDL.h>
#include “SDL/SDL_ttf.h”
#include “character.h”
SDL_Surface *screen, *image[4], *status[4];
SDL_Rect src[4], dest[4];
Uint32 colorkey;
TTF_Font *font;
battle.h:
class battle
{
public:
void loadImage(int index, char* filename);
SDL_Surface *screen, *image[4], *status[4];
SDL_Rect src[4], dest[4];
Uint32 colorkey;
TTF_Font *font;
};
#endif
battle.cpp:
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_gfxPrimitives.h>
#include “battle.h”
#include “character.h”
int i;
void battle::loadImage(int index, char* filename)
{
image[index] = IMG_Load(filename);
if (image[index] == NULL)
{
printf(“Unable to load image %s: %s\n”, filename,
SDL_GetError());
}
colorkey = SDL_MapRGB(image[index]->format, 0, 255, 0);
SDL_SetColorKey(image[index], SDL_SRCCOLORKEY, colorkey);
src[index].x = 0;
src[index].y = 0;
src[index].w = image[index]->w;
src[index].h = image[index]->h;
dest[index].x = 600;
dest[index].y = index * 100;
dest[index].w = image[index]->w;
dest[index].h = image[index]->h;
}
int main()
{
battle mybattle = battle();
for (i = 0; i < 4; i++)
{
mybattle.party[i].setX(600);
mybattle.party[i].setY(i * 100);
}
i = 0;
/Draw the allies/
mybattle.loadImage(i++, “ffight.gif”);
mybattle.loadImage(i++, “tfight.gif”);
mybattle.loadImage(i++, “wmfight.gif”);
mybattle.loadImage(i, “bmfight.gif”);
for (i = 0; i < 4; i++)
{
SDL_BlitSurface(mybattle.image[i], &mybattle.src[i],
mybattle.screen, &mybattle.dest[i]);
}
The full code is at http://www.espersunited.com/~michael/needhelp.txt if
there’s anything relevant to this problem that’s not listed here…
/Draw the enemies/
/Draw the battle screen lines/
drawLines();
SDL_Delay(10000);
for (i = 0; i < 4; i++)
{
SDL_FreeSurface(image[i]);
SDL_FreeSurface(status[i]);
}
return 0;
}On Tue, 2007-11-27 at 16:06 -0600, Michael Sullivan wrote:
I recently converted my project from C to C++ because I feel more
comfortable working with OOP than C. I think I’ve correctly converted
the code, but my sprites don’t show up now. They did show up when the
project was in C. The source code is a bit long to post into an email,
so I’ve posted it to my webspace. Here’s the link:
http://www.espersunited.com/~michael/needhelp.txt
Please help me! Thank you!
-Michael Sullivan-