#include #include #include #include #define PROJECT_NAME "vectors-unit vec" #define obj_n 1 typedef struct { Point pos; } OBJECT_INER; typedef struct OBJECT { OBJECT_INER *objs[obj_n]; } OBJECT; #include void constructor(int w, int h, OBJECT_INER *obj){ obj->pos.x = (float)w/2; obj->pos.y = (float)h/2; } void init_stuffs(int w, int h, OBJECT_INER *objs, STUFFS *stuff){ constructor(w,h,&objs[0]); } void normalize(Point *p){ point_set_mag(p, 1); } void draw(SDL_Renderer* renderer,SDL_Window* window, STUFFS *stuff){ SDL_SetRenderDrawColor(renderer,0,0,0,255); SDL_RenderClear(renderer); Point pos = { 300,300 }; Point mouse = {stuff->mx, stuff->my}; Point v = { mouse.x - pos.x, mouse.y - pos.y, }; //float mag = magnitude(v.x, v.y); //point_div(&v,&(Point){mag,mag}); //normalize(&v); //point_mul(&v,&(Point){50,50}); point_set_mag(&v, 50); SDL_SetRenderDrawColor(renderer,150,50,255,255); SDL_RenderDrawLine(renderer,stuff->width/2,stuff->height/2,v.x + (float)stuff->width/2,v.y + (float)stuff->height/2); SDL_RenderPresent(renderer); } #include