Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
My implementation in Scheme of the game Kinema, that was published in BASIC Computer Games in 1978.
(use srfi-13 extras)
(printf #<<EOF
Adaption of BASIC computer game from 1978
(define correct-count)
(define (prompt-and-evaluate-answer question answer)
(display question)
(display "? ")
(let ((G (read)))
(if (> .15 (abs (/ (- G answer) answer)))
(display "Close enough.")
(set! correct-count (+ correct-count 1)))
(display "Not even close...."))
(printf "Correct answer is ~A\n" answer)))
(define (main)
(newline) (newline)
(let* ((velocity (+ 5 (random 35)))
(time (/ (+ 1 (* 2 (random velocity))) 10)))
(set! correct-count 0)
"A ball is thrown upwars at ~A meters per second.\n\n"
"How high will it go (in meters)"
(* .05 (* velocity velocity)))
"How long until it returns (in seconds)"
(/ velocity 5))
(sprintf "What will its velocity be after ~A seconds" time)
(- velocity (* 10 time)))
(printf "\n~A right out of 3." correct-count)
(when (> correct-count 2) (display " not bad!"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.