Skip to content

Commit 5126e83

Browse files
authored
Add files via upload
1 parent 7db163b commit 5126e83

File tree

1 file changed

+133
-0
lines changed
  • 00_Alternate_Languages/81_Splat/MiniScript

1 file changed

+133
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
within5pct = function(n)
2+
return n * (1 + rnd / 20 - rnd / 20)
3+
end function
4+
5+
splatMsg = ["Requiescat in pace.", "May the Angel of Heaven lead you into Paradise.",
6+
"Rest in piece.", "Son-Of-A-Gun.", "#$%&&%!$",
7+
"A kick in the pants is a boost if you're headed right.",
8+
"Hmm. Should have picked a shorter time.", "Mutter. Mutter. Mutter.",
9+
"Pushing up daisies.", "Easy come, easy go."]
10+
11+
history = []
12+
clear
13+
print " " * 33 + "Splat"
14+
print " " * 15 + "Creative Computing Morristown, New Jersey"
15+
print;print;print
16+
print "Welcome to 'Splat' -- the game that simulates a parachute"
17+
print "jump. Try to open your chute at the last possible"
18+
print "moment without going splat."
19+
ans = "y"
20+
while ans == "y"
21+
print;print
22+
23+
distance = floor(9001 * rnd) + 1000
24+
25+
ans = input("Select your own terminal velocity (Yes or No)? ") + " "
26+
if ans[0].lower == "y" then
27+
terminalVel = input("What terminal velocity (mi/hr)? ").val
28+
else
29+
terminalVel = floor(1000 * rnd)
30+
print "Ok. Terminal velocity = " + terminalVel + "mi/hr"
31+
end if
32+
33+
terminalVel = terminalVel * 5280/3600
34+
velocity = within5pct(terminalVel)
35+
36+
ans = input("Want to select acceleration due to gravity (Yes or No)? ") + " "
37+
if ans[0].lower == "y" then
38+
acceleration = input("What acceleration (ft/sec/sec)? ").val
39+
acceleration = within5pct(acceleration)
40+
else
41+
bodies = ["Mercury", "Venus", "Earth", "the moon", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "the Sun"]
42+
gravity = [12.2, 28.3,32.16,5.15,12.5,85.2,37.6,33.8,39.6,896]
43+
44+
initialStmt = ["Fine. You're on ", "All right. You're on ", "Then you're on "]
45+
46+
i = floor(rnd * 10)
47+
acceleration = gravity[i]
48+
stmt = initialStmt[i%3] + bodies[i] + ". Acceleration=" + acceleration + " ft/sec/sec."
49+
print stmt
50+
end if
51+
52+
actAccel = within5pct(acceleration)
53+
print
54+
print " Altitude = " + distance + " ft"
55+
print " Term. Velocity = " + terminalVel + " ft/sec +/-5%"
56+
print " Acceleration = " + acceleration + " ft/sec/sec +/-5%"
57+
print "Set the timer for your freefall."
58+
sec = input("How many seconds? ").val
59+
60+
print "Here we go."; print
61+
62+
print "Time (sec)" + char(9) + "Dist to Fall (ft)"
63+
print "==========" + char(9) + "================="
64+
termVelHit = false
65+
for i in range(0, sec, sec/8)
66+
sec = velocity/actAccel
67+
if i <= sec and termVelHit == false then
68+
dist = distance - ((actAccel/2)*i^2)
69+
else if termVelHit == false then
70+
termVelHit = true
71+
print "Terminal velocity reached a T plus " + velocity/actAccel + " seconds."
72+
end if
73+
if termVelHit then
74+
dist = distance - ((velocity^2/(2*actAccel))+(velocity*(i-sec)))
75+
end if
76+
77+
if dist <= 0 then break
78+
print (" " + i + " " * 9)[:9] + char(9) + " " + dist
79+
end for
80+
81+
if dist > 0 then
82+
print "Chute open"
83+
history.push(dist)
84+
numJumps = history.len
85+
numLowerJumps = 0
86+
for d in history
87+
numLowerJumps += (dist <= d)
88+
end for
89+
90+
jumpDiff = numJumps - numLowerJumps
91+
if numJumps < 4 then
92+
ordinal = ["1st", "2nd", "3rd"]
93+
print "Amazing!! Not bad for your " + ordinal[numJumps-1] + " successful jump!!!"
94+
else if jumpDiff <= numJumps * 0.10 then
95+
print "Wow! That's some jumping. Of the " + numJumps + " successful jumps"
96+
print "before yours, only " + jumpDiff + " opened their chutes lower than"
97+
print "you did."
98+
else if jumpDiff <= numJumps * 0.25 then
99+
print "Pretty good! " + numJumps + " successful jumps preceded yours and only"
100+
print jumpDiff + " of them got lower than you did before their chute"
101+
print "opened."
102+
else if jumpDiff <= numJumps * 0.50 then
103+
print "Not bad. There have been " + numJumps + " successful jumps before yours."
104+
print "You were beaten out by " + jumpDiff + " of them."
105+
else if jumpDiff <= numJumps * 0.75 then
106+
print "Conservative, aren't you? You ranked only " + jumpDiff + " in the"
107+
print numJumps + " successful jumps before yours."
108+
else if jumpDiff <= numJumps * 0.90 then
109+
print "Humph! Don't you have any sporting blood? There were"
110+
print numJumps + " successful jumps before yours and you came in " + numLowerJumps + " jumps"
111+
print "better than the worst. Shape up!!!"
112+
else
113+
print "Hey! You pulled the rip code much too soon. " + numJumps + " successful"
114+
print "jumps before yours and you came in number " + jumpDiff + "! Get with it."
115+
end if
116+
else if dist <= 0 and not termVelHit then
117+
print (2 * distance / actAccel) ^ .5 + " " * 5 + "Splat"
118+
else if dist <= 0 and termVelHit then
119+
print velocity/actAccel + ((distance - (velocity^2/(2*actAccel)))/velocity) + " " *5 + "Splat"
120+
end if
121+
122+
if dist <=0 then
123+
splatMsg.shuffle
124+
print splatMsg[0]
125+
print "I'll give you another chance."
126+
end if
127+
128+
ans = input("Do you want to play again? ") + " "
129+
ans = ans[0].lower
130+
end while
131+
132+
print "S" * 10
133+
print

0 commit comments

Comments
 (0)