Adding a quit button

This commit is contained in:
AnonymusRaccoon
2020-02-27 14:33:52 +01:00
parent 3294b6a386
commit 070f454300
5 changed files with 14 additions and 4 deletions
+2 -1
View File
@@ -12,4 +12,5 @@
int start_game();
void start_button(gc_engine *engine, int entity_id);
bool start_button(gc_engine *engine, int entity_id);
bool quit(gc_engine *engine, int entity_id);
+2 -1
View File
@@ -5,8 +5,9 @@
<font src="assets/fonts/roboto.ttf" />
</data>
<gc_entities>
<panel src="panel" x="50%" y="40%" width="300" height="50%"/>
<panel src="panel" x="50%" y="40%" width="300" height="55%"/>
<text text="DPR tycoon" x="50%" y="25%"/>
<button text="Start Game" x="50%" y="50%" click="start_button" color="black" />
<button text="Quit game" x="50%" y="60%" click="quit" color="black" />
</gc_entities>
</gc_scene>
+1
View File
@@ -13,6 +13,7 @@ int register_customcmps(gc_engine *engine)
{
engine->finish_physics(engine);
engine->add_callback(engine, "start_button", &start_button);
engine->add_callback(engine, "quit", &quit);
return (0);
}
+8 -1
View File
@@ -6,7 +6,7 @@
#include "scene.h"
#include "my.h"
void start_button(gc_engine *engine, int entity_id)
bool start_button(gc_engine *engine, int entity_id)
{
gc_scene *scene = scene_create(engine, "prefabs/game.gcprefab");
if (!scene) {
@@ -14,4 +14,11 @@ void start_button(gc_engine *engine, int entity_id)
my_printf("The game scene couldn't be found.\n");
}
engine->change_scene(engine, scene);
return (true);
}
bool quit(gc_engine *engine, int entity_id)
{
engine->should_close = true;
return (true);
}