Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float Stage;
- PVector Position;
- int X;
- //PFont font;
- void setup(){
- size(900,800);
- Position = new PVector (10,height/2);
- Stage = 0;
- rectMode(CENTER);
- X = round(random(0,day()));
- //font = createFont("BAUHS93", 32);
- }
- void draw(){
- if(Stage == 0){
- background(0,0,255);
- }
- if(Stage == 1){
- background(0,255,0);
- fill(0);
- rect(width/2,height/2,50,300);
- }
- if(Stage == 2){
- background(255,0,0);
- fill(10,200,10);
- noStroke();
- rect(600,height/2,100,100);
- }
- fill(255);
- ellipse(Position.x,Position.y,20,20);
- if(keyPressed){
- if (key == CODED) {
- if (keyCode == RIGHT) {
- Position.x+=10;
- }
- if (keyCode == LEFT) {
- Position.x-=10;
- }
- if (keyCode == UP) {
- Position.y-=10;
- }
- if (keyCode == DOWN) {
- Position.y+=10;
- }
- }
- }
- if (Position.x>=width && !(Stage == 2)){
- Position.x = 1;
- Stage += 1;
- }
- if (Position.x<=0 && !(Stage == 0)){
- Position.x = width-1;
- Stage -= 1;
- }
- if (Position.y <=0){
- Position.y = 0;
- }
- if (Position.y >=height){
- Position.y = height;
- }
- if (Stage == 0 && Position.x <= 0){
- Position.x = 0;
- }
- if (Stage == 2 && Position.x >= width){
- Position.x = width;
- }
- if (Stage == 1 && Position.x >= ((width/2)-25) && Position.x <= ((width/2)+25) && Position.y <= ((height/2)+150) && Position.y >= ((height/2)-150)){
- Position.x = ((width/2)-25);
- }
- if (Stage == 2 && Position.y >= ((height/2)-50) && Position.y <= ((height/2)+50) && Position.x <= 650 && Position.x >= 550){
- //textFont(font,32);
- text("You Win!", width/2, 300);
- text("Score:", width/2, 340);
- text(X,(width/2)+40,340);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement