Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <SDL2/SDL.h>
  2. #include <SDL2/SDL_image.h>
  3. #include <iostream>
  4. #include <string>
  5. #include <cstdlib>
  6.  
  7. #include "object.h"
  8. #include "window.h"
  9.  
  10. int main()
  11. {
  12.     SDL_Event   mainEvent;
  13.     Window win(640, 480, "Hello)");
  14.     Object img;
  15.     img.setSurface(loadImage("hello.bmp"));
  16.     while(true)
  17.     {
  18.         if(SDL_PollEvent(&mainEvent)){
  19.             switch(mainEvent.type){
  20.                 case SDL_QUIT:    win.close(); break;
  21.                 case SDL_KEYDOWN:
  22.                              switch(mainEvent.key.keysym.sym){
  23.                                 case SDLK_ESCAPE: win.close(); break;
  24.                                 case SDLK_q:      win.close(); break;
  25.                              }
  26.             }
  27.         }
  28.         win.clear();
  29.         win.draw(img);
  30.         win.display();
  31.     }
  32.  
  33.     return EXIT_SUCCESS;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement