mirror of
https://github.com/zoriya/Twac.git
synced 2026-05-28 17:03:13 +00:00
Adding a jump animation
This commit is contained in:
+1
-1
Submodule lib/gamacon updated: 836645532a...b6de809b04
+1
-1
Submodule lib/xmlparser updated: 05fec3bfff...29f8d8b910
@@ -7,7 +7,10 @@
|
||||
<renderer src="assets/sprites/player_sheet.png">
|
||||
<Rect width="80" height="100" top="0" left="0" />
|
||||
<animation name="walk" frame_count="2" frame_rate="10">
|
||||
<Rect left="80" />
|
||||
<Rect left="410" />
|
||||
</animation>
|
||||
<animation name="jump" frame_count="1" frame_rate="10">
|
||||
<Rect left="160" />
|
||||
</animation>
|
||||
</renderer>
|
||||
<movable_component />
|
||||
|
||||
@@ -14,16 +14,19 @@
|
||||
#include "components/movable_component.h"
|
||||
#include "components/controllable_component.h"
|
||||
#include "components/jump_action.h"
|
||||
#include "components/renderer.h"
|
||||
#include "utility.h"
|
||||
#include <stddef.h>
|
||||
|
||||
static void update_entity(gc_engine *engine, void *system,
|
||||
gc_entity *entity, float dtime)
|
||||
static void update_entity(gc_engine *engine __attribute__((unused)), \
|
||||
void *system __attribute__((unused)), gc_entity *entity, \
|
||||
float dtime __attribute__((unused)))
|
||||
{
|
||||
struct collision_component *col = GETCMP(collision_component);
|
||||
struct controllable_component *con = GETCMP(controllable_component);
|
||||
struct movable_component *mov = GETCMP(movable_component);
|
||||
struct jump_action *jump = GETCMP(jump_action);
|
||||
struct renderer *rend = GETCMP(renderer);
|
||||
|
||||
if (col->distance_down == 0 && con->jumping) {
|
||||
mov->acceleration.y += jump->acceleration;
|
||||
@@ -37,9 +40,8 @@ gc_entity *entity, float dtime)
|
||||
mov->acceleration.y += jump->acceleration;
|
||||
jump->step--;
|
||||
}
|
||||
(void)system;
|
||||
(void)dtime;
|
||||
(void)engine;
|
||||
if (rend && rend->type == GC_ANIMREND && col->distance_down != 0)
|
||||
rend_set_anim(rend, "jump");
|
||||
}
|
||||
|
||||
static void destroy(void *system)
|
||||
|
||||
Reference in New Issue
Block a user