Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1.  
  2.  
  3. bool init(){
  4. printf("Connecting to Pi Harness\t");
  5. if (wiringPiSetup () == -1){
  6. printf("Error Could not start wiringPiSetup\n");
  7. return false;
  8. }
  9.  
  10. pinMode (0, INPUT) ; // aka BCM_GPIO pin 17
  11. //Coin Acceptor
  12.  
  13. if(init_i2c() == false){
  14. printf("Error Could not start init_i2c\n");
  15. return false;
  16. }
  17.  
  18. printf("loading sdl2 \n");
  19. if( SDL_Init( SDL_INIT_VIDEO ) < 0 ){
  20. printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
  21. return false;
  22. }
  23.  
  24. //Create window
  25. Window = SDL_CreateWindow( "SDL 2 ", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL );
  26. if( Window == NULL ){
  27. printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
  28. return false;
  29. }
  30.  
  31. //Initialize PNG loading
  32. int imgFlags = IMG_INIT_PNG;
  33. if( !( IMG_Init( imgFlags ) & imgFlags ) ){
  34. printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
  35. return false;
  36. }
  37. //Initialize SDL_ttf
  38. if( TTF_Init() == -1 ){
  39. printf( "SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError() );
  40. return false;
  41. }
  42. //Create renderer for window
  43. Renderer = SDL_CreateRenderer( Window, -1, SDL_RENDERER_ACCELERATED );
  44. if( Renderer == NULL )
  45. {
  46. printf("Renderer could not be created! SDL Error: %s\n", SDL_GetError());
  47. return false;
  48. }
  49.  
  50. //Initialize renderer color
  51. SDL_SetRenderDrawColor( Renderer, 0x77, 0x77, 0x77, 0xFF ); //gray?
  52.  
  53.  
  54. //Initialize SDL_mixer
  55. if( Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024 ) == -1 ) { printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() ); return false; }
  56.  
  57. //Load Files
  58. if(!loadMedia())
  59. {
  60. printf("failed to load graphics\n");
  61. return false;
  62. }
  63.  
  64.  
  65. printf("Game Loaded");
  66. //everything worked
  67. return true;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement