Skip to content

Commit

Permalink
Group can stand on foundations
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipChalupa committed Jan 28, 2025
1 parent d8f6d63 commit 4bcc988
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Components/Environment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ const In: FunctionComponent<ComponentProps<typeof Environment>> = ({
)
}

const canStandOn = (type: EnvironmentFoundation | undefined) =>
type === 'grass' || type === 'floor'

const loop = (lastRunSuccess: null | boolean) => {
if (lastRunSuccess !== null) {
if (lastRunSuccess) {
Expand Down Expand Up @@ -223,7 +226,7 @@ const In: FunctionComponent<ComponentProps<typeof Environment>> = ({
success = false
}
} else if (instruction.type === 'go_forward') {
if (nextSegment === 'grass' && !nextElements.includes('thicket')) {
if (canStandOn(nextSegment) && !nextElements.includes('thicket')) {
playerPosition.x++
animation = 'goForward'
} else if (nextElements.includes('hole')) {
Expand All @@ -233,7 +236,7 @@ const In: FunctionComponent<ComponentProps<typeof Environment>> = ({
warnAboutImpossibleMove()
}
} else if (instruction.type === 'jump') {
if (nextSegment === 'grass' && !nextElements.includes('thicket')) {
if (canStandOn(nextSegment) && !nextElements.includes('thicket')) {
playerPosition.x++
animation = 'jump'
if (!nextElements.includes('hole')) {
Expand Down

0 comments on commit 4bcc988

Please sign in to comment.