// Title: El barquito aventurero (Little Adventurer Boat) // Description: This little boat is tireless, days and nights go over while it travels. // Declaring variables int worldRadius = 50; int move = -15; int moonEndTime = 45; int moonStartTime = 15; int sunStartTime = 45; int sunEndTime = 15; int m = 0; // Setup method void setup(){ size(300, 300); framerate(30); } // Draw method void draw(){ //a cycling degradee background for days and nights colorMode(HSB); int milis = millis() % 60000; int seconds = (milis % 60000)/1000; int c = (seconds * 512)/60; if(seconds > 30) { c = 512 - c; } background (128,200,255-c); colorMode(RGB); // Display title for each language PFont font; fill(230,100,40); font = loadFont("Algerian-22.vlw"); textFont(font, 22); if (millis() < 5000){ text("El barquito aventurero", 10, 30); } if (millis() >= 5000 && millis() <= 10000){ text ("Little Adventurer Boat", 10, 30); } //draw and move Moon if(seconds > moonStartTime && seconds < moonEndTime){ int moonTime = milis - moonStartTime*1000; int moonTimeRange = (moonEndTime - moonStartTime)*1000; int moonX = (moonTime * width)/moonTimeRange; fill (180); ellipse (moonX, 30,15,15); } //draw and move the Sun int sunMillis = milis; if (seconds >= sunStartTime) { sunMillis = sunMillis - sunStartTime*1000; } else { sunMillis = sunMillis + sunEndTime*1000; } if (seconds >= sunStartTime || seconds <= sunEndTime) { int sunX = (sunMillis * width)/30000; fill (255,255,0); smooth(); ellipse (sunX,240,40,40); stroke (255,255,0); strokeWeight (4); pushMatrix (); translate (sunX,240); line (0,35,0,-35); line (-25,25,25,-25); line (-35,0,35,0); line (-25,-25,25,25); popMatrix(); } // Move the origin to the center of the display translate(width/2, height/2); // Set the ellipses' properties for the world frame: color, anti-alias, and the thickness of the line fill(28,214,185); smooth(); stroke (0); strokeWeight(2); // Draw the world frame ellipse(0, 0, (worldRadius) * 2, (worldRadius) * 2); // Draw and move the boat fill (255); strokeWeight (2); int[] xvals = { 0, 8, 22, 14,-14,-22, 8, -8 }; int[] yvals = { -75, -63, -63, -50,-50,-63, -63,-63 }; float angle =radians(seconds*6); rotate(angle); beginShape(POLYGON); pushMatrix(); for(int i = 0; i < xvals.length; i++) { vertex(xvals[i], yvals[i]); } endShape(); popMatrix(); //translate (width*2,height*2); }