Created
February 24, 2015 20:51
-
-
Save luc4leone/7ae02eed9b04ae4df126 to your computer and use it in GitHub Desktop.
khan intro to js, lesson on modifying arrays
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
// x positions of baloons and ropes | |
var xPositions = [100, 200]; | |
//when i want more than 1 baloon i need to create | |
//a variable that grows | |
var newInd = 2; | |
var draw = function(){ | |
if (mouseIsPressed){ | |
xPosition[newInd] = mouseX; | |
newInd++; | |
} | |
} | |
noStroke(); | |
background(212, 254, 255); | |
stroke(64, 117, 207); | |
fill(196, 33, 255); | |
for (var i = 0; i < xPositions.length; i++) { | |
line(xPositions[i], 120, 194, 285); | |
ellipse(xPositions[i], 104, 32, 46); | |
} | |
var hopper = getImage("creatures/Hopper-Jumping"); | |
image(hopper, 189, 227); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment