Skip to content

Commit a7d3e38

Browse files
committed
starting random
1 parent ccc6b41 commit a7d3e38

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
func bounce(ball):
2+
ball.set_direction(ball.get_direction() * Vector2(-1, 1))

TddAndPong/Episode3/test/Tests.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ script = ExtResource( 1 )
1414
__meta__ = {
1515
"_editor_icon": ExtResource( 2 )
1616
}
17+
_select_script = "test_paddle"
1718
_run_on_load = true
1819
_should_maximize = true
1920
_yield_between_tests = false
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
extends 'res://addons/gut/test.gd'
2+
3+
var Paddle = load('res://scripts/paddle.gd')
4+
var Ball = load('res://scripts/ball.gd')
5+
6+
func test_can_make_paddle():
7+
assert_not_null(Paddle.new())
8+
9+
func test_bounce_inverts_x():
10+
var ball = double(Ball).new()
11+
var paddle = Paddle.new()
12+
13+
stub(ball, 'get_direction').to_return(Vector2(1, 1))
14+
paddle.bounce(ball)
15+
assert_called(ball, 'set_direction', [Vector2(-1, 1)])
16+
17+
func test_bounce_inverts_x_other_direction():
18+
var ball = double(Ball).new()
19+
var paddle = Paddle.new()
20+
21+
stub(ball, 'get_direction').to_return(Vector2(-1, 1))
22+
paddle.bounce(ball)
23+
assert_called(ball, 'set_direction', [Vector2(1, 1)])
24+
25+
func test_bounce_changes_y_randomly():
26+
var paddle = Paddle.new()
27+
var ball = double(Ball).new()
28+
stub(ball, 'get_direction').to_return(Vector2(1, 1))
29+

0 commit comments

Comments
 (0)