Skip to content
Permalink
84642e02bc
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
139 lines (119 sloc) 2.2 KB
Console con;
Camera cam;
Mode statusLine;
ArrayList<Point> pointList;
boolean drawCon, drawHelp;
float epsilon = 0.000001;
int G_mode;
// 1 = SCALE
// 2 = PAN
// 3 = ROTATE
// 4 = PLACE
// 5 = SELECT
void setup() {
size(800,800);
background(120);
ellipseMode(CENTER);
con = new Console();
cam = new Camera();
statusLine = new Mode();
pointList = new ArrayList<Point>();
drawCon = false;
drawHelp = true;
G_mode = 1;
}
void draw() {
background(c_background);
pushMatrix();
cam.update();
drawGnoman(200);
for(Point p: pointList) {
p.draw();
}
popMatrix();
if(drawCon) con.draw();
if (drawHelp) {
drawHelpMenu();
} else {
statusLine.draw();
}
}
void keyPressed() {
switch(key) {
case 't':
case 'T':
con.print("t");
drawCon = !drawCon;
break;
case 'f':
case 'F':
G_mode = 1;
break;
case 'd':
case 'D':
G_mode = 2;
break;
case 's':
case 'S':
G_mode = 3;
break;
case 'a':
case 'A':
G_mode = 4;
break;
case 'g':
case 'G':
G_mode = 5;
break;
case 'c':
case 'C':
pointList.clear();
break;
case 'h':
case 'H':
drawHelp = !drawHelp;
break;
}
}
void drawHelpMenu() {
float hwidth = 400;
float hheight = 600;
pushStyle();
strokeWeight (i_helpStrokeWidth);
stroke(c_helpStroke);
fill(c_helpBackground);
rect(width/2 - hwidth/2, height/2 - hheight/2, hwidth, hheight, 50, 50, 50, 50);
textSize(40);
fill(c_helpText);
text("Help:", width/2 - 50, height/2 - hheight/2 + 50);
textSize (30);
float x = width/2 - 150;
float y = height/2 - hheight/2 + 100;
for (int i = 0; i < i_helpStrings; i++) {
text(s_helpStrings[i], x, y);
y += 35;
}
popStyle();
}
void checkSelect() {
}
void drawGnoman(int r) {
pushStyle();
stroke(c_gnoman);
line(-r,0,r,0);
line(0,-r,0,r);
popStyle();
}
void mousePressed() {
if(G_mode == 4) {
pointList.add(cam.transform(new Point(mouseX, mouseY)));
}
cam.mousePressed();
con.print("Pressed");
}
void mouseDragged() {
cam.mouseDragged();
}
void mouseReleased() {
cam.mouseReleased();
}