This repository was archived by the owner on Sep 24, 2022. It is now read-only.
Open
Conversation
magicoder10
suggested changes
Apr 3, 2021
| } | ||
|
|
||
| func (d deadState) draw(batch graphics.Batch) { | ||
| if d.lag <= TombstoneImageDuration { |
Owner
There was a problem hiding this comment.
Suggested change
| if d.lag <= TombstoneImageDuration { | |
| if d.lag <= TombstoneImageDuration { |
Let's put this in update and create a new field called: shouldShow. Then use it here for guarding
Comment on lines
+13
to
+15
| func (ts Tombstone) getWidth() int { | ||
| return ts.width | ||
| } |
Owner
There was a problem hiding this comment.
Suggested change
| func (ts Tombstone) getWidth() int { | |
| return ts.width | |
| } |
We can directly access width in the same package
| *sharedState | ||
| jelly *Jelly | ||
| prevDirection direction.Direction | ||
| trappedLag int64 |
Owner
There was a problem hiding this comment.
Suggested change
| trappedLag int64 | |
| lag int64 |
|
|
||
| func (s sharedState) update(timeElapsed time.Duration) { | ||
| return | ||
| showMarker bool |
Owner
There was a problem hiding this comment.
Suggested change
| showMarker bool |
| } | ||
|
|
||
| func (s *sharedState) shouldShowMarker() bool { | ||
| return s.showMarker |
Owner
There was a problem hiding this comment.
Suggested change
| return s.showMarker | |
| return true |
| func (t *trappedState) update(timeElapsed time.Duration) state { | ||
| t.trappedLag += timeElapsed.Nanoseconds() | ||
| if t.trappedLag >= trapTimeOut { | ||
| t.showMarker = false |
Owner
There was a problem hiding this comment.
I mean you already entered dead state. Dead state will take care of the marker.
| availableCandy: character.initialCandyLimit, | ||
| character: character, | ||
| pubSub: pubSub, | ||
| showMarker: true, |
Owner
There was a problem hiding this comment.
Suggested change
| showMarker: true, |
| func (d *deadState) update(timeElapsed time.Duration) state { | ||
| d.lag += timeElapsed.Nanoseconds() | ||
| return d | ||
| } |
Owner
There was a problem hiding this comment.
Let's just override shouldShowMarker function and return false.
Co-authored-by: Magic Coder <magicoder20@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Screenshots
High Level
This PR is to move a player to a dead state when the he/she is trapped in the jelly for more than 5 seconds.
Detailed Explanation
Per game rule, a player can die and be removed from the game after being trapped for 5 seconds. I did 3 things:
added a dead state for the player, drawing a tombstone after a player is dead.
removed marker when the player is in the dead state
removed tombstone from the game after 0.5 seconds