Created
November 10, 2020 00:15
-
-
Save AlabasterAxe/57ef60773a92c84dd8d03d19e5431a70 to your computer and use it in GitHub Desktop.
Implementation of the ground for Flutter Dino Game
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
Sprite groundSprite = Sprite() | |
..imagePath = "assets/images/ground.png" | |
..imageWidth = 2399 | |
..imageHeight = 24; | |
class Ground extends GameObject { | |
// this is a logical location which is translated to pixel coordinates | |
final Offset location; | |
Ground({this.location}); | |
@override | |
Rect getRect(Size screenSize, double runDistance) { | |
return Rect.fromLTWH( | |
(location.dx - runDistance) 10, | |
4 / 7 screenSize.height - groundSprite.imageHeight - location.dy, | |
groundSprite.imageWidth.toDouble(), | |
groundSprite.imageHeight.toDouble()); | |
} | |
@override | |
Widget render() { | |
return Image.asset( | |
groundSprite.imagePath, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment