-
-
Save markcmarino/1831768 to your computer and use it in GitHub Desktop.
An iterated version of David M Berry's iteracy.rb that randomizes the text of the points
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
# ---------------------------------------------- | |
# CRITICAL CODE STUDIES: WEEK 2 LITERACIES | |
# | |
# David M. Berry Feb 2012 | |
# modified slightly by Mark C Marino Feb 2012 a bit later | |
# | |
# Based on the webpage: http://stunlaw.blogspot.com/2011/09/iteracy-reading-writing-and-running.html | |
# | |
# ITERATED.RB based on ITERACY.RB | |
# Programmed in Zajal - http://zajal.cc/ | |
# Many thanks to Ramsey Nasser | |
# | |
# ---------------------------------------------- | |
# ---------------------------------------------- | |
# This bit defines and fills the arrays used below | |
# Mark: I decided to break up your longer claims to smaller chunks | |
# ---------------------------------------------- | |
iteracy = ["1. Computational Thinking", "2. Algorithms", "3. Reading and Writing Code", "4. Learning programming languages", "5. Aesthetics of Code", "6. Data and Models"] | |
idesc = ["being able to devise and understand the way in which /ncomputational systems work", "to be able to read and write the code associated with them/n","for example abstraction, pipelining, hashing, sorting, etc./n", "understanding the specifically algorithmic nature /nof computational work/n","e.g. recessions, iteration, /ndiscretisation, etc./n", "practices in reading/writing code require new skills/n", "to enable the reader/programmer/n", "to make sense of and develop /ncode in terms of modularity, data, encapsulation, naming, /ncommentary, loops, recursion, etc./n","understanding one or more concrete programming languages/n", "to enable the student to develop a comparative dimension/n", "to hone skills of iteracy, e.g. procedural, functional, object-oriented, etc./n","developing skills related to appreciating the aesthetic /n dimension of code/n","here I am thinking of 'beautiful code' and 'elegance' as key/n concepts./n","understanding the significance and importance of /n", "data, /ninformation and knowledge and their relationships to /nmodels in computational thinking (abstract machines, etc.)./n"] | |
# ---------------------------------------------- | |
# This bit initalises the global variables used | |
# ---------------------------------------------- | |
x2, y2 = 250, 250 | |
current = "" | |
description = " " | |
counter = 0 | |
tcounter = 0 | |
xx = 10 | |
yy = 200 | |
startcounter = 0 | |
setup do | |
# ---------------------------------------------- | |
# This bit initialises all the variables used | |
# ---------------------------------------------- | |
current = iteracy [counter] | |
description = idesc [counter] | |
counter = counter +1 | |
tcounter= tcounter +1 | |
size 500 | |
title "ITERATED" | |
background 0 | |
fill false | |
alpha_blending true | |
smoothing true | |
circle_resolution 64 | |
end | |
draw do #main loop | |
# ---------------------------------------------- | |
# This bit asks the question | |
# ---------------------------------------------- | |
color :green | |
text " ------------ CODE LITERACY QUESTION --------------" | |
text "" | |
text " @MARKCMARINO: Who has a good alternative to 'literacy' " | |
text " when it comes to programming or reading code? " | |
text "" #add a space | |
color :yellow | |
text " @BERRYDM: 'ITERACY' based on the notion of iteration." | |
text " Iteration deals with looping through a " | |
text " collection (like an array) using loops." | |
text "" #add a space | |
text " --------- click mouse for more details -----------" | |
# ---------------------------------------------- | |
# This bit answers the question from the array above | |
# ---------------------------------------------- | |
color :white | |
text current, xx, yy | |
textarray = description.split("/n") #break the description into lines based on '/n' | |
for startcounter in (0..textarray.count) # iteration (loop) to print paragraph description | |
text textarray[startcounter], xx, yy+30+(startcounter*13) | |
end | |
# ---------------------------------------------- | |
# This bit draws the funky iterative background | |
# ---------------------------------------------- | |
alpha = 0..200 #define variable alpha | |
radius = 100..500 #define variable radius | |
depth = 40 #define variable depth | |
depth.times do |n| | |
t = n/depth.to_f | |
color 255, alpha * t #define colour and shades | |
circle x2, y2 + sin(time * 0.001 + n * 0.25) * 30, radius * t**2 #draw circles | |
end | |
end | |
mouse_down do |x, y, btn| #mouse press loop | |
# ---------------------------------------------- | |
# This bit iterates through the answers from the array above | |
# ---------------------------------------------- | |
current = iteracy [tcounter] | |
description = description + " " + idesc [counter] | |
counter = random max (14) #I wanted to radomize the combination | |
tcounter = tcounter +1 | |
if tcounter > 5 | |
tcounter = 0 | |
description = " " | |
current = " " #Mark: wanted to erase the board every so often | |
end | |
xx = 10 | |
yy = 150 # Leave in Place | |
startcounter = 0 # reset the startcounter | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment