fix(aim): full power reachable, and a tap no longer burns the turn
_maxDragPx was a fixed 260 *logical* pixels. On the test device (1080x2400 at 440 dpi) that is 715 physical pixels - a swipe across two thirds of the screen, which ends at the edge before full power is reached. Players could not hit 100 %. - the pull distance is now relative to the playfield: 30 % of its short edge, at least 80 logical px (~325 physical px here) - verified on the device: a 340 px swipe reaches "MAX" and fires, a 149 px swipe reaches 46 % - the HUD now prints MAX instead of 100 % and highlights it, so reaching full power is unmistakable - a tap without a real pull no longer fires: _dragged guards releaseAim, so a stray touch cannot waste a turn (verified: tap leaves the turn unchanged) - release 0.9.2 (15)
This commit is contained in:
@@ -101,11 +101,18 @@ class IronArcGame extends FlameGame {
|
|||||||
double aimPower = 0.6;
|
double aimPower = 0.6;
|
||||||
bool _dragging = false;
|
bool _dragging = false;
|
||||||
|
|
||||||
/// Pull back to charge: full power at this many screen pixels of drag.
|
/// Pull back to charge. The distance is relative to the playfield, because a
|
||||||
static const double _maxDragPx = 260;
|
/// fixed value is wrong on every other screen: 260 *logical* pixels meant a
|
||||||
|
/// swipe of 715 physical pixels on a 1080x2400 device - two thirds of the
|
||||||
|
/// screen - so full power was unreachable without hitting the edge.
|
||||||
|
double get _maxDragPx => math.max(80, math.min(size.x, size.y) * 0.30);
|
||||||
|
|
||||||
Offset? _dragStart;
|
Offset? _dragStart;
|
||||||
Offset? _dragCurrent;
|
Offset? _dragCurrent;
|
||||||
|
|
||||||
|
/// True once the drag left the dead zone; a stray tap must not fire a shot.
|
||||||
|
bool _dragged = false;
|
||||||
|
|
||||||
double _zoom = 1;
|
double _zoom = 1;
|
||||||
double _camX = 0;
|
double _camX = 0;
|
||||||
double _camY = 0;
|
double _camY = 0;
|
||||||
@@ -203,6 +210,7 @@ class IronArcGame extends FlameGame {
|
|||||||
void beginAim(Offset screen) {
|
void beginAim(Offset screen) {
|
||||||
if (!_match.isAiming) return;
|
if (!_match.isAiming) return;
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
|
_dragged = false;
|
||||||
_dragStart = screen;
|
_dragStart = screen;
|
||||||
_dragCurrent = screen;
|
_dragCurrent = screen;
|
||||||
}
|
}
|
||||||
@@ -218,9 +226,12 @@ class IronArcGame extends FlameGame {
|
|||||||
void releaseAim() {
|
void releaseAim() {
|
||||||
if (!_dragging) return;
|
if (!_dragging) return;
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
|
final fired = _dragged;
|
||||||
|
_dragged = false;
|
||||||
_dragStart = null;
|
_dragStart = null;
|
||||||
_dragCurrent = null;
|
_dragCurrent = null;
|
||||||
if (!_match.isAiming) return;
|
if (!_match.isAiming) return;
|
||||||
|
if (!fired) return; // tap without a pull: keep the turn
|
||||||
final angleMdeg = (aimAngle * 1000).round().clamp(1000, 89000);
|
final angleMdeg = (aimAngle * 1000).round().clamp(1000, 89000);
|
||||||
final powerQ16 = (aimPower * 65536).round().clamp(3277, 65536);
|
final powerQ16 = (aimPower * 65536).round().clamp(3277, 65536);
|
||||||
final before = _match.stateHash();
|
final before = _match.stateHash();
|
||||||
@@ -247,6 +258,7 @@ class IronArcGame extends FlameGame {
|
|||||||
final pull = now - start;
|
final pull = now - start;
|
||||||
// Dead zone: a twitchy finger must not move the reticle.
|
// Dead zone: a twitchy finger must not move the reticle.
|
||||||
if (pull.distance < 6) return;
|
if (pull.distance < 6) return;
|
||||||
|
_dragged = true;
|
||||||
|
|
||||||
final radians = math.atan2(pull.dy, pull.dx.abs());
|
final radians = math.atan2(pull.dy, pull.dx.abs());
|
||||||
aimAngle = (radians * 180 / math.pi).clamp(1.0, 89.0);
|
aimAngle = (radians * 180 / math.pi).clamp(1.0, 89.0);
|
||||||
|
|||||||
@@ -236,8 +236,15 @@ class _PowerMeter extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 5),
|
const SizedBox(width: 5),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 34,
|
width: 38,
|
||||||
child: Text('$pct %', style: const TextStyle(fontSize: 12)),
|
// „MAX" is worth a word: the bar alone made it hard to tell whether
|
||||||
|
// full power had been reached.
|
||||||
|
child: Text(pct >= 99 ? 'MAX' : '$pct %',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: pct >= 99 ? FontWeight.w700 : FontWeight.w400,
|
||||||
|
color: pct >= 99 ? const Color(0xFFFF5A5F) : null,
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 0.9.1+14
|
version: 0.9.2+15
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.13.4
|
sdk: ^3.13.4
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user