fix: fixed collision end from ramps

pull/40/head
RuiAlonso 4 years ago
parent 24ac3ad323
commit aa60ed3454

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"

@ -0,0 +1,41 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

@ -85,16 +85,22 @@ class RampOpeningBallContactCallback<Opening extends RampOpening>
@override
void end(Ball ball, Opening opening, Contact _) {
// TODO(ruimiguel): check what happens with ball that slightly touch
// Opening and goes out again. With InitialPosition change now doesn't work
// position.y comparison
/*
final isBallOutsideOpening = opening.orientation == RampOrientation.up
? ball.body.position.y > opening.initialPosition.y
: ball.body.position.y < opening.initialPosition.y;
if (!ballsInside.contains(ball)) {
ball.layer = Layer.board;
} else {
// TODO(ruimiguel): change this code. Check what happens with ball that
// slightly touch Opening and goes out again. With InitialPosition change
// now doesn't work position.y comparison
final isBallOutsideOpening =
(opening.orientation == RampOrientation.down &&
ball.body.linearVelocity.y < 0) ||
(opening.orientation == RampOrientation.up &&
ball.body.linearVelocity.y > 0);
if (isBallOutsideOpening) ball.layer = Layer.board;
*/
if (!ballsInside.contains(ball)) ball.layer = Layer.board;
if (isBallOutsideOpening) {
ball.layer = Layer.board;
ballsInside.remove(ball);
}
}
}
}

@ -144,9 +144,6 @@ void main() {
callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1);
callback.end(ball, area, MockContact());
verifyNever(() => ball.layer = Layer.board);
});
flameTester.test(
@ -194,9 +191,6 @@ void main() {
callback.begin(ball, area, MockContact());
verify(() => ball.layer = area.pathwayLayer).called(1);
callback.end(ball, area, MockContact());
verifyNever(() => ball.layer = Layer.board);
});
flameTester.test(
@ -220,15 +214,12 @@ void main() {
callback.begin(ball, area, MockContact());
expect(callback.ballsInside.contains(ball), isTrue);
callback.end(ball, area, MockContact());
},
);
flameTester.test(
'removes ball from ballsInside '
'when a ball enters upwards into a down oriented path '
'but falls again outside', (game) async {
'when a ball exits from a downward oriented ramp', (game) async {
final ball = MockBall();
final body = MockBody();
final area = TestRampOpening(
@ -239,6 +230,7 @@ void main() {
when(() => ball.body).thenReturn(body);
when(() => body.position).thenReturn(Vector2.zero());
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
when(() => ball.layer).thenReturn(Layer.board);
await game.ready();
@ -250,17 +242,13 @@ void main() {
expect(callback.ballsInside.length, equals(1));
expect(callback.ballsInside.first, ball);
// TODO(ruimiguel): check what happens with ball that slightly touch
// Opening and goes out again. With InitialPosition change now doesn't
// work position.y comparison
callback.end(ball, area, MockContact());
//expect(callback.ballsInside.isEmpty, true);
expect(callback.ballsInside.isEmpty, true);
});
flameTester.test(
'changes ball layer '
'when a ball enters upwards into a down oriented path '
'but falls again outside', (game) async {
'when a ball exits from a downward oriented ramp', (game) async {
final ball = MockBall();
final body = MockBody();
final area = TestRampOpening(
@ -271,6 +259,33 @@ void main() {
when(() => ball.body).thenReturn(body);
when(() => body.position).thenReturn(Vector2.zero());
when(() => body.linearVelocity).thenReturn(Vector2(0, -1));
when(() => ball.layer).thenReturn(Layer.board);
await game.ready();
await game.ensureAdd(area);
callback.begin(ball, area, MockContact());
verify(() => ball.layer = Layer.jetpack).called(1);
callback.end(ball, area, MockContact());
verify(() => ball.layer = Layer.board);
});
flameTester.test(
'removes ball from ballsInside '
'when a ball exits from a upward oriented ramp', (game) async {
final ball = MockBall();
final body = MockBody();
final area = TestRampOpening(
orientation: RampOrientation.up,
pathwayLayer: Layer.jetpack,
)..initialPosition = Vector2(0, 10);
final callback = TestRampOpeningBallContactCallback();
when(() => ball.body).thenReturn(body);
when(() => body.position).thenReturn(Vector2.zero());
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
when(() => ball.layer).thenReturn(Layer.board);
await game.ready();
@ -278,14 +293,38 @@ void main() {
expect(callback.ballsInside.isEmpty, isTrue);
callback.begin(ball, area, MockContact());
expect(callback.ballsInside.length, equals(1));
expect(callback.ballsInside.first, ball);
callback.end(ball, area, MockContact());
expect(callback.ballsInside.isEmpty, true);
});
flameTester.test(
'changes ball layer '
'when a ball exits from a upward oriented ramp', (game) async {
final ball = MockBall();
final body = MockBody();
final area = TestRampOpening(
orientation: RampOrientation.up,
pathwayLayer: Layer.jetpack,
)..initialPosition = Vector2(0, 10);
final callback = TestRampOpeningBallContactCallback();
when(() => ball.body).thenReturn(body);
when(() => body.position).thenReturn(Vector2.zero());
when(() => body.linearVelocity).thenReturn(Vector2(0, 1));
when(() => ball.layer).thenReturn(Layer.board);
await game.ready();
await game.ensureAdd(area);
callback.begin(ball, area, MockContact());
verify(() => ball.layer = Layer.jetpack).called(1);
// TODO(ruimiguel): check what happens with ball that slightly touch
// Opening and goes out again. With InitialPosition change now doesn't
// work position.y comparison
callback.end(ball, area, MockContact());
//verify(() => ball.layer = Layer.board);
verify(() => ball.layer = Layer.board);
});
});
}

Loading…
Cancel
Save