PFont fontA;
PImage Atex;
float Ax = 0;
float Ay = 0;
float Az = 0;
float Arotx = 0;
float Aroty = 0;
float Arotz = 0;
float Bxpos, Bypos;
float Bxspeed = 0;
float Byspeed = 5;
int Bxdirection = 0;
int Bydirection = 1;
int BcircleSize = 70;
float Ca = -100;
void setup() {
size(400, 400, P3D);
fontA = loadFont("ComicSansMS-Bold-48.vlw");
frameRate(30);
textureMode(NORMALIZED);
Atex = loadImage("BlockATexture.jpg");
Bxpos = width/2;
Bypos = height/2;
}
void draw() {
background (32, 177, 252);
// if(keyPressed == true) {
if(key == 'a') {
textFont(fontA, 72);
text('A', 20, 80);
textFont(fontA, 36);
text("Alphabet", 230, 50);
text("Blocks", 250, 90);
fill(255);
stroke(255);
translate(width/2.0, height/2.0, -100);
scale(90);
Ax = Ax + 0.01;
Arotx = Arotx + 0.1;
makeAcube(Ax,Ay,Az,Arotx,Aroty,Arotz,Atex);
}
if(key == 'b') {
textFont(fontA, 72);
text('B', 20, 80);
textFont(fontA, 36);
text("Ball", 280, 60);
fill(255);
BdrawCircle();
fill(255);
}
if(key == 'c') {
textFont(fontA, 72);
text('C', 20, 80);
textFont(fontA, 36);
text("Car", 280, 60);
car();
fill(255);
}
if(key == 'd') {
textFont(fontA, 72);
text('D', 20, 80);
textFont(fontA, 30);
text("Rubber Duckie", 180, 60);
fill(255);
PImage duck;
duck =loadImage ("Duck.png");
image(duck, 50, 100, 300, 300);
}
if(key == 'e') {
textFont(fontA, 72);
text('E', 20, 80);
textFont(fontA, 30);
text("Etcha-Sketch", 180, 60);
noStroke();
fill(255);
fill(169, 20, 20);
quad(75, 170, 75, 370, 325, 370, 325, 170);
fill(181, 170, 170);
quad(110, 195, 110, 330, 290, 330, 290, 195);
fill(242, 242, 242);
ellipse(95, 350, 30, 30);
ellipse(305, 350, 30, 30);
}
}
void BdrawCircle() {
fill(200, 0, 0);
if (Bypos > height-BcircleSize/2) {
Bydirection = -1;
}
if (Bypos < BcircleSize/2) {
Bydirection = 1;
}
ellipse(Bxpos, Bypos, BcircleSize, BcircleSize);
if (keyPressed == true) {
Bypos = Bypos + ( Byspeed * Bydirection );
}
}
void makeAcube(float Ax, float Ay, float Az, float Arotx, float Aroty, float Arotz, PImage Atex){
// +Z "front" face
beginShape(QUADS);
rotateX(PI/1+Arotx);
rotateY(PI/-6);
texture(Atex);
vertex(-1, -1, 1, 0, 0);
vertex( 1, -1, 1, 1, 0);
vertex( 1, 1, 1, 1, 1);
vertex(-1, 1, 1, 0, 1);
// -Z "back" face
vertex( 1, -1, -1, 0, 0);
vertex(-1, -1, -1, 1, 0);
vertex(-1, 1, -1, 1, 1);
vertex( 1, 1, -1, 0, 1);
// +Y "bottom" face
vertex(-1, 1, 1, 0, 0);
vertex( 1, 1, 1, 1, 0);
vertex( 1, 1, -1, 1, 1);
vertex(-1, 1, -1, 0, 1);
// -Y "top" face
vertex(-1, -1, -1, 0, 0);
vertex( 1, -1, -1, 1, 0);
vertex( 1, -1, 1, 1, 1);
vertex(-1, -1, 1, 0, 1);
// +X "right" face
vertex( 1, -1, 1, 0, 0);
vertex( 1, -1, -1, 1, 0);
vertex( 1, 1, -1, 1, 1);
vertex( 1, 1, 1, 0, 1);
// -X "left" face
vertex(-1, -1, -1, 0, 0);
vertex(-1, -1, 1, 1, 0);
vertex(-1, 1, 1, 1, 1);
vertex(-1, 1, -1, 0, 1);
endShape();
}
void car() {
//body
//background (32, 177, 252);
fill(87, 65, 251);
beginShape();
vertex(Ca, 350);
vertex(Ca+10, 300);
vertex(Ca+10, 300);
vertex(Ca+45, 300);
vertex(Ca+45, 300);
vertex(Ca+60, 260);
vertex(Ca+60, 260);
vertex(Ca+140, 260);
vertex(Ca+140, 260);
vertex(Ca+160, 300);
vertex(Ca+160, 300);
vertex(Ca+190, 310);
vertex(Ca+190, 310);
vertex(Ca+200, 350);
vertex(Ca+200, 350);
vertex(Ca, 350);
endShape();
//bumper
stroke(217);
strokeWeight(8);
line(Ca, 350, Ca+200, 350);
//wheels
fill(130);
stroke(0);
ellipse(Ca+50, 350, 30, 30);
ellipse(Ca+160, 350, 30, 30);
//headlight
fill(250, 243, 40);
strokeWeight(3);
ellipse(Ca+180, 320, 15, 15);
//windows
quad(Ca+70, 270, Ca+60, 300, Ca+100, 300, Ca+100, 270);
quad(Ca+110, 270, Ca+110, 300, Ca+150, 300, Ca+137, 270);
if (keyPressed == true) {
Ca= Ca +1;
}
}Alexis-F
on Wednesday, Oct 15, 2008 – 9:09 am
One Comment
It’s good to see some of the motion in the first letters and then disappointing to have none in the later.