diff options
| author | Giuseppe Gadola <giusgadola@gmail.com> | 2023-03-05 09:49:32 +0100 |
|---|---|---|
| committer | Giuseppe Gadola <giusgadola@gmail.com> | 2023-03-06 13:48:27 +0100 |
| commit | 347e7c33926918df84a3e3721ec6734083ca5e6a (patch) | |
| tree | e43fc803647a897ffeefdcb591fc60bdea49e297 /lua | |
| parent | fix: extend pet-specific table to not raise errors (diff) | |
feat(animations): added left movements
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/pets/animations.lua | 36 | ||||
| -rw-r--r-- | lua/pets/pets/dog.lua | 12 |
2 files changed, 43 insertions, 5 deletions
diff --git a/lua/pets/animations.lua b/lua/pets/animations.lua index 9118523..effa001 100644 --- a/lua/pets/animations.lua +++ b/lua/pets/animations.lua @@ -204,12 +204,44 @@ function M.Animation:set_next_col() end elseif vim.tbl_contains(self.movements.right.slow, self.current_action) then if self.col < self.popup.win_config.width - 8 then - if self.frame_counter % 2 == 0 or self.repetitions % 2 == 0 then - self.col = self.col + 1 + if #self.frames[self.current_action] < 2 then -- if there is only one frame in the current action + if self.repetitions % 2 == 0 then -- then use repetitions as a counter + self.col = self.col + 1 + end + else + if self.frame_counter % 2 == 0 then + self.col = self.col + 1 + end end else self.col = M.base_col end + elseif vim.tbl_contains(self.movements.left.normal, self.current_action) then + if self.col > M.base_col then + self.col = self.col - 1 + else + self.col = self.popup.win_config.width - 8 + end + elseif vim.tbl_contains(self.movements.left.fast, self.current_action) then + if self.col > M.base_col then + self.col = self.col - 2 + else + self.col = self.popup.win_config.width - 8 + end + elseif vim.tbl_contains(self.movements.left.slow, self.current_action) then + if self.col > M.base_col then + if #self.frames[self.current_action] < 2 then -- if there is only one frame in the current action + if self.repetitions % 2 == 0 then -- then use repetitions as a counter + self.col = self.col - 1 + end + else + if self.frame_counter % 2 == 0 then + self.col = self.col - 1 + end + end + else + self.col = self.popup.win_config.width - 8 + end end end diff --git a/lua/pets/pets/dog.lua b/lua/pets/pets/dog.lua index 80f04da..a5890c2 100644 --- a/lua/pets/pets/dog.lua +++ b/lua/pets/pets/dog.lua @@ -1,11 +1,13 @@ return { next_actions = { - idle = { "sit", "liedown", "walk", "run", "pee" }, + idle = { "sit", "liedown", "walk", "run", "pee", "walk_left" }, liedown = { "sit", "idle" }, - pee = { "idle", "sit" }, - run = { "walk", "idle" }, + pee = { "idle", "sit", "walk" }, + run = { "walk", "idle", "run_left" }, sit = { "walk", "liedown", "pee" }, walk = { "run", "idle" }, + run_left = { "walk_left", "run" }, + walk_left = { "run_left", "idle" }, }, idle_actions = { "idle", "sit", "liedown" }, movements = { @@ -13,5 +15,9 @@ return { normal = { "walk" }, fast = { "run" }, }, + left = { + normal = { "walk_left" }, + fast = { "run_left" }, + }, }, } |