Adding prefabs

This commit is contained in:
Tristan Roux
2019-12-03 18:54:29 +01:00
parent e93dac35b0
commit aa97147dcc
7 changed files with 22 additions and 5 deletions
+6
View File
@@ -0,0 +1,6 @@
{
"files.associations": {
"position_component.h": "c",
"movable_component.h": "c"
}
}
+1 -1
View File
@@ -11,4 +11,4 @@
#include "scene.h"
int start_game(void);
gc_scene *create_game_scene(void);
gc_scene *create_game_scene(gc_engine *engine);
Submodule lib/gamacon updated: 7964f4ead3...cae301c417
View File
+4
View File
@@ -0,0 +1,4 @@
0:
PositionComponent 0,0
MovableComponent Q D Z
TextureRenderer assets/sprites/bck_layer1.png
+5 -2
View File
@@ -11,9 +11,12 @@
int start_game(void)
{
gc_engine *engine = engine_create("Runner");
gc_scene *scene = create_game_scene();
gc_scene *scene;
if (!engine || !scene)
if (!engine)
return (ERROR);
scene = create_game_scene(engine);
if (!scene)
return (ERROR);
engine->change_scene(engine, scene);
while (engine->is_open(engine)) {
+5 -1
View File
@@ -6,17 +6,21 @@
*/
#include "scene.h"
#include "prefab.h"
#include <stddef.h>
static const char *textures[] = {"assets/sprites/bck_layer1.png", \
"assets/sprites/bck_layer2.png", "assets/sprites/bck_layer3.png", \
"assets/sprites/bck_layer4.png", NULL};
gc_scene *create_game_scene(void)
gc_scene *create_game_scene(gc_engine *engine)
{
gc_scene *scene = scene_create(textures);
gc_entity *entity;
if (!scene)
return (NULL);
entity = prefab_load(engine, "prefabs/player.gcprefab");
scene->add_entity(scene, entity);
return (scene);
}