Created
February 11, 2012 20:27
-
-
Save dmberry/1803996 to your computer and use it in GitHub Desktop.
ZAJAL version of Nick Montfort's '10 PRINT CHR$(205.5+RND(1)); : GOTO 10' example
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
# ------------------------------------------------------ | |
# | |
# ZAJAL version of Nick Montfort's '10 PRINT CHR$(205.5+RND(1)); : GOTO 10' example | |
# | |
# The program generates a random number and an array to generate the screen layout. | |
# It uses a mouse_pressed event to refresh the screen and recalculate the layout. | |
# | |
# The program doesn't quite capture the specific way the C64 prints to the screen | |
# and scrolls up, in fact that would require extra code to essentially emulate the | |
# C64 way of printing characters. In this version I preferred to reinterpret the | |
# original code using Zajal's specific way of doing things. | |
# | |
# Based on the original 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 code by Nick Montfort | |
# | |
# Written by David M. Berry | |
# 11 February 2012 | |
# | |
# For the Critical Code Workshop 2012 | |
# | |
# Written in Zajal ( http://zajal.cc ) | |
# | |
# ------------------------------------------------------ | |
# ------------------------------------------------------ | |
# Here be declarations of variables and array | |
# ------------------------------------------------------ | |
backslash = 92 | |
forwardslash = 47 | |
line = "" | |
array = [] | |
# ------------------------------------------------------ | |
# Here be the MAIN LOOP called Draw (called every screen refresh) | |
# ------------------------------------------------------ | |
draw do | |
color :yellow | |
text "Press a mousebutton to change the screen maze..." | |
color :purple | |
40.times do |n| | |
text array[n] | |
end | |
end | |
# ------------------------------------------------------ | |
# Here be the MOUSE PRESSED LOOP (called every mouse press) | |
# ------------------------------------------------------ | |
mouse_pressed do | |
line = "" | |
array = [] | |
40.times do | |
65.times do | |
if rand(2) == 1 then | |
line = line + backslash.chr | |
else | |
line = line + forwardslash.chr | |
end | |
end | |
array << line | |
line = "" | |
end | |
end | |
# ------------------------------------------------------ | |
# Here be the END OF CODE | |
# ------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment