-
Notifications
You must be signed in to change notification settings - Fork 0
/
rocket-lander-starter
175 lines (112 loc) · 5.77 KB
/
rocket-lander-starter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
include image
include shared-gdrive("Rocket Lander (background)", "1gF4GvcpTnLtF0WGaYpleT12z3hlPfKu1")
#######################
# Images / Parameters #
#######################
MARS = image-url("https://drive.google.com/uc?export=download&id=1fCcB6IuEUJN3JNsksDE0gtCAXc7-Qw_5")
ROCKET = scale(0.2,image-url("https://code.pyret.org/shared-image-contents?sharedImageId=1npNv8bo_6cSn-s0x_I3PtMAVoXtsUDtJ"))
mass = 533 # kg
vx-init = 35 # m/s
gfs = -3.711 # N/kg
############
# Unit 2 #
######################################################################
# Add your two-argument next-x function, along with its contract #
# and examples. THEN in the last line, change default-next-x to #
# next-x. Confirm that the rocket moves in the way you expect. #
######################################################################
######################################################################
# Your lander has probably drifted across the window and off of #
# the right side of the screen! #
# #
# Design a function called is-onscreen-x which consumes the #
# lander's current x position and returns true whenever the #
# lander's current x position is actually visible on screen. #
# #
# THEN in the last line, change default-is-onscreen-x to #
# is-onscreen-x. Confirm the rocket stays on screen (and returns) #
# in the way that you expect. #
######################################################################
#|
is-onscreen-x :: ... -> ...
#Add Purpose Statement here
# These examples should evaluate to true because the expression evaluates to true
examples "is-onscreen-x is true":
is-onscreen-x(...) is ... because ...
...
end
# These examples should evaluate to false because the expression evaluates to false
examples "is-onscreen-x is false":
is-onscreen-x(...) is ... because ...
...
end
fun is-onscreen-x(...):
...
end
|#
############
# Unit 3 #
######################################################################
# Add your next-y and next-vy functions from the lunar drop sim. #
# THEN in the last line, change default-next-y and default-next-vy #
# to next-y and next-vy, respectively. Confirm the rocket moves in #
# the way you expect. #
######################################################################
############
# Unit 4 #
######################################################################
# Design a function called game-status that consumes the current #
# x-position, the current y-position, and the current y-velocity, #
# and produces a statement describing the current condition of #
# the rocket: flying, safely landed, or crash landed. #
# #
# #
# NOTE: You can call a pre-defined function called ground-height, #
# which consumes the current x-position and produces the height #
# of the ground at that x-position (aka, elevation of the ground). #
# #
# THEN, in the last line, change default-game-status to game-status. #
# Confirm the game status changes in all of the ways you expect. #
######################################################################
############
# Unit 5 #
####################################################################
# Design a function called sum-of-forces that consumes the rocket #
# thrust, and produces the total force on the rocket due to both #
# the thrust and the gravitational field. #
# #
# THEN, in the last line, change default-sum-of-forces to #
# to sum-of-forces. #
####################################################################
####################################################################
# Design a function called a-from-f that consumes a Number #
# (the current sum of the forces on the rocket), and produces #
# the rocket's current acceleration. #
# #
# THEN, in the last line, change default-a-from-f to a-from-f. #
####################################################################
####################################################################
# Design a function called thrust-from-key that consumes the #
# current thrust and the name of a key pressed by the player, #
# and, depending on the key pressed, produces a positive change #
# in the thrust, a negative change in the thrust, or no change in #
# the thrust at all. #
# #
# THEN, in the last line, change default-thrust-from-key to #
# thrust-from-key. Confirm the game works the way you intend. #
####################################################################
####################################################################
#CONGRATULATIONS! You've finished building your Rocket Lander game!#
####################################################################
make-lander(
MARS, ROCKET, # IMAGES
mass, vx-init, gfs, # PARAMETERS
# swap your functions here!
default-next-x,
default-is-onscreen-x,
default-next-y,
default-next-vy,
default-a-from-f,
default-thrust-from-key,
default-sum-of-forces,
default-game-status)