-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #903 from JoeStrout/main
Last batch of MiniScript ports!
- Loading branch information
Showing
5 changed files
with
445 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html). | ||
|
||
Conversion to [MiniScript](https://miniscript.org). | ||
|
||
Ways to play: | ||
|
||
1. Command-Line MiniScript: | ||
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as: | ||
|
||
miniscript slots.ms | ||
|
||
2. Mini Micro: | ||
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: | ||
|
||
load "slots" | ||
run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
center = function(s,n) | ||
h = floor((n - s.len)/2) | ||
s = " " * h + s + " " * n | ||
return s[:n] | ||
end function | ||
|
||
Machine = {"symbols": ["Bar", "Bell", "Orange", "Lemon", "Plum ", "Cherry"]} | ||
Machine.money = 0 | ||
Machine.bet = 0 | ||
Machine.playing = true | ||
Machine.reels = [0,0,0] | ||
Machine.results = null | ||
|
||
Machine.reelsSpin = function(n, msg, row) | ||
env = [1,.95,.9,.85,.25,.2,.15,.1,.05,0] | ||
bell = new Sound | ||
bell.init .1, 800, env, Sound.sineWave | ||
for i in range(1,2) | ||
s1 = new Sound | ||
s1.init .2, i * 800 + 800, env, Sound.sineWave | ||
bell.mix(s1, 1 / (2 ^ i)) | ||
end for | ||
for i in range(1,n) | ||
bell.play | ||
ix = 0 | ||
while bell.isPlaying | ||
text.row = row | ||
ix = (ix + 1) % self.symbols.len | ||
print msg + center(self.symbols[ix],8) | ||
end while | ||
end for | ||
end function | ||
|
||
Machine.makeBet = function() | ||
while true | ||
bet = floor(input("Your bet? ").val) | ||
if bet > 100 then | ||
print "House limits are $100" | ||
else if bet < 1 then | ||
print "Minimum bet is $1" | ||
else | ||
break | ||
end if | ||
end while | ||
Machine.bet = bet | ||
end function | ||
|
||
Machine.pullHandle = function | ||
if text.row < 3 then | ||
print; print | ||
text.row = text.row + 2 | ||
end if | ||
row = text.row | ||
msg = "" | ||
for i in range(0,2) | ||
self.reelsSpin(5 + 5 * (i==0), msg, row) | ||
wait .1 | ||
symIx = floor(rnd * self.symbols.len) | ||
msg += center(self.symbols[symIx],9) | ||
self.reels[i] = symIx | ||
text.row = row | ||
print msg | ||
end for | ||
end function | ||
|
||
Machine.winnings = function | ||
bet = Machine.bet | ||
barIdx = self.symbols.indexOf("Bar") | ||
numBars = 0 | ||
multiples = 0 | ||
for i in range(0,2) | ||
numBars += (self.reels[i] == barIdx) | ||
multiples += (self.reels[i] == self.reels[(i + 1) % 3]) | ||
end for | ||
|
||
if numBars == 3 then return {"won": bet * 101, "msg": "***Jackpot***"} | ||
if numBars == 2 then return {"won": bet * 6, "msg": "*Double Bar*"} | ||
if multiples == 3 then return {"won": bet * 11, "msg": "**Top Dollar**"} | ||
if multiples == 1 then return {"won": bet * 3, "msg": "Double!!"} | ||
return {"won": -bet, "msg": "You lost."} | ||
end function | ||
|
||
Machine.results = function | ||
result = Machine.winnings | ||
self.money += result.won | ||
print result.msg | ||
if result.won > 0 then | ||
print "You Won!!" | ||
end if | ||
print "Your standings are $" + self.money | ||
return | ||
end function | ||
|
||
Machine.playAgain = function | ||
ans = input("Again? ") + " " | ||
self.playing = (ans[0].lower == "y") | ||
if self.playing then return | ||
if self.money < 0 then | ||
print "Pay up! Please leave your money on the terminal." | ||
else if self.money == 0 then | ||
print "Hey, you broke even." | ||
else | ||
print "Collect your winnings from the H&M cashier." | ||
end if | ||
end function | ||
|
||
clear | ||
print " " * 30 + "Slots" | ||
print " " * 15 + "Creative Computing Morristown, New Jersey" | ||
print;print;print | ||
print "You are in the H&M Casino, in front of one of our" | ||
print "one-arm bandits. Bet from $1 to $100." | ||
print "to pull the arm, punch the return key after making your bet." | ||
|
||
while Machine.playing | ||
Machine.makeBet | ||
Machine.pullHandle | ||
Machine.results | ||
Machine.playAgain | ||
end while |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html). | ||
|
||
Conversion to [MiniScript](https://miniscript.org). | ||
|
||
Ways to play: | ||
|
||
1. Command-Line MiniScript: | ||
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as: | ||
|
||
miniscript splat.ms | ||
|
||
2. Mini Micro: | ||
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: | ||
|
||
load "splat" | ||
run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
within5pct = function(n) | ||
return n * (1 + rnd / 20 - rnd / 20) | ||
end function | ||
|
||
splatMsg = ["Requiescat in pace.", "May the Angel of Heaven lead you into Paradise.", | ||
"Rest in piece.", "Son-Of-A-Gun.", "#$%&&%!$", | ||
"A kick in the pants is a boost if you're headed right.", | ||
"Hmm. Should have picked a shorter time.", "Mutter. Mutter. Mutter.", | ||
"Pushing up daisies.", "Easy come, easy go."] | ||
|
||
history = [] | ||
clear | ||
print " " * 33 + "Splat" | ||
print " " * 15 + "Creative Computing Morristown, New Jersey" | ||
print;print;print | ||
print "Welcome to 'Splat' -- the game that simulates a parachute" | ||
print "jump. Try to open your chute at the last possible" | ||
print "moment without going splat." | ||
ans = "y" | ||
while ans == "y" | ||
print;print | ||
|
||
distance = floor(9001 * rnd) + 1000 | ||
|
||
ans = input("Select your own terminal velocity (Yes or No)? ") + " " | ||
if ans[0].lower == "y" then | ||
terminalVel = input("What terminal velocity (mi/hr)? ").val | ||
else | ||
terminalVel = floor(1000 * rnd) | ||
print "Ok. Terminal velocity = " + terminalVel + "mi/hr" | ||
end if | ||
|
||
terminalVel = terminalVel * 5280/3600 | ||
velocity = within5pct(terminalVel) | ||
|
||
ans = input("Want to select acceleration due to gravity (Yes or No)? ") + " " | ||
if ans[0].lower == "y" then | ||
acceleration = input("What acceleration (ft/sec/sec)? ").val | ||
acceleration = within5pct(acceleration) | ||
else | ||
bodies = ["Mercury", "Venus", "Earth", "the moon", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "the Sun"] | ||
gravity = [12.2, 28.3,32.16,5.15,12.5,85.2,37.6,33.8,39.6,896] | ||
|
||
initialStmt = ["Fine. You're on ", "All right. You're on ", "Then you're on "] | ||
|
||
i = floor(rnd * 10) | ||
acceleration = gravity[i] | ||
stmt = initialStmt[i%3] + bodies[i] + ". Acceleration=" + acceleration + " ft/sec/sec." | ||
print stmt | ||
end if | ||
|
||
actAccel = within5pct(acceleration) | ||
print " Altitude = " + distance + " ft" | ||
print " Term. Velocity = " + terminalVel + " ft/sec +/-5%" | ||
print " Acceleration = " + acceleration + " ft/sec/sec +/-5%" | ||
print "Set the timer for your freefall." | ||
sec = input("How many seconds? ").val | ||
|
||
print "Here we go."; print | ||
|
||
print "Time (sec)" + char(9) + "Dist to Fall (ft)" | ||
print "==========" + char(9) + "=================" | ||
termVelHit = false | ||
for i in range(0, sec, sec/8) | ||
sec = velocity/actAccel | ||
if i <= sec and termVelHit == false then | ||
dist = distance - ((actAccel/2)*i^2) | ||
else if termVelHit == false then | ||
termVelHit = true | ||
print "Terminal velocity reached a T plus " + velocity/actAccel + " seconds." | ||
end if | ||
if termVelHit then | ||
dist = distance - ((velocity^2/(2*actAccel))+(velocity*(i-sec))) | ||
end if | ||
|
||
if dist <= 0 then break | ||
print (" " + i + " " * 9)[:9] + char(9) + " " + dist | ||
end for | ||
|
||
if dist > 0 then | ||
print "Chute open" | ||
history.push(dist) | ||
numJumps = history.len | ||
numLowerJumps = 0 | ||
for d in history | ||
numLowerJumps += (dist <= d) | ||
end for | ||
|
||
jumpDiff = numJumps - numLowerJumps | ||
if numJumps < 4 then | ||
ordinal = ["1st", "2nd", "3rd"] | ||
print "Amazing!! Not bad for your " + ordinal[numJumps-1] + " successful jump!!!" | ||
else if jumpDiff <= numJumps * 0.10 then | ||
print "Wow! That's some jumping. Of the " + numJumps + " successful jumps" | ||
print "before yours, only " + jumpDiff + " opened their chutes lower than" | ||
print "you did." | ||
else if jumpDiff <= numJumps * 0.25 then | ||
print "Pretty good! " + numJumps + " successful jumps preceded yours and only" | ||
print jumpDiff + " of them got lower than you did before their chute" | ||
print "opened." | ||
else if jumpDiff <= numJumps * 0.50 then | ||
print "Not bad. There have been " + numJumps + " successful jumps before yours." | ||
print "You were beaten out by " + jumpDiff + " of them." | ||
else if jumpDiff <= numJumps * 0.75 then | ||
print "Conservative, aren't you? You ranked only " + jumpDiff + " in the" | ||
print numJumps + " successful jumps before yours." | ||
else if jumpDiff <= numJumps * 0.90 then | ||
print "Humph! Don't you have any sporting blood? There were" | ||
print numJumps + " successful jumps before yours and you came in " + numLowerJumps + " jumps" | ||
print "better than the worst. Shape up!!!" | ||
else | ||
print "Hey! You pulled the rip code much too soon. " + numJumps + " successful" | ||
print "jumps before yours and you came in number " + jumpDiff + "! Get with it." | ||
end if | ||
else if dist <= 0 and not termVelHit then | ||
print (2 * distance / actAccel) ^ .5 + " " * 5 + "Splat" | ||
else if dist <= 0 and termVelHit then | ||
print velocity/actAccel + ((distance - (velocity^2/(2*actAccel)))/velocity) + " " *5 + "Splat" | ||
end if | ||
|
||
if dist <=0 then | ||
splatMsg.shuffle | ||
print splatMsg[0] | ||
print "I'll give you another chance." | ||
end if | ||
|
||
ans = input("Do you want to play again? ") + " " | ||
ans = ans[0].lower | ||
end while | ||
|
||
print "S" * 10 | ||
Oops, something went wrong.