Skip to content

Commit

Permalink
Add new state for resource collection
Browse files Browse the repository at this point in the history
  • Loading branch information
z-silver committed Feb 4, 2025
1 parent d064f35 commit 6a8f700
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/src/game/animation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub const character = struct {
const frameCount: i32 = @intCast(anims[1].frameCount);
if (animFrameCounter.* >= frameCount) animFrameCounter.* = 0;
},
.idle => {
.idle, .collecting_resource => {
if (entity.model) |model| rl.updateModelAnimation(model, anims[0], 0);
},
}
Expand Down
10 changes: 6 additions & 4 deletions client/src/game/character.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ pub const Chat = struct {
mode: chat.Mode = .idle,
};

pub const State = enum {
walking,
idle,
collecting_resource,
};

pub const Animation = struct {
pub const State = enum {
walking,
idle,
};
frameCounter: i32 = 0,
frames: []rl.ModelAnimation = &.{},
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/server/messages.zig
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub const Character_Info = struct {
y_velocity: f32 = 0,
face_direction: i16 = 270,
map_name: [:0]const u8 = "",
state_type: GameCharacter.Animation.State = .idle,
state_type: GameCharacter.State = .idle,
};

pub const Characters_Request = struct {
Expand Down Expand Up @@ -165,7 +165,7 @@ pub const Character_Update = struct {
username: []const u8,
face_direction: i16,
email: []const u8,
state_type: GameCharacter.Animation.State,
state_type: GameCharacter.State,
};

// Central place to send game's data
Expand Down
3 changes: 2 additions & 1 deletion server/database/migrations/000004_character.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
DROP TYPE IF EXISTS "character.STATE_TYPE";
CREATE TYPE character.STATE_TYPE AS ENUM(
'idle',
'walking'
'walking',
'collecting_resource'
);

CREATE TABLE character.instance(
Expand Down

0 comments on commit 6a8f700

Please sign in to comment.