-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adding custom classes and types #14
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
22531e2
feat: adding custom classes and types
erickzanardo f2c5c2d
fix format
erickzanardo cb9be61
apply PR suggestions
erickzanardo cc44a75
update README
erickzanardo bd937e3
pr suggestions
erickzanardo 7176d95
pr suggestions
erickzanardo d583ea1
linter
erickzanardo 0cafda3
making config belong to the game
erickzanardo f67f371
making config belong to the game
erickzanardo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/// A configurable class that allows the developer to | ||
/// customize names and classes that Leap will look for | ||
/// when reading the map. | ||
class LeapOptions { | ||
const LeapOptions({ | ||
this.groundLayerName = 'Ground', | ||
this.metadataLayerName = 'Metadata', | ||
this.playerSpawnClass = 'PlayerSpawn', | ||
this.hazardClass = 'Hazard', | ||
this.damageProperty = 'Damage', | ||
this.platformClass = 'Platform', | ||
this.slopeType = 'Slope', | ||
this.slopeRightTopProperty = 'RightTop', | ||
this.slopeLeftTopProperty = 'LeftTop', | ||
}); | ||
|
||
/// The default options for Leap. | ||
static LeapOptions defaults = const LeapOptions(); | ||
|
||
/// Which layer name should be used for the player, defaults to "Ground". | ||
final String groundLayerName; | ||
|
||
/// Which layer name should be used for the metadata, defaults to "Metadata". | ||
final String metadataLayerName; | ||
|
||
/// Which class name should be used for the player spawn point, | ||
/// defaults to "PlayerSpawn". | ||
final String playerSpawnClass; | ||
|
||
/// Whick class name represents hazard objects, defaults to "Hazard". | ||
final String hazardClass; | ||
|
||
/// Which property name represents damage, defaults to "Damage". | ||
final String damageProperty; | ||
|
||
/// Which class name represents platform objects, defaults to "Platform". | ||
final String platformClass; | ||
|
||
/// Which property name represents the slope type, defaults to "Slope". | ||
final String slopeType; | ||
|
||
/// Which property name represents the slope left bottom, defaults to | ||
/// "RightTop". | ||
final String slopeRightTopProperty; | ||
|
||
/// Which property name represents the slope right bottom, defaults to | ||
/// "LeftTop". | ||
final String slopeLeftTopProperty; | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only qualm with this PR is the API to set the values...
Setting
LeapOptions.defaults
feels awkward, especially because if you are changing the defaults, does that mean the original values are the "default defaults"?Anyways, maybe a function instead would be better, like
LeapOptions.changeTiledConstants(...)
? Or LeapOptions could be a value on LeapGame, and you just set LeapGame.options to a new instance? Leaning towards the second option since the game ref is everywhere anywaysThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it might be good to differentiate between Leap Tiled options and other options (like physics etc), but that's probably premature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was on the fence about the naming, I tried a different approach now, let me know what you think of it, I have also prepared for the future in case we want to have multiple type of configurations, not only about tiled.