From c01a19a9ee8d21d1516b7802fe3a4e5c957c6111 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Tue, 29 Sep 2015 21:18:26 +0300 Subject: [PATCH] Draw a platform --- main.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 0d4e15f..9d4df81 100644 --- a/main.cpp +++ b/main.cpp @@ -32,8 +32,29 @@ int main(int argc, char const *argv[]) { return 1; } - std::cout << "Sleeping for a second..." << std::endl; - usleep(1000000); + // Setting background color to black + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); + + // Creat a rect at pos ( 50, 50 ) that's 50 pixels wide and 50 pixels high. + SDL_Rect platform = { + .x = (640 - 200) / 2, + .y = (480 - 20), + .w = 200, + .h = 20 + }; + + // Set render color to blue ( rect will be rendered in this color ) + SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); + + // Render rect + SDL_RenderFillRect(renderer, &platform); + + // Render the rect to the screen + SDL_RenderPresent(renderer); + + SDL_DestroyWindow(window); + SDL_Quit(); std::cout << "Exiting nicely" << std::endl; return 0;