Skip to content

Commit

Permalink
Reworked States
Browse files Browse the repository at this point in the history
Added a Stand state used for grazing with the horses. Now they eat facing either direction. Also reworked states to slow them down a bit and emphasize grazing. Wowee!
  • Loading branch information
thechriskent committed Jun 3, 2024
1 parent 923e433 commit 3f11edc
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The forest theme was designed by [edermunizz](https://edermunizz.itch.io/free-pi

The turtle animations were designed by enkeefe using [Pixelart](https://www.pixilart.com/draw).

The tiny-horse animations were adapted by [Chris Kent](https://github.com/thechriskent) from assets by [Onfe](https://onfe.itch.io/horse-sprite-with-rider-asset-pack).
The horse animations were adapted by [Chris Kent](https://github.com/thechriskent) from assets by [Onfe](https://onfe.itch.io/horse-sprite-with-rider-asset-pack).

## Thank you

Expand Down
Binary file modified media/horse/black_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/black_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/brown_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/brown_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/magical_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/magical_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/paint_beige_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/paint_beige_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/paint_black_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/paint_black_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/paint_brown_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/paint_brown_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/socks_beige_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/socks_beige_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/socks_black_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/socks_black_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/socks_brown_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/socks_brown_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/warrior_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/warrior_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/horse/white_idle_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/horse/white_stand_8fps.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 48 additions & 11 deletions src/panel/pets/horse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,47 +51,84 @@ export class Horse extends BasePetType {
PetColor.warrior,
];
sequence = {
startingState: States.sitIdle,
startingState: States.standRight,
sequenceStates: [
{
state: States.sitIdle,
possibleNextStates: [States.walkRight, States.runRight],
// Only on first adding the horse
possibleNextStates: [States.walkRight],
},
{
state: States.standRight,
// Can start walking either direction (twice as likely to keep going right), or just keep on eating
possibleNextStates: [
States.walkRight,
States.walkRight,
States.walkLeft,
States.standRight,
],
},
{
state: States.standLeft,
// Can start walking either direction (twice as likely to keep going left), or just keep on eating
possibleNextStates: [
States.walkRight,
States.walkLeft,
States.walkLeft,
States.standLeft,
],
},
{
state: States.walkRight,
possibleNextStates: [States.walkLeft, States.runLeft],
// Can switch directions, start running the same direction, or start eating (twice as likely)
possibleNextStates: [
States.walkLeft,
States.runRight,
States.standRight,
States.standRight,
],
},
{
state: States.runRight,
possibleNextStates: [States.walkLeft, States.runLeft],
// Can switch directions or slow down to a walk (twice as likely)
possibleNextStates: [
States.walkRight,
States.walkRight,
States.runLeft,
],
},
{
state: States.walkLeft,
// Can switch directions, start running the same direciton, or start eating (twice as likely)
possibleNextStates: [
States.sitIdle,
States.walkRight,
States.runRight,
States.runLeft,
States.standLeft,
States.standLeft,
],
},
{
state: States.runLeft,
// Can switch directions or slow down to a walk (twice as likely)
possibleNextStates: [
States.sitIdle,
States.walkRight,
States.walkLeft,
States.walkLeft,
States.runRight,
],
},
{
state: States.chase,
// After the chase, the horse has the ball!
possibleNextStates: [States.idleWithBall],
},
{
state: States.idleWithBall,
// Can go back to running or have a bite to eat
possibleNextStates: [
States.walkRight,
States.walkLeft,
States.runLeft,
States.runRight,
States.runLeft,
States.standRight,
States.standLeft,
],
},
],
Expand Down
20 changes: 20 additions & 0 deletions src/panel/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export const enum States {
idleWithBall = 'idle-with-ball',
chase = 'chase',
chaseFriend = 'chase-friend',
standRight = 'stand-right',
standLeft = 'stand-left',
}

export enum FrameResult {
Expand Down Expand Up @@ -138,6 +140,10 @@ export function resolveState(state: string, pet: IPetType): IState {
return new IdleWithBallState(pet);
case States.chaseFriend:
return new ChaseFriendState(pet);
case States.standRight:
return new StandRightState(pet);
case States.standLeft:
return new StandLeftState(pet);
}
return new SitIdleState(pet);
}
Expand Down Expand Up @@ -399,3 +405,17 @@ export class JumpDownLeftState implements IState {
return FrameResult.stateContinue;
}
}

export class StandRightState extends AbstractStaticState {
label = States.standRight;
spriteLabel = 'stand';
horizontalDirection = HorizontalDirection.right;
holdTime = 60;
}

export class StandLeftState extends AbstractStaticState {
label = States.standRight;
spriteLabel = 'stand';
horizontalDirection = HorizontalDirection.left;
holdTime = 60;
}
10 changes: 9 additions & 1 deletion src/test/gifs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,15 @@ const pets: { [key: string]: { colors: string[]; states: string[] } } = {
'magical',
'warrior',
],
states: ['idle', 'run', 'swipe', 'walk', 'walk_fast', 'with_ball'],
states: [
'idle',
'run',
'swipe',
'walk',
'walk_fast',
'with_ball',
'stand',
],
},
};

Expand Down

0 comments on commit 3f11edc

Please sign in to comment.