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
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { |
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
import 'package:flutter/material.dart'; | |
import 'package:flutter/widgets.dart'; | |
import 'common.dart'; | |
class ExplorePage extends StatefulWidget { | |
const ExplorePage({Key key}) : super(key: key); | |
@override | |
_ExplorePageState createState() => _ExplorePageState(); |
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
AnimatedBuilder( | |
animation: cardSwipeAnimationController, | |
builder: (context, snapshot) { | |
Offset translateOffset = Offset.fromDirection(direction, cardAnimationController.value); | |
return Transform.translate( | |
offset: Offset(translateOffset.dx, 0), | |
child: Card( | |
child: Center( | |
child: Text("${widget.displayNumber}", |
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
frame = (elapsedTime.inMilliseconds / 100).floor() % 2 + 3 |
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
@override | |
Rect getRect(Size screenSize, double runDistance) { | |
return Rect.fromLTWH( | |
(location.dx - runDistance) WORLD_TO_PIXEL_RATIO / 5, | |
2 / 7 screenSize.height - cloud.imageHeight - location.dy, | |
cloud.imageWidth.toDouble(), | |
cloud.imageHeight.toDouble()); | |
} |
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
for (GameObject object in [...ground, ...obstacles, dino]) { | |
children.add( | |
AnimatedBuilder( | |
animation: worldController, | |
builder: (context, child) { | |
Rect objectRect = object.getRect(screenSize, runDistance); | |
return Positioned( | |
top: objectRect.top, | |
left: objectRect.left, | |
width: objectRect.width, |
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
if (groundlet.getRect(screenSize, runDistance).right < 0) { | |
setState(() { | |
ground.remove(groundlet); | |
ground.add(Ground( | |
worldLocation: Offset( | |
ground.last.worldLocation.dx + | |
groundSprite.imageWidth / WORLD_TO_PIXEL_RATIO, | |
0))); | |
}); | |
} |
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
ground = [ | |
Ground(location: Offset(0, 0)), | |
Ground( | |
location: Offset(groundSprite.imageWidth / WORLD_TO_PIXEL_RATIO, 0)) | |
]; |
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 |
NewerOlder