so I have a couple classes, engine, input, and graphics. what I want to do is enter key strokes that will update the screen, how do I get the code to work, and is there an easier way than what I’m trying to do?
main.cpp
Code:
while( quit == false )
{
quit =input.check_quit(quit);
if(event.type ==SDL_KEYDOWN)
{
input.get_input();
x = input.getx();
graphics.getInput(x);
graphics.update();
}
}
engine.cpp
Code:
void input::get_input()
{
key = SDL_GetKeyState (NULL);
if (key[SDLK_RIGHT])
{
x =4;
}
}
int input::getx()
{
return x;
}
graphics.cpp
Code:
int graphics::getInput(int y)
{
y = x;
if (y == 4)
{
player = facingRight;
}
bool graphics::update()
{
if( message != NULL )
{
apply_surface( 0, 0, background, buffer,NULL);
apply_surface(500, 0, player, buffer);
}
if( SDL_Flip( buffer ) == -1 )
{
printf(“graphics.cpp buffer = -1: %s\n”, SDL_GetError());
return 1;
}
}
}