this code needs to be crusified
This commit is contained in:
parent
95737984ee
commit
f62676b94b
2 changed files with 81 additions and 0 deletions
BIN
src/a.out
Executable file
BIN
src/a.out
Executable file
Binary file not shown.
81
src/main.c
Normal file
81
src/main.c
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
#include <stdio.h> //printf and shit
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
const int width = 800;
|
||||||
|
const int height = 600;
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
//legally required print (it broke without it)
|
||||||
|
printf("asd");
|
||||||
|
|
||||||
|
//general setup
|
||||||
|
SDL_Init(SDL_INIT_EVERYTHING);
|
||||||
|
SDL_Window *window = SDL_CreateWindow("amogus", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL);
|
||||||
|
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0);
|
||||||
|
|
||||||
|
//clear
|
||||||
|
//this kinda doesnt work
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
int mousex;
|
||||||
|
int mousey;
|
||||||
|
SDL_Rect rect;
|
||||||
|
rect.x = 250;
|
||||||
|
rect.y = 150;
|
||||||
|
rect.w = 10;
|
||||||
|
rect.h = 10;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
//update mouse
|
||||||
|
SDL_PumpEvents();
|
||||||
|
const Uint8 *state = SDL_GetKeyboardState(NULL);
|
||||||
|
SDL_GetMouseState(&mousex, &mousey);
|
||||||
|
|
||||||
|
if (state[SDL_SCANCODE_Q]) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if (state[SDL_SCANCODE_W]) {
|
||||||
|
rect.y -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state[SDL_SCANCODE_A]) {
|
||||||
|
rect.x -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state[SDL_SCANCODE_S]) {
|
||||||
|
rect.y += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state[SDL_SCANCODE_D]) {
|
||||||
|
rect.x += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state[SDL_SCANCODE_T]) {
|
||||||
|
rect.x = 10;
|
||||||
|
rect.y = 10;
|
||||||
|
}
|
||||||
|
SDL_Delay(1);
|
||||||
|
|
||||||
|
//render loop
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||||
|
SDL_RenderDrawPoint(renderer, mousex, mousey);
|
||||||
|
|
||||||
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
|
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
}
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
|
||||||
|
//CLEANUP
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue