Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.64 KB | None | 0 0
  1. static void Setup()
  2. {
  3.     SCREEN_WIDTH=680;
  4.     SCREEN_HEIGHT=480;
  5. }
  6.  
  7. real32 time=0;
  8.  
  9. void InitGame(game_memory* memory)
  10. {
  11.     memory->map = (uint32*) allocate(memory,sizeof(uint32)*(TILE_WIDTH+1*TILE_WIDTH+1));
  12.     memory->clear = (uint32*) allocate(memory,sizeof(uint32)*(SCREEN_WIDTH*SCREEN_HEIGHT));
  13.  
  14.     InitBmps(memory,3);
  15.     LoadBmp("owl.bmp",memory);
  16.     LoadBmp("man.bmp",memory);
  17.  
  18.     DrawBlock(memory->clear,SCREEN_WIDTH,SCREEN_HEIGHT,RGB(0.0f,0.0f,0.0f));
  19.     DrawBlock(memory->map,TILE_WIDTH,TILE_HEIGHT,RGB(1.0f,0.0f,0.0f));
  20.  
  21.     player.origin.x = SCREEN_WIDTH/2;
  22.     player.origin.y = SCREEN_HEIGHT/2;
  23.  
  24.     time = 0.0f;
  25.  
  26. #endif
  27.  
  28. }
  29.  
  30. void GameUpdateAndRender(game_memory* memory,game_input* gameInput,sdl_offscreen_buffer* offscreenbuffer,game_sound_output_buffer* soundBuffer )
  31. {
  32.     uint32 map[MAP_HEIGHT][MAP_WIDTH]  =
  33.     {
  34.           {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
  35.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  36.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  37.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  38.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  39.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  40.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  41.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  42.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  43.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  44.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  45.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  46.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  47.           {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
  48.           {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
  49.     };
  50.  
  51.  
  52.     time += gameInput->dt;
  53.  
  54.     real32 Angle = time;
  55.  
  56.     player.x.x = (70.0f*cosf(Angle));
  57.     player.x.y =( 70.0f*sinf(Angle));
  58.  
  59.     player.y.x = -1 * player.x.y;
  60.     player.y.y = 1 * player.x.x;
  61.  
  62.     HardRender(memory->clear,SCREEN_WIDTH,SCREEN_HEIGHT,0,-3);
  63.  
  64.     vector dm = { 2,2 };
  65.    
  66.     vector p = player.origin;
  67.     p.x = player.origin.x;
  68.     p.y = player.origin.y;
  69.  
  70.     DrawBlock(memory->map,TILE_WIDTH,TILE_HEIGHT,RGB(0.0f,1.0f,0.0f));
  71.     HardRender(memory->map,TILE_WIDTH,TILE_HEIGHT,p.x - dm.x, p.y - dm.y);
  72.  
  73.     p.x = player.origin.x+player.x.x;
  74.     p.y = player.origin.x+player.x.y;
  75.  
  76.     DrawBlock(memory->map,TILE_WIDTH,TILE_HEIGHT,RGB(0.0f,1.0f,0.0f));
  77.     HardRender(memory->map,TILE_WIDTH,TILE_HEIGHT,p.x - dm.x, p.y - dm.y);
  78.  
  79.     p.x = player.origin.y+player.y.x;
  80.     p.y = player.origin.y+player.y.y;
  81.  
  82.     DrawBlock(memory->map,TILE_WIDTH,TILE_HEIGHT,RGB(0.0f,1.0f,0.0f));
  83.     HardRender(memory->map,TILE_WIDTH,TILE_HEIGHT,p.x - dm.x, p.y - dm.y);
  84.  
  85. }
  86.  
  87. void DrawBlock(uint32* memoryblock,int width, int height, uint32 color)
  88. {
  89.     int counter=0;
  90.     for (counter = 0; counter < width * height; counter++)
  91.     {
  92.         memoryblock[counter] = color;
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement