SDL.c
int main(int argc, char** argv){
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window* window = SDL_CreateWindow("title",SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,800,600,SDL_WINDOW_SHOWN);
SDL_Renderer* render = SDL_CreateRenderer(window,-1,0);
SDL_Rect rect = {100,100,50,50};
SDL_Event event;
SDL_bool running = SDL_TRUE;
const Uint8* keyState;
int speed = 6;
while(running){
SDL_PollEvent(&event);
if(event.type == SDL_QUIT) running = SDL_FALSE;
keyState = SDL_GetKeyboardState(NULL);
if(keyState[SDL_SCANCODE_UP]) rect.y -= speed;
if(keyState[SDL_SCANCODE_DOWN]) rect.y += speed;
if(keyState[SDL_SCANCODE_RIGHT]) rect.x += speed;
if(keyState[SDL_SCANCODE_LEFT]) rect.x -= speed;
SDL_SetRenderDrawColor(render,0,0,0,255);
SDL_RenderClear(render);
SDL_SetRenderDrawColor(render,0,255,0,255);
SDL_RenderFillRect(render,&rect);
SDL_RenderPresent(render);
SDL_Delay(1000/120);
}
SDL_DestroyRenderer(render);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}