diff --git a/.gitignore b/.gitignore index 6e7463f..a590c46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ *.o -game diff --git a/game b/game new file mode 100755 index 0000000..9cb7dc6 Binary files /dev/null and b/game differ diff --git a/game.c b/game.c index 08d1210..49b446b 100644 --- a/game.c +++ b/game.c @@ -63,7 +63,7 @@ int init(void){ return 0; } -int createCar(){ +int createCar(void){ // create surface SDL_Surface* Car_surface = IMG_Load("img/car.png"); if(!Car_surface){ @@ -88,6 +88,34 @@ int createCar(){ return 0; } +void drowTrack(void){ + Uint32 w = WINDOW_WIDTH / 10; + Uint32 h = WINDOW_HEIGHT / 10; + SDL_Rect track[4]; + // left + track[0].x = w; + track[0].y = h; + track[0].w = w; + track[0].h = h*8; + // top + track[1].x = w; + track[1].y = h; + track[1].w = w*8; + track[1].h = h; + // right + track[2].x = w*8; + track[2].y = h; + track[2].w = w; + track[2].h = h*8; + // bottom + track[3].x = w; + track[3].y = h*8; + track[3].w = w*8; + track[3].h = h; + SDL_SetRenderDrawColor(renderer, 119, 119, 119, 255); + SDL_RenderFillRects(renderer, &track, 4); +} + int main(void){ if(init() != 0) return 1; if(createCar() != 0) return 2; @@ -156,8 +184,11 @@ int main(void){ } // clear the window + SDL_SetRenderDrawColor(renderer, 126, 200, 80, 255); SDL_RenderClear(renderer); + drowTrack(); + // update position if(car_moving == 1){ if(direction == 1){ @@ -190,11 +221,11 @@ int main(void){ Car_pos.x = (int) car_pos[0]; Car_pos.y = (int) car_pos[1]; - +/* printf("heading: %f\t%d\n", (heading), direction); printf("car posf: %f, %f\n", car_pos[0], car_pos[1]); printf("car pos: %u, %u\t%d\n", Car_pos.x, Car_pos.y, car_moving); - +*/ // drow image SDL_RenderCopyEx(renderer, Car_texture, NULL, &Car_pos, 180-(heading*(180/PI)), NULL, SDL_FLIP_NONE); SDL_RenderPresent(renderer);