leave some context in
what error? Yes i read the previous two posts and I'm still not clear
what you meant.
What is?
The /compiler's/ effort?! Not your effort?
It's the compiler's output string.
to represent an array of Frame class pointers within the Animation class.
wouldn't that be?
class Animation
{
Frame* arrayFramePtrs[9];
};
I'm dynamically allocating memory at run time.
void Animation::SetNumFrames(int x)
{
NumFrames=x;
FrameList = (Frame *) malloc(x * sizeof(Frame));
}
try a simpler case. Without all the casts and arbitary offsts
Try reposting again. I know posting software can do Strange Things.
But stuffing a 44u in there sounds way off the scale!
#ifndef CHARACTER_H
#define CHARACTER_H
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
//Defines/////////////////////////////////////////////////////////
//Definitions for various states//////////////////////////////////
#define STANDING 1
#define WALKING 2
#define AIRBORN 3
#define HITHI 4
#define HITLOW 5
#define TRIPPED 6
#define FALLING 7
#define GROUNDED 8
#define DEAD 9
//Classes////////////////////////////////////////////////////////
class ContactBox
{
public:
int GetStrenth();
void SetStrength(int x);
SDL_Rect GetArea();
void SetArea(SDL_Rect x);
private:
int Strength;//how much damage can it withstand.
SDL_Rect Area;//Area on the character. EG. head.
};
class AttackBox //For when the character attacks
{
public:
void SetVelocity(int x, int y, int z);
SDL_Rect GetArea();
void SetArea(SDL_Rect x);
private:
int XVelocity;//The direction of the attack
int YVelocity;//The direction of the attack
int ZVelocity;
SDL_Rect Area;//Area on the character. EG. Fist.
};
class Frame
{
public:
void SetImage(char * filename, SDL_Rect area);//area of the image to use for the frame.
void SetDuration(int Duration);
int GetDuration();
void SetVelocity();
void SetNextFrame(Frame * frame);
Frame* GetNextFrame();
void SetPreviousFrame(Frame * frame);
Frame* GetPreviousFrame();
void DrawFrame(SDL_Surface * screen);
Frame &operator=( const Frame& );
private:
int FrameDuration;
int XVelocity, YVelocity, ZVelocity;//The directional velocity of the frame. To be added to the characters velocity.
ContactBox * ContactBoxList;
AttackBox * AttackBoxList;
SDL_Surface* Image;//Set to null if character is not to be visible.
SDL_Rect ImageArea;//to be passed to the drawing routine.
Frame * PreviousFrame;
Frame * NextFrame;
};
class Animation
{
public:
void UpdateAnimation(SDL_Surface* screen);
void DrawAnimation(SDL_Surface* screen);
void SetNumFrames(int x);
void SetFrame(int index, Frame * frame);
void SetNextAnimation(Animation * animation);
Animation * GetNextAnimation();
private:
int NumFrames;
int CurrentFrame;
int ControlLock;//Should the user have control
Frame *FrameList;//List of frames for the animation
Animation * NextAnimation;//null if not linked.
};
class Character
{
public:
Character(char *filename);
int GetHealth();
void SetAnimation();
private:
int Health;//current character health
int HealthMax;//max character health (can you say "Level Up!"
int Level;
int Experience;
int Strenght;
int Agility;
int Intelligence;
int State;
int XLocation, YLocation, ZLocation;// where the character is located on the game map/stage
int XVelocity, YVelocity, Zvelocity;//what direction the character is moving
int XIntent, YIntent, ZIntent;//What direction the character is trying to go.
int CurrentAnimation;
int Visible; //should the character be visible
Animation * AnimationList;
};
#endif
//CPP FILE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#include <stdio.h>
#include <stdlib.h>
#include "character.h"
//ContactBox//////////////////////////////////////////////////////////
int ContactBox::GetStrenth()
{
return Strength;
}
void ContactBox::SetStrength(int x)
{
Strength = x;
}
SDL_Rect ContactBox::GetArea()
{
return Area;
}
void ContactBox::SetArea(SDL_Rect x)
{
Area = x;
}
//AttackBox///////////////////////////////////////////////////
void AttackBox::SetVelocity(int x, int y, int z)
{
XVelocity = x;
YVelocity = y;
ZVelocity = z;
}
SDL_Rect AttackBox::GetArea()
{
return Area;
}
void AttackBox::SetArea(SDL_Rect x)
{
Area = x;
}
//Frame////////////////////////////////////////////////////////////////
void Frame::SetImage(char * filename, SDL_Rect area)//area of the image to use for the frame.
{
Image = IMG_Load(filename);
ImageArea = area;
}
void Frame::SetDuration(int Duration)
{
}
int Frame::GetDuration()
{
return FrameDuration;
}
void Frame::SetNextFrame(Frame * frame)
{
NextFrame = frame;
}
Frame* Frame::GetNextFrame()
{
return NextFrame;
}
void Frame::SetPreviousFrame(Frame * frame)
{
PreviousFrame = frame;
}
Frame* Frame::GetPreviousFrame()
{
return PreviousFrame;
}
void Frame:
rawFrame(SDL_Surface * screen)
{
SDL_BlitSurface(Image, 0, screen, &ImageArea);
}
//operator overloading
Frame &Frame:
perator=( const Frame& )
{
return *this;
}
//Animation///////////////////////////////////////////////////
void Animation::UpdateAnimation(SDL_Surface* screen)
{
CurrentFrame++;
DrawAnimation(screen);
}
void Animation:
rawAnimation(SDL_Surface* screen)
{
FrameList[CurrentFrame].DrawFrame(screen);
}
void Animation::SetNumFrames(int x)
{
NumFrames=x;
FrameList = (Frame *) malloc(x * sizeof(Frame));
}
void Animation::SetFrame(int index, Frame * frame)
{
FrameList[index]=frame;
}
void Animation::SetNextAnimation(Animation * animation)
{
NextAnimation = animation;
}
Animation * Animation::GetNextAnimation()
{
return NextAnimation;
}
//Character///////////////////////////////////////////////////
Character::Character(char *filename)
{
FILE *DefinitionFile;
fopen(filename, "r");
}
int Character::GetHealth()
{
return Health;
}