![]() Rectangles: TSDL_Rect and PSDL_Rect in SDL 2.0 Screens and Images are rectangular, so this shape has a special importance to SDL2 and graphics programming in particular. A list of all the scancodes shows all possible scancodes. A detailed description of scancodes in the next chapter. The scancode represents the position of the related key state in the array. exit the program loop or change the x/y coordinates of the rectangle. SDL_SCANCODE_ESCAPE for the escape key) and react as desired, e.g. We now can check for the of any key in the array by sdlKeyboardState using its These actions have to performed on every cycle. After that we can grab the keyboard state by the former mentioned function SDL_GetKeyboardState. Here we need to update the event queue by procedure SDL_PumpEvents. program loopĪfter setting up a SDL2 window and and preparing a SDL2 rectangle, the program loop is entered. To get the keyboard state, we define a unsigned 8 bit pointer variable sdlKeyboardState in the var clause. ![]() SDL_RenderDrawRect(sdlRenderer, clear memory SDL_SetRenderDrawColor(sdlRenderer, 255, 0, 0, SDL_ALPHA_OPAQUE) SDL_SetRenderDrawColor(sdlRenderer, 0, 0, 0, SDL_ALPHA_OPAQUE) SdlKeyboardState := SDL_GetKeyboardState(nil) Therefore we read out their key states on every cycle of the program loop. The following code example will draw a red rectangle which can be moved by the WASD keys. The red rectangle can be moved by the WASD keys by reading out their key states. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |