Skip to content

Instantly share code, notes, and snippets.

View bogoreh's full-sized avatar
🎯
Focusing

bogoreh

🎯
Focusing
View GitHub Profile
//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);
//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;
//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;
//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));
//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;
//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);
//defining variables
var r = 0;
var theta = 0;
draw = function() {
pushMatrix();
translate(width/2, height/2);
//switching the type of coordinate
//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;
//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;
//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