54 lines
1.0 KiB
C
Executable File
54 lines
1.0 KiB
C
Executable File
#include <stdbool.h>
|
|
#include <global_objects.c>
|
|
|
|
#include <SDL2/SDL.h>
|
|
#include <SDL2/SDL_video.h>
|
|
|
|
#define PROJECT_NAME "vecotrs-main"
|
|
|
|
typedef struct {
|
|
Point pos;
|
|
Point vel;
|
|
} OBJECT;
|
|
|
|
#include <init.h>
|
|
|
|
void constructor(int w, int h, OBJECT *obj){
|
|
obj->pos.x = (float)w/2;
|
|
obj->pos.y = (float)h/2;
|
|
obj->vel.x = 1;
|
|
obj->vel.y = -1;
|
|
}
|
|
|
|
OBJECT init_stuffs(int w, int h){
|
|
OBJECT obj;
|
|
constructor(w,h,&obj);
|
|
|
|
return obj;
|
|
}
|
|
|
|
void update(OBJECT *obj){
|
|
point_add(&obj->pos, &obj->vel);
|
|
}
|
|
|
|
void show(SDL_Renderer* renderer,OBJECT *obj){
|
|
SDL_SetRenderDrawColor(renderer,150,50,255,255);
|
|
SDL_RenderFillRect(renderer,&(SDL_Rect){.x = obj->pos.x - 5, .y=obj->pos.y - 5, .w = 10, .h = 10});
|
|
}
|
|
|
|
void draw(SDL_Renderer* renderer,SDL_Window* window, STUFFS *stuff){
|
|
SDL_SetRenderDrawColor(renderer,0,0,0,255);
|
|
SDL_RenderClear(renderer);
|
|
|
|
update(stuff->obj);
|
|
show(renderer,stuff->obj);
|
|
|
|
SDL_RenderPresent(renderer);
|
|
}
|
|
|
|
void mousePressed(STUFFS *stuff){
|
|
|
|
}
|
|
|
|
#include <init.c>
|