mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
Added MiniScript port of 52_Kinema
This commit is contained in:
3
00_Alternate_Languages/52_Kinema/MiniScript/README.md
Normal file
3
00_Alternate_Languages/52_Kinema/MiniScript/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
40
00_Alternate_Languages/52_Kinema/MiniScript/kinema.ms
Normal file
40
00_Alternate_Languages/52_Kinema/MiniScript/kinema.ms
Normal file
@@ -0,0 +1,40 @@
|
||||
// Kinema
|
||||
//
|
||||
// Ported from BASIC to MiniScript by Joe Strout
|
||||
|
||||
print " "*33 + "KINEMA"
|
||||
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
print; print; print
|
||||
|
||||
checkAnswer = function(prompt, correctValue)
|
||||
answer = input(prompt).val
|
||||
right = abs((answer - correctValue)/answer) < 0.15
|
||||
if right then
|
||||
print "Close enough!"
|
||||
else
|
||||
print "Not even close...."
|
||||
end if
|
||||
print "Correct answer is " + correctValue
|
||||
return right
|
||||
end function
|
||||
|
||||
doOneRun = function
|
||||
print; print
|
||||
rightCount = 0
|
||||
V = 5 + floor(35*rnd)
|
||||
print "A ball is thrown upwards at " + V + " meters per second."
|
||||
print
|
||||
rightCount += checkAnswer("How high will it go (in meters)? ", 0.05 * V^2)
|
||||
rightCount += checkAnswer("How long until it returns (in seconds)? ", V/5)
|
||||
t = 1 + floor(2*V*rnd)/10
|
||||
rightCount += checkAnswer("What will its velocity be after " + t +
|
||||
" seconds? ", V-10*t)
|
||||
print
|
||||
print rightCount + " right out of 3."
|
||||
if rightCount >= 2 then print " Not bad."
|
||||
end function
|
||||
|
||||
// main loop (press control-C to break out)
|
||||
while true
|
||||
doOneRun
|
||||
end while
|
||||
Reference in New Issue
Block a user