I'm working on a game project which should be similar to a street fighter game. The problem is that when I try to add new variables to the struct player which is inside a Abstract Data Type it crashes or the program doens't work propertly.
struct player {
//int neueVariable;
//int health;
float frameTime;
bool left;
float moveSpeed;
int curDoing;
int textureHeight;
int textureWidth;
SDL_Texture *texture;
SDL_Rect playerRect;
SDL_Rect playerPosition;
When I try to define the integer health it still works but some animations which are not connected to this abstract data type don't work anymore. So I guess it's some kind of a memory leak even though I have no Idea what it could be. But when I define the integer neueVariable and health (so both) it just crashes. Nothing works.
If you need some special code just tell me because I don't know what code you need because I have no clue what can cause it.
Im using the SDL library by the way.
#include "SDL.h"
#include "SDL_Image.h"
PPlayer player_create() {
PPlayer ply = (PPlayer) malloc(sizeof(struct player));
//player_setHealth(ply,100);
//player_setDead(ply,0);
player_setMoveSpeed(ply,0);
player_setCurDoing(ply,0);
player_setTextureHeight(ply,0);
player_setTextureWidth(ply,0);
player_setPlayerPositionX(ply,0);
player_setPlayerPositionY(ply,0);
player_setPlayerPositionW(ply,0);
player_setPlayerPositionH(ply,0);
player_setPlayerRectX(ply,0);
player_setPlayerRectY(ply,0);
player_setPlayerRectW(ply,0);
player_setPlayerRectH(ply,0);
return ply;
}
void player_setTextureHeight(PPlayer player, int value){
player->textureHeight = value;
}
in main for example
player_setTextureHeight(player1,rin_textureHeight);
rin_textureHeight is defined with int rin_textureHeight = 13600;