GameSetup::GameSetup()
{
this->x = 10;
this->y = 10;
}
GameSetup::~GameSetup()
{
delete &x;
delete &y;
std::cout << "this object is being destroyed..." << std::endl;
}
void GameSetup::initialize()
{
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT,
SCREEN_WIDTH,
SCREEN_HEIGHT,
0, 0);
while(!key[KEY_ESC])
{
clear_keybuf();
acquire_screen();
textout_ex(screen, font, " ", x, y, makecol(0, 0, 0), makecol(0, 0, 0));
if (key[KEY_UP]) --y;
else if (key[KEY_DOWN]) ++y;
else if (key[KEY_LEFT]) --x;
else if (key[KEY_RIGHT]) ++x;
textout_ex(screen, font, "hello world!", x, y, makecol(0, 255, 0), makecol(0, 0, 0));
release_screen();
rest(50);
}
}
int GameSetup::get_x() const
{
return this->x;
}
int GameSetup::get_y() const
{
return this->y;
}
And here's what I have in main:
int main()
{
{
GameSetup * game;
game->initialize();
}
return 0;
}
It's nothing complicated; just the 'Hello World' version of Allegro which allows the user to move text around the screen with the arrow keys. The problem is that if I try to do this the object oriented way, nothing really works. The program compiles, and the screen loads, but that's it. No text. And when I move the arrow keys, the program exits.
Any idea why this is happening?

New Topic/Question
Reply



MultiQuote



|