Skip to content

Commit 39366de

Browse files
authored
Merge pull request #3 from chinhouse/main
MiniScript version of SLOTS
2 parents f7ea184 + 9afa9d5 commit 39366de

File tree

5 files changed

+445
-0
lines changed

5 files changed

+445
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
2+
3+
Conversion to [MiniScript](https://miniscript.org).
4+
5+
Ways to play:
6+
7+
1. Command-Line MiniScript:
8+
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
9+
10+
miniscript slots.ms
11+
12+
2. Mini Micro:
13+
Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
14+
15+
load "slots"
16+
run
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
center = function(s,n)
2+
h = floor((n - s.len)/2)
3+
s = " " * h + s + " " * n
4+
return s[:n]
5+
end function
6+
7+
Machine = {"symbols": ["Bar", "Bell", "Orange", "Lemon", "Plum ", "Cherry"]}
8+
Machine.money = 0
9+
Machine.bet = 0
10+
Machine.playing = true
11+
Machine.reels = [0,0,0]
12+
Machine.results = null
13+
14+
Machine.reelsSpin = function(n, msg, row)
15+
env = [1,.95,.9,.85,.25,.2,.15,.1,.05,0]
16+
bell = new Sound
17+
bell.init .1, 800, env, Sound.sineWave
18+
for i in range(1,2)
19+
s1 = new Sound
20+
s1.init .2, i * 800 + 800, env, Sound.sineWave
21+
bell.mix(s1, 1 / (2 ^ i))
22+
end for
23+
for i in range(1,n)
24+
bell.play
25+
ix = 0
26+
while bell.isPlaying
27+
text.row = row
28+
ix = (ix + 1) % self.symbols.len
29+
print msg + center(self.symbols[ix],8)
30+
end while
31+
end for
32+
end function
33+
34+
Machine.makeBet = function()
35+
while true
36+
bet = floor(input("Your bet? ").val)
37+
if bet > 100 then
38+
print "House limits are $100"
39+
else if bet < 1 then
40+
print "Minimum bet is $1"
41+
else
42+
break
43+
end if
44+
end while
45+
Machine.bet = bet
46+
end function
47+
48+
Machine.pullHandle = function
49+
if text.row < 3 then
50+
print; print
51+
text.row = text.row + 2
52+
end if
53+
row = text.row
54+
msg = ""
55+
for i in range(0,2)
56+
self.reelsSpin(5 + 5 * (i==0), msg, row)
57+
wait .1
58+
symIx = floor(rnd * self.symbols.len)
59+
msg += center(self.symbols[symIx],9)
60+
self.reels[i] = symIx
61+
text.row = row
62+
print msg
63+
end for
64+
end function
65+
66+
Machine.winnings = function
67+
bet = Machine.bet
68+
barIdx = self.symbols.indexOf("Bar")
69+
numBars = 0
70+
multiples = 0
71+
for i in range(0,2)
72+
numBars += (self.reels[i] == barIdx)
73+
multiples += (self.reels[i] == self.reels[(i + 1) % 3])
74+
end for
75+
76+
if numBars == 3 then return {"won": bet * 101, "msg": "***Jackpot***"}
77+
if numBars == 2 then return {"won": bet * 6, "msg": "*Double Bar*"}
78+
if multiples == 3 then return {"won": bet * 11, "msg": "**Top Dollar**"}
79+
if multiples == 1 then return {"won": bet * 3, "msg": "Double!!"}
80+
return {"won": -bet, "msg": "You lost."}
81+
end function
82+
83+
Machine.results = function
84+
result = Machine.winnings
85+
self.money += result.won
86+
print result.msg
87+
if result.won > 0 then
88+
print "You Won!!"
89+
end if
90+
print "Your standings are $" + self.money
91+
return
92+
end function
93+
94+
Machine.playAgain = function
95+
ans = input("Again? ") + " "
96+
self.playing = (ans[0].lower == "y")
97+
if self.playing then return
98+
print
99+
if self.money < 0 then
100+
print "Pay up! Please leave your money on the terminal."
101+
else if self.money == 0 then
102+
print "Hey, you broke even."
103+
else
104+
print "Collect your winnings from the H&M cashier."
105+
end if
106+
end function
107+
108+
clear
109+
print " " * 30 + "Slots"
110+
print " " * 15 + "Creative Computing Morristown, New Jersey"
111+
print;print;print
112+
print "You are in the H&M Casino, in front of one of our"
113+
print "one-arm bandits. Bet from $1 to $100."
114+
print "to pull the arm, punch the return key after making your bet."
115+
116+
print
117+
while Machine.playing
118+
Machine.makeBet
119+
print
120+
Machine.pullHandle
121+
print
122+
Machine.results
123+
Machine.playAgain
124+
print
125+
end while
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
2+
3+
Conversion to [MiniScript](https://miniscript.org).
4+
5+
Ways to play:
6+
7+
1. Command-Line MiniScript:
8+
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
9+
10+
miniscript splat.ms
11+
12+
2. Mini Micro:
13+
Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
14+
15+
load "splat"
16+
run
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)