bonfire 0.1.1 bonfire: ^0.1.1 copied to clipboard
(RPG maker) Create RPG-style or similar games more simply with Flame.
import 'package:bonfire/bonfire.dart';
import 'package:example/map/dungeon_map.dart';
import 'package:example/player/knight.dart';
import 'package:example/player/knight_interface.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Flame.util.setLandscape();
await Flame.util.fullScreen();
runApp(
MaterialApp(
home: Game(),
),
);
}
class Game extends StatelessWidget {
static const sizeTile = 32.0;
@override
Widget build(BuildContext context) {
return BonfireWidget(
joystick: Joystick(
pathSpriteBackgroundDirectional: 'joystick_background.png',
pathSpriteKnobDirectional: 'joystick_knob.png',
sizeDirectional: 100,
marginLeftDirectional: 150,
actions: [
JoystickAction(
actionId: 0,
pathSprite: 'joystick_atack.png',
size: 80,
margin: EdgeInsets.only(bottom: 50, right: 50),
),
JoystickAction(
actionId: 1,
pathSprite: 'joystick_atack_range.png',
size: 50,
margin: EdgeInsets.only(bottom: 50, right: 160),
)
],
),
player: Knight(
initPosition: Position(5 * sizeTile, 6 * sizeTile),
),
interface: KnightInterface(),
map: DungeonMap.map(),
decorations: DungeonMap.decorations(),
enemies: DungeonMap.enemies(),
background: BackgroundColorGame(Colors.blueGrey[900]),
listener: (context, game) {
// TODO ANYTHING
},
);
}
}