This file contains hidden or 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
| //original code based on my Creature comforts and critter jitters project | |
| //includes ladybugs that oscillate around a flower | |
| //setting angle mode to radians instead of degrees | |
| angleMode = "radians"; | |
| //defining the properties of the flower | |
| var Flower = function(){ | |
| this.position = new PVector(width/2, height-100); |
This file contains hidden or 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
| //changing angle mode to radians instead of degrees | |
| angleMode = "radians"; | |
| //declaring properties of the pendulum | |
| var Pendulum = function(origin, armLength, angle) { | |
| this.origin = origin; | |
| this.armLength = armLength; | |
| this.position = new PVector(); | |
| this.angle = angle; | |
This file contains hidden or 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
| //changing angle mode from degrees to radians | |
| angleMode = "radians"; | |
| //defining the properties of the wave | |
| var Wave = function(amplitude, period, color) { | |
| this.startAngle = 0; | |
| this.amplitude = amplitude; | |
| this.period = period; | |
| this.color = color; | |
| this.angleVel = (TWO_PI / this.period) * 5; |
This file contains hidden or 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
| //setting angle mode to radians instead of degrees | |
| angleMode = "radians"; | |
| //defining spaceship variable | |
| var Spaceship = function() { | |
| this.a = 0; | |
| this.angVelocity = 0; | |
| this.angle = new PVector(); | |
| this.velocity = new PVector(random(-0.05, 0.05), random(-0.05, 0.05)); |
This file contains hidden or 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
| //converting mode to degrees | |
| angleMode = "radians"; | |
| //displaying the slinky on the canvas | |
| var drawSlinky = function(centerX, startY, endY) { | |
| noFill(); | |
| colorMode(HSB); | |
| strokeWeight(2); | |
| ellipseMode(CENTER); | |
| var overlap = 0.8; |
This file contains hidden or 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
| //use the left and right arrow keys to turn the spaceship and press the z key to speed up | |
| //based on code from "Turning car" in Khan Academy | |
| //changing angle mode to radians instead of degrees | |
| angleMode = "radians"; | |
| //function declaring properties of spaceship | |
| var Spaceship = function() { | |
| this.position = new PVector(width/2, height/2); |
This file contains hidden or 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
| //defining variables | |
| var r = 0; | |
| var theta = 0; | |
| draw = function() { | |
| pushMatrix(); | |
| translate(width/2, height/2); | |
| //switching the type of coordinate |
This file contains hidden or 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
| //setting angle to radians instead of degrees | |
| angleMode = "radians"; | |
| //declaring original car function | |
| var Car = function() { | |
| this.position = new PVector(width/2, height/2); | |
| this.velocity = new PVector(3, 0); | |
| this.acceleration = new PVector(0, 0); | |
| this.topspeed = 4; | |
| this.xoff = 1000; |
This file contains hidden or 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
| //setting mode to radians isntead of degrees | |
| angleMode = "radians"; | |
| //declaring properties of the boulder | |
| var Boulder = function(m, x, y) { | |
| this.position = new PVector(x, y); | |
| this.mass = m; | |
| this.width = this.mass * 10; | |
| this.angle = 0; | |
| this.aVelocity = 0; |
This file contains hidden or 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
| //making the mode radians | |
| angleMode = "radians"; | |
| //declaring variable that dictates how much to spin it by | |
| var spin = 0; | |
| draw = function() { | |
| background(255); | |
| pushMatrix(); | |
| //translating baton to the middle |