Intro #
How Chapter 4 works? #
- init()
SDL_Init()
SDL_CreateWindow()
SDL_GetWindowSurface()
- loadMedia()
- put surfaces in SDL_Surface* array( is global variable) with
SDL_LoadBMP()
.
- put surfaces in SDL_Surface* array( is global variable) with
- start loop untill variable
quit
is true.- start loop that calls
SDL_PollEvent()
untill it returns 0.- if
SDL_Event.type
isSDL_QUIT
, quit is true( which means first loop will end).- else if
SDL_Event.type
isSDL_KEYDOWN
, choose mapped sruface to key insideSDL_Surface* array
( is global variable).
- else if
- copy screen(Blit) with
SDL_BlitSurface()
from chosen surface to screen surface. - update window with
SDL_UpdateWindowSurface()
to refresh and show what we’ve done.
- if
- start loop that calls
- close()
- free surfacees in SDL_Surface* array( is global varable) with
SDL_FreeSurface()
. SDL_DestroyWindow()
SDL_Quit()
- free surfacees in SDL_Surface* array( is global varable) with
Function #
- nothing new
Struct #
- nothing new
Term #
(enum(not official))KeyPressSurfaces #
- KEY_PRESS_SURFACE_DEFAULT
- KEY_PRESS_SURFACE_UP
- KEY_PRESS_SURFACE_DOWN
- KEY_PRESS_SURFACE_LEFT
- KEY_PRESS_SURFACE_RIGHT
- KEY_PRESS_SURFACE_TOTAL
these enum will have global SDL_Surface* array for having mapped surface.
SDL_Event.type #
- SDL_KEYDOWN
SDL_Event.key.keysym.sym #
- SDLK_UP
- SDLK_DOWN
- SDLK_LEFT
- SDLK_RIGHT