Build
Save
Load
Back
var sketchProc = function(processingInstance) { with (processingInstance) { size(400, 400, OPENGL); frameRate(60); smooth(); var x = width/2; var y = height/2; var z = 0; var keys = []; var keyPressed = function() { keys[keyCode] = true; }; var keyReleased = function() { keys[keyCode] = false; }; var angle = 0; var colF = false; var colB = false; var colL = false; var colR = false; var wall = function(X, Y, Z) { noStroke(); pushMatrix(); translate(X, Y, Z); fill(100, 50, 0); box(100, 50, 10); popMatrix(); if(Z === 305 && X <= 270 && X >= 130 && Y > 155 && Y < 250) { colF = true; } if(Z === 317.5 && X <= 270 && X >= 130 && Y > 155 && Y < 250) { colB = true; } if(X === 127.5 && Z >= 305 && Z <= 315 && Y > 155 && Y < 250) { colL = true; } if(X === 272.5 && Z >= 305 && Z <= 315 && Y > 155 && Y < 250) { colR = true; } }; var sideWall = function(X, Y, Z) { noStroke(); pushMatrix(); translate(X, Y, Z); fill(100, 50, 0); box(10, 50, 100); popMatrix(); if(Z === 255 && X < 230 && X > 170 && Y > 155 && Y < 250) { colF = true; } if(Z === 365 && X < 230 && X > 170 && Y > 155 && Y < 250) { colB = true; } if(Z < 365 && Z > 255 && X === 170 && Y > 155 && Y < 250) { colL = true; } if(Z < 365 && Z > 255 && X === 230 && Y > 155 && Y < 250) { colR = true; } }; var ground = function(X, Y, Z) { pushMatrix(); noStroke(); fill(0, 255, 0); translate(X, Y, Z); box(width*2, 1, width*2); popMatrix(); fill(0, 155, 0); noStroke(); pushMatrix(); translate(X, Y+5, Z); box(width*6, 1, width*6); popMatrix(); if(Z === 705) { colF = true; } if(Z === -95) { colB = true; } if(X === 575) { colL = true; } if(X === -175) { colR = true; } }; var sun = function(X, Y, Z) { fill(255, 255, 255, 10); pushMatrix(); noStroke(); translate(X, Y, Z); noStroke(); for(var i = 0; i < 60; i++) { sphere(i); } popMatrix(); }; var draw = function() { lights(); background(64, 126, 179); sun(x-200, y-300, z-width-100); ground(x, y+25, z) if(keys[UP] && !colF) { z+=2.5; } if(keys[DOWN] && !colB) { z-=2.5; } if(keys[LEFT] && !colL) { x+=2.5; } if(keys[RIGHT] && !colR) { x-=2.5; } colF = false; colB = false; colL = false; colR = false; fill(255); textSize(18); textAlign(CORNER); text("X: "+x+"\nY: "+y+"\nZ: "+z, 5, 5); text("Players\nPlayer1\nPlayer2\nPlayer3\nPlayer4\nPlayer5", 300, 5); angle+=0.05; } } } var canvas = document.getElementById("screen"); var processingInstance = new Processing(canvas, sketchProc);