Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Headers.h"
- #include "GlobalVar.h"
- #include "functions.h"
- using namespace std;
- class LTexture;
- class CharProp;
- int main( int argc, char* argv[] )
- {
- //Properties of character
- gracz.x = 0;
- gracz.y = 0;
- gracz.h = 64;
- gracz.w = 64;
- //Initialisation
- if ( !init() )
- {
- cout << "Could not init\n";
- }
- else
- {
- if ( !loadMedia() )
- {
- cout << "Could not load media\n";
- }
- else
- {
- SDL_SetWindowIcon( gWindow, Icon);
- SDL_FreeSurface( Icon );
- bool quit = false;
- SDL_Event e;
- SDL_RenderClear( gRenderer );
- renderAll();
- SDL_RenderPresent(gRenderer);
- while ( !quit )
- {
- short MoveMultiplier = 32;
- while( SDL_PollEvent( &e ) )
- {
- if ( e.type == SDL_QUIT )
- {
- quit = true;
- }
- switch ( e.key.keysym.sym )
- {
- case SDLK_UP:
- {
- if( gracz.y > 0 && gracz.y != 0)
- {
- gracz.y -= MoveMultiplier;
- std::cout<<gracz.x<<" "<<gracz.y<<endl;
- renderAll();
- }
- }
- break;
- case SDLK_DOWN:
- {
- if( gracz.y+gracz.h < SCREEN_HEIGHT && gracz.y+gracz.h != SCREEN_HEIGHT)
- {
- gracz.y += MoveMultiplier;
- std::cout<<gracz.x<<" "<<gracz.y<<endl;
- renderAll();
- }
- }
- break;
- case SDLK_LEFT:
- {
- if( gracz.x- MoveMultiplier >= 0 )
- {
- gracz.x -= MoveMultiplier;
- std::cout<<gracz.x<<" "<<gracz.y<<endl;
- renderAll();
- }
- }
- break;
- case SDLK_RIGHT:
- {
- if( gracz.x+gracz.w+ MoveMultiplier <= SCREEN_WIDTH)
- {
- gracz.x += MoveMultiplier;
- std::cout<<gracz.x<<" "<<gracz.y<<endl;
- renderAll();
- }
- }
- break;
- }
- }
- }
- }
- }
- close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement