im trying to make a simple game engine, it consists of 2 classes, Game
class Game
{
protected:
SDL_Event event;
vector<Sprite> render_queue;
void render();
public:
int SCREEN_WIDTH,
SCREEN_HEIGHT,
SCREEN_BPP,
FPS;
SDL_Surface *screen;
Game(int width, int height, int fps);
void reset_screen();
void set_caption(string caption);
bool update();
void quit();
void add_sprite(Sprite spt);
};
and Sprite
class Sprite
{
public:
float x,y;
SDL_Surface* graphics;
Sprite();
void draw(SDL_Surface *target);
void loadGraphics(string path);
};
when im trying to change x or y of sprite it resets to 0 on next frame!
main.cpp
int main(int argc, char* args[])
{
Game testing(640, 480, 50);
testing.set_caption("Test");
Sprite s1;
Sprite s2;
s1.loadGraphics("img1.png");
s2.loadGraphics("img1.jpg");
testing.add_sprite(s1);
testing.add_sprite(s2);
while(!testing.update())
{
s1.x = 100;
s2.y = 200;
}
return 0;
}