need help with game!
in
Programming Questions
•
8 months ago
- //Pimp Man
- boolean displayStartScreen;
- int xmove = 0; int ymove = 0;
- int xpos = 150; int ypos = 150;
- int row = 0; int col = 0;
- int x = 175; int y = 100;
- void setup() {
- size(800, 800); //size of game
- textAlign(CENTER, CENTER); //alignment of timer
- displayStartScreen = true;
- }
- void draw() {
- if ( displayStartScreen ) {
- drawStartScreen(); //call Start Screen
- } else {
- background(0); // Black background
- fill(255);
- text( "" + millis() / 1000, 35, 20 );
- fill(255,140,5);
- rect(450,650,50,50);
- line(200, 100, 200, 400);
- line(200, 400, 475, 400);
- line(475, 400, 475, 650);
- stroke(255);
- player(x,y,xpos,ypos);
- }
- }
- void player(int x,int y, int xpos, int ypos) {
- fill(0,255,0);
- rect(x,y,50,50);
- }
- void drawStartScreen() { //Start Screen
- background(0); //Black Background
- textSize(20);
- text("*Hurry, timer has already started!*", width/2, 500);
- textSize(30);
- text("Press Enter/Return to Start", width/2, height/2); //How to Start
- textSize(70);
- text("PIMP MAN", 400, 200); //Game Title
- }
- void check(){
- if (row > 7 || col > 7 || row < 0 || col < 0 ){
- background(255);
- }
- }
- void keyPressed() {
- if ( displayStartScreen ) {
- if (key == ENTER || key == RETURN) { //Pushed to Start
- displayStartScreen = false;
- if(key == UP) {
- ymove = ymove-100;
- col = col-1;
- check();
- }
- if(key == LEFT){
- xmove = xmove-100;
- row = row-1;
- check();
- }
- if(key == RIGHT){
- xmove = xmove+100;
- row = row+1;
- check();
- }
- if(key == DOWN){
- ymove = ymove+100;
- col = col+1;
- check();
- }
- }
- }
- }
- void animate( ){
- player(x, y, xpos, ypos);
- if(xmove > 0){
- xpos = xpos + 1;
- xmove = xmove - 1;
- }
- if(ymove > 0){
- ypos = ypos + 1;
- ymove = ymove -1;
- }
- }
1