xxxxxxxxxx
PFont hello;
PFont name;
int x = 0;
int y = 0;
int z = 250;
int c = 700;
int e = 250;
int t = 0;
int l = 0;
int ra = 0;
int ri = 0;
int rn = 0;
int ro = 0;
int sy = -700;
int ax = 100;
int ay = 140;
int ix = 200;
int iy = 140;
int nx = 300;
int ny = 140;
int ox = 400;
int oy = 140;
int axr =0;
int ayr = 0;
int ixr = 0;
int iyr = 0;
int nxr = 0;
int nyr = 0;
int oxr = 0;
int oyr = 0;
int timer = 0;
void setup() {
size(500, 500);
hello = loadFont("RosewoodStd-Regular-48.vlw");
name = loadFont("RosewoodStd-Regular-48.vlw");
frameRate(60);
}
void draw() {
background(0);
if (y>=700) { // game
textFont(name, 80);
text("A", 70-700+ra, 170);
textFont(name, 80);
text("I", 180-700+ri, 170);
textFont(name, 80);
text("N", 270-700+rn, 170);
textFont(name, 80);
text("O", 370-700+ro, 170);
ellipse(e, sy, 5, 10); // bullet
if ((ax - e) * (ax - e) + (ay - sy) * (ay - sy) < (40 + 5) * (40 + 5)) { //hit
ra =700;
e=700;
}
if ((ix - e) * (ix - e) + (iy - sy) * (iy - sy) < (40 + 5) * (40 + 5)) { //hit
ri =700;
e=700;
}
if ((nx - e) * (nx - e) + (ny - sy) * (ny - sy) < (40 + 5) * (40 + 5)) { //hit
rn =700;
e=700;
}
if ((ox - e) * (ox - e) + (oy - sy) * (oy - sy) < (40 + 5) * (40 + 5)) { //hit
ro =700;
e=700;
}
ax += axr;
ay += ayr;
ix += ixr;
iy += iyr;
nx += nxr;
ny += nyr;
ox += oxr;
oy += oyr;
if (ax>=500|| ax<0) {
axr = -axr;
}
if (ix>=500|| ix<0) {
ixr = -ixr;
}
if (nx>=500|| nx<0) {
nxr = -nxr;
}
if (ox>=500|| ox<0) {
oxr = -oxr;
}
if (ay>=300 || ay<0) {
ayr = -ayr;
}
if (iy>=300 || iy<0) {
iyr = -iyr;
}
if (ny>=300 || ny<0) {
nyr = -nyr;
}
if (oy>=300 || oy<0) {
oyr = -oyr;
}
ellipse(ax+ra, ay, 80, 80); // target1_1
ellipse(ix+ri, iy, 80, 80); // target2_1
ellipse(nx+rn, ny, 80, 80); // target3_1
ellipse(ox+ro, oy, 80, 80); // target4_1
triangle(z-20, 430, z, 390, z+20, 430); //Shooter
if ( t == 0) {
if (timer > 1*60 ) {
fill(0, 0, 0, 0);
}
if (timer == 2*60) {
timer =0;
}
textFont(name, 20);
text("PRESS SHIFT TO SHOT", 150+t, 330);
}
sy -=10;
if (z >= 500) {
z = 1;
}
if (z <= 0) {
z = 499;
}
if ( ra == 700 && ri == 700 && rn == 700 && ro == 700) { //clear
z= 700;
textFont(name, 40);
text("CONGRATULATIONS", 80, 300);
textFont(name, 20);
text("PRESS CTRL TO TRY AGAIN", 130, 430);
}
noStroke();
fill(0, 255, 0);
}
fill(0, 255, 0); //title
x += 1;
if (x>=400) {
x=400;
}
if (x == 400) {
textFont(name, 20);
text("CREDIT : 0", 400+y, 480);
textFont(name, 20);
text("HIGH SCORE : 00324", 300+y, 20);
if (timer > 1*60 ) {
fill(0);
}
if (timer == 2*60) {
timer =0;
}
textFont(name, 25);
text("PRESSE MOUSE", 170+y, 380);
timer ++;
}
fill(0, 255, 0);
textFont(hello, 60);
text("hello world", 70+y, 550-x);
textFont(name, 45);
text("AINO", 205+y, 650-x);
stroke(0, 0, 0, 120);
l += 10;
strokeWeight(3);
line(-10, l, 600, l);
line(-10, l+250, 600, l+250);
strokeWeight(1);
line(-10, l+20, 600, l+20);
line(-10, l+240, 600, l+240);
if (l >= 500) {
l -= 500;
}
}
void mousePressed() {
if (x == 400) {
y = 700;
}
else if (x < 400) {
x = 400;
axr= (int)random(-10, 10);
ayr= (int)random(-10, 10);
ixr= (int)random(-10, 10);
iyr= (int)random(-10, 10);
nxr= (int)random(-10, 10);
nyr= (int)random(-10, 10);
oxr= (int)random(-10, 10);
oyr= (int)random(-10, 10);
}
if ( y < 700) {
ax = 100;
ay = 140;
ix = 200;
iy = 140;
nx = 300;
ny = 140;
ox = 400;
oy = 140;
}
}
void keyPressed() {
if (key == CODED) {
if (keyCode == LEFT) {
z -= 10;
e -= 10;
}
else if (keyCode == RIGHT) {
z += 10;
e += 10;
}
else if (keyCode == SHIFT) {
if (y>=700) {
if (sy<=0 || e == 700) {
sy=400;
e=z;
t=700;
}
}
}
else if (keyCode == CONTROL) {
if ( ra == 700 && ri == 700 && rn == 700 && ro == 700) {
ra=0;
ri=0;
rn=0;
ro=0;
z=250;
y=0;
x=0;
t=0;
}
}
}
}