Skip to content
Snippets Groups Projects
Commit ccd38445 authored by Réthelyi Bálint's avatar Réthelyi Bálint :no_mouth:
Browse files

generate scoreboard button

parent b3101069
No related branches found
No related tags found
1 merge request!5Blint
...@@ -6,15 +6,19 @@ ...@@ -6,15 +6,19 @@
#IncludeRegexTransform: #IncludeRegexTransform:
/home/blint/projects/nhf/move.c /home/blint/projects/nhf/main.c
move.h
/home/blint/projects/nhf/move.h
view.h view.h
/home/blint/projects/nhf/view.h /home/blint/projects/nhf/view.h
SDL.h move.h
/home/blint/projects/nhf/move.h
SDL2/SDL_image.h
-
SDL2/SDL2_gfxPrimitives.h
- -
stdbool.h stdbool.h
- -
time.h
-
/home/blint/projects/nhf/move.h /home/blint/projects/nhf/move.h
view.h view.h
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -38,6 +38,7 @@ int main(int argc, char *argv[]) { ...@@ -38,6 +38,7 @@ int main(int argc, char *argv[]) {
bool quit = false; bool quit = false;
bool moving = false; bool moving = false;
bool loading = false; bool loading = false;
bool scoring = false;
int elozo_x = 0; int elozo_x = 0;
int elozo_y = W - 2*owl; int elozo_y = W - 2*owl;
...@@ -67,10 +68,19 @@ int main(int argc, char *argv[]) { ...@@ -67,10 +68,19 @@ int main(int argc, char *argv[]) {
load.click = false; load.click = false;
Button scoreboard; Button scoreboard;
scoreboard.x = 0; scoreboard.x = W/6;
scoreboard.y = 0; scoreboard.y = (3*H/9 + 2*(H/18));
scoreboard.w = 300; scoreboard.w = (W - W/6) - load.x;
scoreboard.h = owl; scoreboard.h = (3*H/9 + H/18) - load.y;
strcpy(scoreboard.title, "Dicsőség tábla");
scoreboard.over = false;
scoreboard.click = false;
Button scoretitle;
scoretitle.x = 0;
scoretitle.y = 0;
scoretitle.w = 300;
scoretitle.h = owl;
Color green = (Color){0, 255, 0}; Color green = (Color){0, 255, 0};
Color white = (Color){255, 255, 255}; Color white = (Color){255, 255, 255};
...@@ -91,20 +101,20 @@ int main(int argc, char *argv[]) { ...@@ -91,20 +101,20 @@ int main(int argc, char *argv[]) {
if (moving){ if (moving){
move_draw(ev, bagoly, &elozo_x, &elozo_y, platf, itemke); move_draw(ev, bagoly, &elozo_x, &elozo_y, platf, itemke);
sprintf(scoreboard.title, "Score: %6d", max_score); sprintf(scoretitle.title, "Score: %6d", max_score);
draw_button(scoreboard, green, white); draw_button(scoretitle, green, white);
} else } else
{ {
menu(ev, &start, &load, &moving, &loading); menu(ev, &start, &load, &scoreboard, &moving, &loading, &scoring);
} }
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
printf("Final score: %d\n", score);
SDL_DestroyTexture(bagoly); SDL_DestroyTexture(bagoly);
freeing(platf); freeing(platf);
freeing(itemke);
SDL_Quit(); SDL_Quit();
return 0; return 0;
......
...@@ -199,7 +199,7 @@ Button clickwatcher(SDL_Event ev, Button button) ...@@ -199,7 +199,7 @@ Button clickwatcher(SDL_Event ev, Button button)
return button; return button;
} }
void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading) void menu(SDL_Event ev, Button *start, Button *load, Button *scoreboard, bool *moving, bool *loading, bool *scoring)
{ {
Color red = (Color){255, 0, 0}; Color red = (Color){255, 0, 0};
Color green = (Color){0, 255, 0}; Color green = (Color){0, 255, 0};
...@@ -208,6 +208,7 @@ void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading ...@@ -208,6 +208,7 @@ void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading
*start = clickwatcher(ev, *start); *start = clickwatcher(ev, *start);
*load = clickwatcher(ev, *load); *load = clickwatcher(ev, *load);
*scoreboard = clickwatcher(ev, *scoreboard);
if (start->over) if (start->over)
draw_button(*start, green, white); draw_button(*start, green, white);
...@@ -219,6 +220,12 @@ void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading ...@@ -219,6 +220,12 @@ void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading
else else
draw_button(*load, red, white); draw_button(*load, red, white);
if (scoreboard->over)
draw_button(*scoreboard, green, white);
else
draw_button(*scoreboard, red, white);
if (start->click) if (start->click)
*moving = true; *moving = true;
else else
...@@ -228,4 +235,9 @@ void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading ...@@ -228,4 +235,9 @@ void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading
*loading = true; *loading = true;
else else
*loading = false; *loading = false;
if (scoreboard->click)
*scoring = true;
else
*scoring = false;
} }
\ No newline at end of file
...@@ -28,6 +28,6 @@ Palyaelem *palyamozgat(Palyaelem *eleje, int x); ...@@ -28,6 +28,6 @@ Palyaelem *palyamozgat(Palyaelem *eleje, int x);
Button clickwatcher(SDL_Event ev, Button button); Button clickwatcher(SDL_Event ev, Button button);
void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading); void menu(SDL_Event ev, Button *start, Button *load, Button *scoreboard, bool *moving, bool *loading, bool *scoring);
#endif //NHF_MOVE_H #endif //NHF_MOVE_H
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment