Allowing the camera to move

This commit is contained in:
AnonymusRaccoon
2020-03-12 16:48:23 +01:00
parent cbad8113d0
commit b6298c95a0
4 changed files with 14 additions and 2 deletions
+2 -1
View File
@@ -31,11 +31,12 @@
</tiles> </tiles>
</data> </data>
<gc_entities> <gc_entities>
<camera x="0" y="300" />
<gc_entity> <gc_entity>
<clickable_component click="map_manage_click"/> <clickable_component click="map_manage_click"/>
<map_manager_component /> <map_manager_component />
<transform_component> <transform_component>
<Position x="25" y="320" /> <Position x="0" y="0" />
<Size x="100000000" y="100000000" /> <Size x="100000000" y="100000000" />
</transform_component> </transform_component>
<vertex_component tilemap="prefabs/tilemap.gcmap" /> <vertex_component tilemap="prefabs/tilemap.gcmap" />
+1
View File
@@ -5,6 +5,7 @@
<font src="assets/fonts/roboto.ttf" /> <font src="assets/fonts/roboto.ttf" />
</data> </data>
<gc_entities> <gc_entities>
<camera x="0" y="0" />
<panel src="panel" x="50%" y="45%" width="300" height="69%"/> <panel src="panel" x="50%" y="45%" width="300" height="69%"/>
<text text="DPR tycoon" x="50%" y="25%" resize="false"/> <text text="DPR tycoon" x="50%" y="25%" resize="false"/>
<button text="Start Game" x="50%" y="50%" click="start_button" color="black" width="200" resize="false" /> <button text="Start Game" x="50%" y="50%" click="start_button" color="black" width="200" resize="false" />
+10
View File
@@ -3,6 +3,7 @@
// //
#include <components/tag_component.h> #include <components/tag_component.h>
#include <systems/sfml_renderer_system.h>
#include "my.h" #include "my.h"
#include "prefab.h" #include "prefab.h"
#include "keybindings.h" #include "keybindings.h"
@@ -39,6 +40,7 @@ static void update_entity(gc_engine *engine, void *system, gc_entity *entity, \
float dtime) float dtime)
{ {
struct game_manager *manager = GETCMP(entity, game_manager); struct game_manager *manager = GETCMP(entity, game_manager);
struct sfml_renderer_system *rend = GETSYS(engine, sfml_renderer_system);
gc_scene *gameover_scene = NULL; gc_scene *gameover_scene = NULL;
if (manager->happiness <= 0) if (manager->happiness <= 0)
@@ -48,6 +50,14 @@ float dtime)
if (gameover_scene) if (gameover_scene)
engine->change_scene(engine, gameover_scene); engine->change_scene(engine, gameover_scene);
if (engine->is_keypressed(sfKeyLeft))
sfView_move(rend->view, (sfVector2f){-10, 0});
if (engine->is_keypressed(sfKeyRight))
sfView_move(rend->view, (sfVector2f){10, 0});
if (engine->is_keypressed(sfKeyDown))
sfView_move(rend->view, (sfVector2f){0, 10});
if (engine->is_keypressed(sfKeyUp))
sfView_move(rend->view, (sfVector2f){0, -10});
} }
static void ctr(void *system, va_list list) static void ctr(void *system, va_list list)