-
-
Notifications
You must be signed in to change notification settings - Fork 932
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #475 from flame-engine/develop
0.27.0 release
- Loading branch information
Showing
67 changed files
with
603 additions
and
154 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
#!/bin/bash -xe | ||
|
||
rm -rf */build | ||
rm -rf */android | ||
rm -rf */ios | ||
rm -rf */web | ||
rm -rf */macos | ||
rm -rf */test | ||
rm -rf */.dart_tool | ||
shopt -s globstar | ||
|
||
rm -rf **/build | ||
rm -rf **/android | ||
rm -rf **/ios | ||
rm -rf **/web | ||
rm -rf **/macos | ||
rm -rf **/test | ||
rm -rf **/.dart_tool |
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,54 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flame/game.dart'; | ||
import 'package:flame/gestures.dart'; | ||
import 'package:flame/palette.dart'; | ||
import 'package:flame/position.dart'; | ||
|
||
void main() { | ||
final game = MyGame(); | ||
runApp(game.widget); | ||
} | ||
|
||
class MyGame extends Game with MouseMovementDetector { | ||
static const SPEED = 200; | ||
|
||
Position position = Position(0, 0); | ||
Position target; | ||
|
||
final Paint _blue = Paint()..color = const Color(0xFF0000FF); | ||
|
||
bool _onTarget = false; | ||
|
||
@override | ||
void onMouseMove(event) { | ||
target = Position.fromOffset(event.localPosition); | ||
} | ||
|
||
Rect _toRect() => Rect.fromLTWH( | ||
position.x, | ||
position.y, | ||
50, | ||
50, | ||
); | ||
|
||
@override | ||
void render(Canvas canvas) { | ||
canvas.drawRect( | ||
_toRect(), | ||
_onTarget ? _blue : BasicPalette.white.paint, | ||
); | ||
} | ||
|
||
@override | ||
void update(double dt) { | ||
if (target != null) { | ||
_onTarget = _toRect().contains(target.toOffset()); | ||
|
||
if (!_onTarget) { | ||
final dir = target.clone().minus(position).normalize(); | ||
|
||
position.add(dir.times(SPEED * dt)); | ||
} | ||
} | ||
} | ||
} |
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,44 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flame/game.dart'; | ||
import 'package:flame/gestures.dart'; | ||
import 'package:flame/palette.dart'; | ||
import 'package:flame/position.dart'; | ||
|
||
void main() { | ||
final game = MyGame(); | ||
runApp(game.widget); | ||
} | ||
|
||
class MyGame extends Game with ScrollDetector { | ||
static const SPEED = 200; | ||
|
||
Position position = Position(0, 0); | ||
Position target; | ||
|
||
@override | ||
void onScroll(event) { | ||
target = position.minus(Position.fromOffset(event.scrollDelta)); | ||
} | ||
|
||
@override | ||
void render(Canvas canvas) { | ||
canvas.drawRect( | ||
Rect.fromLTWH( | ||
position.x, | ||
position.y, | ||
50, | ||
50, | ||
), | ||
BasicPalette.white.paint, | ||
); | ||
} | ||
|
||
@override | ||
void update(double dt) { | ||
if (target != null) { | ||
final dir = target.clone().minus(position).normalize(); | ||
|
||
position.add(dir.times(SPEED * dt)); | ||
} | ||
} | ||
} |
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,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: 7fc14a55af64462763d28abfb4e610086c6e0f39 | ||
channel: dev | ||
|
||
project_type: app |
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,3 @@ | ||
# isometric | ||
|
||
A Flame game showcasing how to use the Isometric Tile Map component. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,85 @@ | ||
import 'package:flame/components/component.dart'; | ||
import 'package:flame/flame.dart'; | ||
import 'package:flame/game.dart'; | ||
import 'package:flame/components/isometric_tile_map_component.dart'; | ||
import 'package:flame/gestures.dart'; | ||
import 'package:flame/position.dart'; | ||
import 'package:flame/sprite.dart'; | ||
import 'package:flutter/gestures.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
const x = 500.0; | ||
const y = 500.0; | ||
const s = 64; | ||
final topLeft = Position(x, y); | ||
|
||
void main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
final Size size = await Flame.util.initialDimensions(); | ||
final game = MyGame(size); | ||
runApp(game.widget); | ||
} | ||
|
||
class Selector extends SpriteComponent { | ||
bool show = false; | ||
|
||
Selector(double s) | ||
: super.fromSprite(s, s, Sprite('selector.png', width: 32, height: 32)); | ||
|
||
@override | ||
void render(Canvas canvas) { | ||
if (!show) { | ||
return; | ||
} | ||
|
||
super.render(canvas); | ||
} | ||
} | ||
|
||
class MyGame extends BaseGame with MouseMovementDetector { | ||
IsometricTileMapComponent base; | ||
Selector selector; | ||
|
||
MyGame(Size size) { | ||
init(); | ||
} | ||
|
||
void init() async { | ||
final tileset = await IsometricTileset.load('tiles.png', 32); | ||
final matrix = [ | ||
[3, 1, 1, 1, 0, 0], | ||
[-1, 1, 2, 1, 0, 0], | ||
[-1, 0, 1, 1, 0, 0], | ||
[-1, 1, 1, 1, 0, 0], | ||
[1, 1, 1, 1, 0, 2], | ||
[1, 3, 3, 3, 0, 2], | ||
]; | ||
add( | ||
base = IsometricTileMapComponent(tileset, matrix, destTileSize: s) | ||
..x = x | ||
..y = y, | ||
); | ||
add(selector = Selector(s.toDouble())); | ||
} | ||
|
||
@override | ||
void render(Canvas canvas) { | ||
super.render(canvas); | ||
|
||
canvas.drawRect( | ||
const Rect.fromLTWH(x - 1, y - 1, 3, 3), | ||
Paint()..color = const Color(0xFFFF00FF), | ||
); | ||
} | ||
|
||
@override | ||
void onMouseMove(PointerHoverEvent event) { | ||
if (base == null || selector == null) { | ||
return; // loading | ||
} | ||
final screenPosition = Position.fromOffset(event.position); | ||
final block = base.getBlock(screenPosition); | ||
selector.show = base.containsBlock(block); | ||
selector.setByPosition(base.getBlockPosition(block).add(topLeft)); | ||
} | ||
} |
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,22 @@ | ||
name: isometric | ||
description: Example of isometric tilemap using Flame | ||
|
||
version: 0.1.0 | ||
|
||
environment: | ||
sdk: ">=2.1.0 <3.0.0" | ||
|
||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
flame: | ||
path: ../../../ | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
|
||
flutter: | ||
assets: | ||
- assets/images/tiles.png | ||
- assets/images/selector.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.