Skip to content
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

[pull] master from RafaelBarbosatec:master #171

Merged
merged 37 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
eadad76
chore: init shader
RafaelBarbosatec Nov 12, 2024
9e69d1e
chore: finish v1
RafaelBarbosatec Nov 12, 2024
0008e42
chore: init shader
RafaelBarbosatec Nov 12, 2024
11addd7
chore: update
RafaelBarbosatec Nov 12, 2024
a42dd98
chore: finaliza test
RafaelBarbosatec Nov 12, 2024
254ed63
chore: organiza arquivos
RafaelBarbosatec Nov 12, 2024
3425934
chore: update example
RafaelBarbosatec Nov 13, 2024
f4cd4eb
chore: init v2
RafaelBarbosatec Nov 13, 2024
c2f8933
chore: finish v2
RafaelBarbosatec Nov 13, 2024
dd2f302
finish UseShader
RafaelBarbosatec Nov 14, 2024
95370ed
update readme
RafaelBarbosatec Nov 14, 2024
501171f
adiciona variaveis
RafaelBarbosatec Nov 14, 2024
60b2e86
adds ShaderSetter
RafaelBarbosatec Nov 14, 2024
849db5e
shader example improvements
RafaelBarbosatec Nov 14, 2024
2f441a1
chore: finish example
RafaelBarbosatec Nov 14, 2024
a0a3f33
chore: increment version
RafaelBarbosatec Nov 14, 2024
7485938
Merge pull request #565 from RafaelBarbosatec/develop
RafaelBarbosatec Nov 14, 2024
64e4778
update action
RafaelBarbosatec Nov 14, 2024
34a12e8
Fix minimap issues with non-1.0 zoom
qulvmp6 Nov 15, 2024
1ce240c
added a description of the change under `[next]` in `CHANGELOG.md`.
qulvmp6 Nov 15, 2024
19e6aee
Merge pull request #566 from qulvmp6/master
RafaelBarbosatec Nov 15, 2024
c9ba42c
chore: code improvements
RafaelBarbosatec Nov 15, 2024
09a1cf0
chore: pequenos ajustes
RafaelBarbosatec Nov 15, 2024
cdf3a1e
chore: melhorias
RafaelBarbosatec Nov 16, 2024
8d26420
chore: fix onGameMounted
RafaelBarbosatec Nov 16, 2024
be00c71
chore: changelog
RafaelBarbosatec Nov 16, 2024
57574b1
format
RafaelBarbosatec Nov 16, 2024
bffb05a
Merge pull request #567 from RafaelBarbosatec/develop
RafaelBarbosatec Nov 16, 2024
89cbd18
publish
RafaelBarbosatec Nov 16, 2024
87e6bae
publish
RafaelBarbosatec Nov 16, 2024
da7fecf
pusblish
RafaelBarbosatec Nov 16, 2024
939a3b9
chore: random movement improvements
RafaelBarbosatec Nov 18, 2024
a8188e1
chore: increment version
Nov 22, 2024
f444b63
Merge pull request #568 from RafaelBarbosatec/develop
RafaelBarbosatec Nov 22, 2024
d888a97
chore: publish on release
Nov 22, 2024
5430e6e
fix: directions on random_movement
Nov 22, 2024
b97a534
Merge pull request #569 from RafaelBarbosatec/develop
RafaelBarbosatec Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ on:

jobs:
publish:

permissions:
id-token: write # Required for authentication using OIDC
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Intall dart
uses: dart-lang/setup-dart@v1
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: Publish
uses: sakebook/actions-flutter-pub-publisher@v1.4.1
with:
credential: ${{ secrets.CREDENTIAL_JSON }}
flutter_package: true
skip_test: true
dry_run: true
run: flutter pub publish --force
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 3.12.3
- `RandomMovement` improvements

# 3.12.1
- Resolve the alignment and visibility issues when using the MiniMap widget with non-1.0 zoom values. Thanks [qulvmp6](https://github.com/qulvmp6)
- Adds `randomMovementArea` param in `RandomMovement` mixin.

# 3.12.0
- Adds `UseShader` mixin.

# 3.11.0
- Adds `MapNavigator`. Structure to facilitate map navigations.
- Update `MultiScenario` example to use `MapNavigator`.
Expand Down
Binary file added example/assets/images/noise/gradiente_noise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/assets/images/noise/value_noise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
184 changes: 184 additions & 0 deletions example/assets/images/solaria/map.tmj

Large diffs are not rendered by default.

Binary file added example/assets/images/solaria/solaria_tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions example/assets/images/solaria/solaria_tiles.tsj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ "columns":56,
"image":"solaria_tiles.png",
"imageheight":240,
"imagewidth":448,
"margin":0,
"name":"solaria_tiles",
"spacing":0,
"tilecount":1680,
"tiledversion":"1.10.2",
"tileheight":8,
"tilewidth":8,
"type":"tileset",
"version":"1.10"
}
21 changes: 12 additions & 9 deletions example/lib/pages/enemy/melee_enemy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ class MeleeEnemy extends SimpleEnemy {

@override
void update(double dt) {
seeAndMoveToPlayer(closePlayer: (p) {
animation?.showStroke(Colors.white, 1);
if (checkInterval('attack', 600, dt)) {
_playAttackAnimation();
}
}, notObserved: () {
animation?.hideStroke();
return true;
});
seeAndMoveToPlayer(
closePlayer: (p) {
animation?.showStroke(Colors.white, 1);
if (checkInterval('attack', 600, dt)) {
_playAttackAnimation();
}
},
notObserved: () {
animation?.hideStroke();
return true;
},
);
super.update(dt);
}

Expand Down
11 changes: 11 additions & 0 deletions example/lib/pages/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'package:example/pages/path_finding/path_finding_page.dart';
import 'package:example/pages/player/platform/platform_player_page.dart';
import 'package:example/pages/player/rotation/rotation_player_page.dart';
import 'package:example/pages/player/simple/simple_player_page.dart';
import 'package:example/pages/shader/shader_page.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

Expand Down Expand Up @@ -255,6 +256,16 @@ class _HomePageState extends State<HomePage> {
),
],
),
SectionDrawer(
itens: [
ItemDrawer(
name: 'Shader',
builder: (_) => const ShaderPage(),
codeUrl:
'https://github.com/RafaelBarbosatec/bonfire/blob/develop/example/lib/pages/shader',
),
],
),
SectionDrawer(
name: 'Parallax',
itens: [
Expand Down
4 changes: 3 additions & 1 deletion example/lib/pages/player/simple/human.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:bonfire/bonfire.dart';
import 'package:example/shared/util/person_sprite_sheet.dart';

Expand All @@ -12,7 +14,7 @@ class HumanPlayer extends SimplePlayer with BlockMovementCollision {
);

@override
Future<void> onLoad() {
Future<void> onLoad() async {
/// Adds rectangle collision
add(
RectangleHitbox(
Expand Down
49 changes: 49 additions & 0 deletions example/lib/pages/shader/shader_config_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:bonfire/bonfire.dart';
import 'package:flutter/widgets.dart';

class ShaderConfig {
final double distortionStrength;
final Color toneColor;
final Color lightColor;
final double speed;
final double opacity;
final Vector2 lightRange;

ShaderConfig({
this.distortionStrength = 0.05,
this.toneColor = const Color(0xFF5ca4ec),
this.lightColor = const Color(0xFFffffff),
this.speed = 0.04,
this.opacity = 0.7,
Vector2? lightRange,
}) : lightRange = lightRange ?? Vector2(0.4, 0.5);

ShaderConfig copyWith({
double? distortionStrength,
Color? toneColor,
Color? lightColor,
double? speed,
double? opacity,
Vector2? lightRange,
}) {
return ShaderConfig(
distortionStrength: distortionStrength ?? this.distortionStrength,
toneColor: toneColor ?? this.toneColor,
lightColor: lightColor ?? this.lightColor,
speed: speed ?? this.speed,
opacity: opacity ?? this.opacity,
lightRange: lightRange ?? this.lightRange,
);
}
}

class ShaderConfigController extends ChangeNotifier {
ShaderConfig _config = ShaderConfig();
ShaderConfig get config => _config;

void update(ShaderConfig config) {
_config = config;
notifyListeners();
}
}
218 changes: 218 additions & 0 deletions example/lib/pages/shader/shader_config_panel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
import 'package:bonfire/bonfire.dart';
import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';

import 'shader_config_controller.dart';

class ShaderConfigPanel extends StatefulWidget {
final ShaderConfigController controller;
const ShaderConfigPanel({super.key, required this.controller});

@override
State<ShaderConfigPanel> createState() => _ShaderConfigPanelState();
}

class _ShaderConfigPanelState extends State<ShaderConfigPanel> {
late double speed;
late double distortionStrength;
late double opacity;
late Color toneColor;
late Color lightColor;
late Vector2 lightRange;

@override
void initState() {
speed = widget.controller.config.speed;
distortionStrength = widget.controller.config.distortionStrength;
toneColor = widget.controller.config.toneColor;
lightColor = widget.controller.config.lightColor;
opacity = widget.controller.config.opacity;
lightRange = widget.controller.config.lightRange;
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Speed: ${speed.toStringAsFixed(3)}'),
Slider(
value: speed,
min: 0,
max: 0.5,
onChanged: (value) {
setState(() {
speed = value;
});
widget.controller.update(
widget.controller.config.copyWith(
speed: speed,
),
);
},
),
Text(
'Distortion Strength: ${distortionStrength.toStringAsFixed(3)}'),
Slider(
value: distortionStrength,
min: 0,
max: 0.5,
onChanged: (value) {
setState(() {
distortionStrength = value;
});
widget.controller.update(
widget.controller.config.copyWith(
distortionStrength: distortionStrength,
),
);
},
),
Text('Opacity: ${opacity.toStringAsFixed(3)}'),
Slider(
value: opacity,
min: 0,
max: 1,
onChanged: (value) {
setState(() {
opacity = value;
});
widget.controller.update(
widget.controller.config.copyWith(
opacity: opacity,
),
);
},
),
Text(
'Light range: min${lightRange.x.toStringAsFixed(3)} | max${lightRange.y.toStringAsFixed(3)}'),
RangeSlider(
values: RangeValues(lightRange.x, lightRange.y),
min: 0,
max: 1,
onChanged: (value) {
setState(() {
lightRange = Vector2(value.start, value.end);
});
widget.controller.update(
widget.controller.config.copyWith(
lightRange: lightRange,
),
);
},
),
const SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
const Text('Tone color'),
const SizedBox(
width: 16,
),
InkWell(
onTap: () {
showColorPicker(
toneColor,
(value) {
setState(() {
toneColor = value;
});
widget.controller.update(
widget.controller.config.copyWith(
toneColor: toneColor,
),
);
},
);
},
child: Container(
decoration: BoxDecoration(
color: toneColor,
shape: BoxShape.circle,
),
width: 30,
height: 30,
),
),
],
),
),
const SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
const Text('Light color'),
const SizedBox(
width: 16,
),
InkWell(
onTap: () {
showColorPicker(
lightColor,
(value) {
setState(() {
lightColor = value;
});
widget.controller.update(
widget.controller.config.copyWith(
lightColor: lightColor,
),
);
},
);
},
child: Container(
decoration: BoxDecoration(
color: lightColor,
shape: BoxShape.circle,
),
width: 30,
height: 30,
),
),
],
),
)
],
),
),
),
);
}

void showColorPicker(Color color, ValueChanged<Color> onChange) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Pick a color!'),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: color,
onColorChanged: onChange,
),
),
actions: <Widget>[
ElevatedButton(
child: const Text('Got it'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
}
Loading
Loading