1
00:00:01,030 --> 00:00:07,300
Hey, this lesson, more tweaks and adjustments, so we did want to add in this Storper option where

2
00:00:07,300 --> 00:00:11,800
the ball will actually sit on top of the paddle and it's actually not going to be moving or it's not

3
00:00:11,800 --> 00:00:14,930
going to be in play until the player wants to place it into play.

4
00:00:15,250 --> 00:00:21,520
So creating another object within the player in play by default, we're going to set this to false and

5
00:00:21,520 --> 00:00:23,710
then apply this condition where we need to.

6
00:00:23,890 --> 00:00:26,410
And this is also going to be sitting on top of the stopper.

7
00:00:26,530 --> 00:00:31,370
And we're also going to update this inplay value when we do the key presses.

8
00:00:31,630 --> 00:00:39,010
So when the key press is whenever the key is pressed and player in play is not true, that we're going

9
00:00:39,010 --> 00:00:40,120
to set it to true.

10
00:00:40,360 --> 00:00:44,650
We're going to check to see if key 38 is being pressed.

11
00:00:44,890 --> 00:00:46,230
And that's the up arrow.

12
00:00:46,480 --> 00:00:50,320
So you can apply a few different keys if you wanted to, to this function as well.

13
00:00:50,560 --> 00:00:55,180
And we're checking to see if player in play is not true.

14
00:00:55,540 --> 00:01:01,060
And if that's the case, then we're going to take player in play and we're going to set that one to

15
00:01:01,060 --> 00:01:07,870
true so that our way to toggle that and that will give the player the ability to launch the ball whenever

16
00:01:07,870 --> 00:01:09,140
they're ready to launch it.

17
00:01:09,430 --> 00:01:14,320
So we need to add in a few more things where we don't want the ball actually to be moving or we want

18
00:01:14,320 --> 00:01:19,660
to adjust the ball movement to be in line with what's happening with the paddle because we're sitting

19
00:01:19,660 --> 00:01:22,130
on top of the paddle, has to move along side with that.

20
00:01:22,180 --> 00:01:28,780
So going down to where we have the ball move and update the so we can have a condition that will check

21
00:01:28,780 --> 00:01:32,110
to see if the ball is on the paddle.

22
00:01:32,710 --> 00:01:34,090
So take move ball.

23
00:01:34,090 --> 00:01:40,180
And we're going to move that just to just under here where we've updated the paddle position because

24
00:01:40,180 --> 00:01:43,390
we want to use that to also update the ball position.

25
00:01:43,660 --> 00:01:50,050
And we're going to apply our condition here to check to see if player inplay.

26
00:01:51,950 --> 00:01:52,990
Is not true.

27
00:01:53,030 --> 00:01:53,900
So if it's false.

28
00:01:55,700 --> 00:02:01,970
Then that means that it's waiting on the paddle, otherwise we know we can move the ball naturally.

29
00:02:01,970 --> 00:02:05,590
However, the ball needs to move so we can apply the move ball function there.

30
00:02:05,870 --> 00:02:10,310
And if it's waiting on the paddle, we're going to create another function that will be or we actually

31
00:02:10,310 --> 00:02:15,190
probably don't even need a function for that where we can update the ball position directly here.

32
00:02:15,440 --> 00:02:20,030
We're updating the ball style and updating the ball style.

33
00:02:20,030 --> 00:02:24,230
Top position will be equal to whatever the paddle.

34
00:02:25,550 --> 00:02:33,590
Offset and we use these offset values again, so that offset top and then subtracting roughly around

35
00:02:33,590 --> 00:02:38,260
20 and we'll have to check that just to make sure that we did get that properly.

36
00:02:38,690 --> 00:02:46,430
And then the ball style left position is going to be equal to whatever the current position left is.

37
00:02:46,760 --> 00:02:51,000
And as well, we need to add to that so we can take that current position.

38
00:02:51,500 --> 00:02:57,430
So this is going to be the same as the left and add 50 to the current position.

39
00:02:58,480 --> 00:02:59,440
So see what happens.

40
00:02:59,470 --> 00:03:06,880
So now we've got the ball sitting on top of the paddle and we move it along and then when I press the

41
00:03:06,880 --> 00:03:10,010
upkeep, you're going to see that it actually moves alongside.

42
00:03:10,420 --> 00:03:16,810
So this situation where the ball has moved, now we have a function that we can set.

43
00:03:16,990 --> 00:03:20,950
We can set this in play, and that means that's going to be sitting on top of the paddle.

44
00:03:21,200 --> 00:03:27,250
So when it goes, whatever it falls off, we can apply that where we're sitting the ball on top of the

45
00:03:27,250 --> 00:03:27,730
paddle.

46
00:03:27,910 --> 00:03:33,340
And that will give us the ability to set it and move it along side.

47
00:03:33,670 --> 00:03:39,820
So whenever it falls off the edge, the starting position is going to be wherever the stopper is setting

48
00:03:39,820 --> 00:03:40,210
it to.

49
00:03:40,630 --> 00:03:48,880
So taking that stopper position stopper function that we created earlier, now we can use that game

50
00:03:49,030 --> 00:03:59,080
player in play value and set that to force and then also take the player ball direction.

51
00:03:59,350 --> 00:04:04,930
We need to make an adjustment for that because we saw that as well, that we need to always set it to

52
00:04:04,930 --> 00:04:09,390
the negative so that it will always start out decreasing in value.

53
00:04:09,400 --> 00:04:13,900
So moving up and also the ball direction by default, we're going to set it to zero.

54
00:04:14,470 --> 00:04:16,330
And actually I'm going to break this off.

55
00:04:16,330 --> 00:04:21,520
And the reason I'm going to do this is breaking it off of the current position is so that we do have

56
00:04:21,520 --> 00:04:23,830
a function where we can reset the position.

57
00:04:24,130 --> 00:04:29,200
So let's do a quick adjustment here and we'll call it waiting on paddle.

58
00:04:29,740 --> 00:04:34,510
And what this function is going to do is this is going to take care of the ball position so that we

59
00:04:34,510 --> 00:04:39,820
can call to this function over here and we're going to reuse that same function where we're going to

60
00:04:39,820 --> 00:04:41,170
position the ball position.

61
00:04:41,440 --> 00:04:48,580
So instead of the current position, we're going to take the current offset left position and we're

62
00:04:48,580 --> 00:04:53,030
going to add 50 to it in order to position it on the paddle.

63
00:04:53,230 --> 00:05:00,520
So now, whenever we need to position it and we within Storper, we can call to that function and that

64
00:05:00,520 --> 00:05:05,470
will reposition where the ball is sitting and place it on top of the paddle.

65
00:05:05,560 --> 00:05:09,340
And then when we're moving the paddle, then we can see where the ball is going to be sitting.

66
00:05:09,610 --> 00:05:14,320
And there's one more that we wanted to add in as well, and that is to stop the animation.

67
00:05:14,560 --> 00:05:18,220
So we've have an option where we can give the animation frame a name.

68
00:05:18,400 --> 00:05:23,440
And when we start the animation, if we call it a name, that we can access it.

69
00:05:23,440 --> 00:05:26,470
We can also use that to stop the animation.

70
00:05:26,860 --> 00:05:28,960
So you can just call it player any.

71
00:05:29,470 --> 00:05:36,460
And then within itself, as we are calling itself, we're going to also give it that same name so that

72
00:05:36,460 --> 00:05:37,840
we can always refer to it.

73
00:05:38,050 --> 00:05:43,930
And then within Storper, we have an option here to cancel the animation subframe so we can go window,

74
00:05:44,320 --> 00:05:49,540
cancel animation frame, and then we need to specify the name of the animation frame that we want to

75
00:05:49,540 --> 00:05:51,200
stop and cancel.

76
00:05:51,550 --> 00:05:59,410
So I think we're ready to try that and we can move the ball and sitting on top of it went off and we

77
00:05:59,410 --> 00:06:02,560
can adjust the lives so that we have a little bit longer gameplay.

78
00:06:03,010 --> 00:06:08,110
And sometimes it does take a few times where you have to play through the game just to make sure you've

79
00:06:08,110 --> 00:06:10,330
got all of the functionality that you were looking for.

80
00:06:10,600 --> 00:06:16,360
So see where decreasing in lives and whenever it's running off, then the ball is sitting on top of

81
00:06:16,360 --> 00:06:19,650
the paddle and when we move the paddle, the ball moves along side.

82
00:06:19,900 --> 00:06:23,140
Well, also, I just noticed that it's not directly centered.

83
00:06:23,260 --> 00:06:29,020
So maybe we'll want to make an adjustment to where we've got the offset, whatever the ball is sitting

84
00:06:29,020 --> 00:06:29,860
on top of the paddle.

85
00:06:30,100 --> 00:06:33,430
So we still have that within that one option here.

86
00:06:33,430 --> 00:06:39,580
So we can maybe even move it down a little bit and move it over to the left hand side because the ball

87
00:06:39,580 --> 00:06:39,820
hits.

88
00:06:39,820 --> 00:06:42,760
The paddle was one hundred, the ball was 20.

89
00:06:42,910 --> 00:06:46,840
So taking half of that should give us a good starting point for the ball.

90
00:06:46,990 --> 00:06:49,780
And we can also move that down a little bit more as well.

91
00:06:49,930 --> 00:06:54,720
So it looks more like it's sitting on top of the paddle and you can adjust and tweak it as needed.

92
00:06:54,880 --> 00:06:56,680
So I think that was a little bit too much.

93
00:06:57,130 --> 00:07:01,930
And sometimes we do need to make a few little minor adjustments to get at work in the way that we need

94
00:07:01,930 --> 00:07:02,100
it.

95
00:07:02,140 --> 00:07:06,250
Coming up next, we're going to do a final run-Through of the game, make sure that we've got all of

96
00:07:06,250 --> 00:07:10,720
the functionality that we set out to produce and also do a quick code review.

97
00:07:10,720 --> 00:07:15,580
And I just noticed one of the thing that we do need to adjust and we still have the ability to run the

98
00:07:15,580 --> 00:07:16,750
paddle off the screen.

99
00:07:16,900 --> 00:07:18,490
So we want to create those boundaries.

100
00:07:18,640 --> 00:07:19,720
So that's coming up next.

101
00:07:19,720 --> 00:07:22,990
One more tweak, an adjustment lesson and then a code review.

102
00:07:23,350 --> 00:07:24,550
So that's still all yet to come.
