Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Setup()
- {
- SCREEN_WIDTH=680;
- SCREEN_HEIGHT=480;
- }
- real32 time=0;
- void InitGame(game_memory* memory)
- {
- memory->map = (uint32*) allocate(memory,sizeof(uint32)*(TILE_WIDTH+1*TILE_WIDTH+1));
- memory->clear = (uint32*) allocate(memory,sizeof(uint32)*(SCREEN_WIDTH*SCREEN_HEIGHT));
- InitBmps(memory,3);
- LoadBmp("owl.bmp",memory);
- LoadBmp("man.bmp",memory);
- DrawBlock(memory->clear,SCREEN_WIDTH,SCREEN_HEIGHT,RGB(0.0f,0.0f,0.0f));
- DrawBlock(memory->map,TILE_WIDTH,TILE_HEIGHT,RGB(1.0f,0.0f,0.0f));
- player.origin.x = SCREEN_WIDTH/2;
- player.origin.y = SCREEN_HEIGHT/2;
- time = 0.0f;
- #endif
- }
- void GameUpdateAndRender(game_memory* memory,game_input* gameInput,sdl_offscreen_buffer* offscreenbuffer,game_sound_output_buffer* soundBuffer )
- {
- uint32 map[MAP_HEIGHT][MAP_WIDTH] =
- {
- {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
- {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
- };
- time += gameInput->dt;
- real32 Angle = time;
- player.x.x = (70.0f*cosf(Angle));
- player.x.y =( 70.0f*sinf(Angle));
- player.y.x = -1 * player.x.y;
- player.y.y = 1 * player.x.x;
- HardRender(memory->clear,SCREEN_WIDTH,SCREEN_HEIGHT,0,-3);
- vector dm = { 2,2 };
- vector p = player.origin;
- p.x = player.origin.x;
- p.y = player.origin.y;
- DrawBlock(memory->map,TILE_WIDTH,TILE_HEIGHT,RGB(0.0f,1.0f,0.0f));
- HardRender(memory->map,TILE_WIDTH,TILE_HEIGHT,p.x - dm.x, p.y - dm.y);
- p.x = player.origin.x+player.x.x;
- p.y = player.origin.x+player.x.y;
- DrawBlock(memory->map,TILE_WIDTH,TILE_HEIGHT,RGB(0.0f,1.0f,0.0f));
- HardRender(memory->map,TILE_WIDTH,TILE_HEIGHT,p.x - dm.x, p.y - dm.y);
- p.x = player.origin.y+player.y.x;
- p.y = player.origin.y+player.y.y;
- DrawBlock(memory->map,TILE_WIDTH,TILE_HEIGHT,RGB(0.0f,1.0f,0.0f));
- HardRender(memory->map,TILE_WIDTH,TILE_HEIGHT,p.x - dm.x, p.y - dm.y);
- }
- void DrawBlock(uint32* memoryblock,int width, int height, uint32 color)
- {
- int counter=0;
- for (counter = 0; counter < width * height; counter++)
- {
- memoryblock[counter] = color;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement