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
Branches
No related tags found
1 merge request!5Blint
......@@ -6,15 +6,19 @@
#IncludeRegexTransform:
/home/blint/projects/nhf/move.c
move.h
/home/blint/projects/nhf/move.h
/home/blint/projects/nhf/main.c
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
-
time.h
-
/home/blint/projects/nhf/move.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[]) {
bool quit = false;
bool moving = false;
bool loading = false;
bool scoring = false;
int elozo_x = 0;
int elozo_y = W - 2*owl;
......@@ -67,10 +68,19 @@ int main(int argc, char *argv[]) {
load.click = false;
Button scoreboard;
scoreboard.x = 0;
scoreboard.y = 0;
scoreboard.w = 300;
scoreboard.h = owl;
scoreboard.x = W/6;
scoreboard.y = (3*H/9 + 2*(H/18));
scoreboard.w = (W - W/6) - load.x;
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 white = (Color){255, 255, 255};
......@@ -91,20 +101,20 @@ int main(int argc, char *argv[]) {
if (moving){
move_draw(ev, bagoly, &elozo_x, &elozo_y, platf, itemke);
sprintf(scoreboard.title, "Score: %6d", max_score);
draw_button(scoreboard, green, white);
sprintf(scoretitle.title, "Score: %6d", max_score);
draw_button(scoretitle, green, white);
} else
{
menu(ev, &start, &load, &moving, &loading);
menu(ev, &start, &load, &scoreboard, &moving, &loading, &scoring);
}
SDL_RenderPresent(renderer);
}
printf("Final score: %d\n", score);
SDL_DestroyTexture(bagoly);
freeing(platf);
freeing(itemke);
SDL_Quit();
return 0;
......
......@@ -199,7 +199,7 @@ Button clickwatcher(SDL_Event ev, Button 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 green = (Color){0, 255, 0};
......@@ -208,6 +208,7 @@ void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading
*start = clickwatcher(ev, *start);
*load = clickwatcher(ev, *load);
*scoreboard = clickwatcher(ev, *scoreboard);
if (start->over)
draw_button(*start, green, white);
......@@ -219,6 +220,12 @@ void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading
else
draw_button(*load, red, white);
if (scoreboard->over)
draw_button(*scoreboard, green, white);
else
draw_button(*scoreboard, red, white);
if (start->click)
*moving = true;
else
......@@ -228,4 +235,9 @@ void menu(SDL_Event ev, Button *start, Button *load, bool *moving, bool *loading
*loading = true;
else
*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);
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
\ 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