Can someone help us with our game?

I really need's someone help right now. It's a very easy game for you guys.

Tagged:

Answers

  • Answer ✓

    This post would be helpful if I knew what help you needed. What game? Do you have code? Images? Can we see what you have already? What still doesn't work? What are you trying to do?

  • edited October 2014
    //Car
    Car car1;
    b1 b1;
    o1 o1;
    int xx=1000;
    int virtualMouseY;
    float y1= random(390, 600);
    int c1=0;
    int d=0;
    int speed=1;
    int p=0;
    PImage bg;
    
    void setup() {
      size(1000, 600);
      bg = loadImage("road.jpg");
      car1= new Car();
      b1= new b1();
      o1= new o1();
      smooth();
    }
    
    void draw() {
      println(c1);
      loop();
      noStroke();
      background(bg);
      fill(183, 67, 123);
      car1.cardisplay();
      virtualMouseY = constrain(mouseY, 335, 525);
      fill(128);
      b1.b1();
      o1.o1();
      xx-=speed;
      fill(108);
      textSize(15);
      text("CLICK TO PAUSE", 10, 55);
      fill(255, 169, 88);
      textSize(35);
      text("Score:", 10, 35);
      text(c1*100, 120, 35);
      if (xx<=-20) {
        xx=1000;
        c1+=1;
        y1=(y1*3)+1;
        if (y1>1000) {
          y1=y1%1000;
        }
      }
      if (((y1-15<=virtualMouseY)&&(y1+15>=virtualMouseY))&&(xx-27<=25)) {
        noLoop();
        d=1;
      }
      if (d==1) {
        background(128);
        textSize(42);
        fill(245, 166, 166);
        text("GAME OVER", 400, 240);
        fill(255);
        text("SCORE:", 450, 290);
        text(c1*100, 450, 340);
        fill(166, 214, 245);
        text("CLICK TO RETRY", 350, 390);
      }
      if (c1>=1) {
        speed=(c1/1)+1;
      }
    }
    
    class Car {
      void cardisplay() {
        rect(30, virtualMouseY, 100,35);
         rect(40, virtualMouseY-20, 60,20);
    
        fill(0);
        ellipse(40,virtualMouseY+40,15,15);
        ellipse(120,virtualMouseY+40,15,15);
      }
    }
    class b1 {
      void b1() {
        beginShape();
        vertex(xx-1000, 216);
        vertex(xx-951, 216);
        vertex(xx-951, 247);
        vertex(xx-931, 228);
        vertex(xx-923, 247);
        vertex(xx-923, 150);
        vertex(xx-908, 135);
        vertex(xx-893, 150);
        vertex(xx-893, 179);
        vertex(xx-882, 167);
        vertex(xx-870, 179);
        vertex(xx-870, 195);
        vertex(xx-826, 195);
        vertex(xx-826, 224); 
        vertex(xx-807, 198);
        vertex(xx-788, 224);
        vertex(xx-768, 198);
        vertex(xx-749, 224);
        vertex(xx-749, 150);
        vertex(xx-734, 135);
        vertex(xx-719, 150);
        vertex(xx-719, 217);
        vertex(xx-671, 217);
        vertex(xx-671, 248);
        vertex(xx-657, 228);
        vertex(xx-642, 248);
        vertex(xx-642, 195);
        vertex(xx-599, 195);
        vertex(xx-599, 224);
        vertex(xx-579, 200);
        vertex(xx-560, 224);
        vertex(xx-560, 179);
        vertex(xx-548, 168);
        vertex(xx-536, 179);
        vertex(xx-536, 233);
        vertex(xx-493, 233);
        vertex(xx-493, 195);
        vertex(xx-449, 195);
        vertex(xx-449, 151);
        vertex(xx-435, 136);
        vertex(xx-420, 151);
        vertex(xx-420, 179);
        vertex(xx-409, 167);
        vertex(xx-397, 179);
        vertex(xx-384, 167);
        vertex(xx-373, 179);
        vertex(xx-373, 223);
        vertex(xx-353, 198);
        vertex(xx-328, 233);
        vertex(xx-292, 233);
        vertex(xx-292, 214);
        vertex(xx-249, 214);
        vertex(xx-249, 179);
        vertex(xx-236, 168);
        vertex(xx-224, 179);
        vertex(xx-224, 225);
        vertex(xx-204, 200);
        vertex(xx-186, 225);
        vertex(xx-186, 151);
        vertex(xx-171, 137);
        vertex(xx-156, 151);
        vertex(xx-156, 197);
        vertex(xx-114, 197);
        vertex(xx-114, 181);
        vertex(xx-101, 169);
        vertex(xx-89, 181);
        vertex(xx-89, 215);
        vertex(xx-48, 215);
        vertex(xx-23, 181);
        vertex(xx, 211);
        vertex(xx, 216);
        vertex(xx, 216); //1st
        vertex(xx, 216);
        vertex(xx+49, 216);
        vertex(xx+49, 247);
        vertex(xx+63, 228);
        vertex(xx+77, 247);
        vertex(xx+77, 150);
        vertex(xx+92, 135);
        vertex(xx+107, 150);
        vertex(xx+107, 179);
        vertex(xx+118, 167);
        vertex(xx+130, 179);
        vertex(xx+130, 195);
        vertex(xx+174, 195);
        vertex(xx+174, 224); 
        vertex(xx+193, 198);
        vertex(xx+212, 224);
        vertex(xx+232, 198);
        vertex(xx+251, 224);
        vertex(xx+251, 150);
        vertex(xx+266, 135);
        vertex(xx+281, 150);
        vertex(xx+281, 217);
        vertex(xx+329, 217);
        vertex(xx+329, 248);
        vertex(xx+343, 228);
        vertex(xx+358, 248);
        vertex(xx+358, 195);
        vertex(xx+401, 195);
        vertex(xx+401, 224);
        vertex(xx+421, 200);
        vertex(xx+440, 224);
        vertex(xx+440, 179);
        vertex(xx+452, 168);
        vertex(xx+464, 179);
        vertex(xx+464, 233);
        vertex(xx+507, 233);
        vertex(xx+507, 195);
        vertex(xx+551, 195);
        vertex(xx+551, 151);
        vertex(xx+565, 136);
        vertex(xx+580, 151);
        vertex(xx+580, 179);
        vertex(xx+591, 167);
        vertex(xx+603, 179);
        vertex(xx+616, 167);
        vertex(xx+627, 179);
        vertex(xx+627, 223);
        vertex(xx+647, 198);
        vertex(xx+672, 233);
        vertex(xx+708, 233);
        vertex(xx+708, 214);
        vertex(xx+751, 214);
        vertex(xx+751, 179);
        vertex(xx+764, 168);
        vertex(xx+776, 179);
        vertex(xx+776, 225);
        vertex(xx+796, 200);
        vertex(xx+814, 225);
        vertex(xx+814, 151);
        vertex(xx+829, 137);
        vertex(xx+844, 151);
        vertex(xx+844, 197);
        vertex(xx+886, 197);
        vertex(xx+886, 181);
        vertex(xx+899, 169);
        vertex(xx+911, 181);
        vertex(xx+911, 215);
        vertex(xx+952, 215);
        vertex(xx+977, 181);
        vertex(xx+1000, 211);
        vertex(xx+1000, 216); //1st
        vertex(xx+1049, 216);
        vertex(xx+1049, 247);
        vertex(xx+1049, 315);
        vertex(xx-1000, 315);
        endShape(CLOSE);
      }
    }
    class o1 {
      void o1() {
        ellipse(xx+50, y1, 50, 40);
        ellipse(xx+150, y1+3, 40, 30);
        ellipse(xx+200, y1+6, 40, 30);
        ellipse(xx+300, y1+9, 40, 30);
        ellipse(xx+400, y1+12, 40, 30);
        ellipse(xx+500, y1+15, 40, 30);
      }
    }
    void mousePressed() {
      if (d==1) {
        redraw();
        c1=0;
        speed=1;
        d=0;
        xx=1000;
      }
      if ((d==0)&&(p==0)) {
        noLoop();
        background(110);
        fill(255);
        textSize(42);
        fill(245, 166, 166);
        text("PAUSED", 450, 280);
        fill(166, 214, 245);
        text("CLICK TO RESUME", 350, 330);
        p=1;
      }
      if ((d==0)&&(p==1)) {
        redraw();
        p=0;
      }
    }
    
  • road the image is saved as road.jpg

    I would like to ask help for the obstacles, which are the tiny stones to be a point. Example, if the car passes one rock then there is a corresponding point.

  • The problem in our game is that the points correspond to the set instead of one stone only.

  • edited October 2014

    It is a convention to write class names with a capital as first letter

    I would not recommend to have a one/2 letter class such as b1 - better say Building

    Also the same name for class and object looks weird...

    The object of that class starts with a small letter by convention so line 3 could be

    Building building; 
    

    or (not as good)

    Building bldg; 
    

    I don't understand why people don't use full names...

    Same goes for o1...

    I also recommend to have all classes together at the end of the sketch - and not in the middle as you have.

    ;-)

  • edited October 2014

    it looks nice btw

    the stones shouldn't be allowed to be placed up in the sky...

    also you call the method in line 32 /33 which has the same name as the class. Thus it is the constructor. Which shouldn't be called like this at all... This is not good...

    name the method in 234 draw() or display() pls

    read the tutorial on oop pls....

    Car class is much better

  • I assume that o1 is the obstacle...

    you want to give it random values for x and y - see random in the reference pls

    you need to store the values in 5 vars or in an array

    then display them from 5 vars or the array

    do the collision check Car against 5 vars or the array

  • "I don't understand why people don't use full names..."
    I fully agree, but it will be easier when the PDE will have auto-completion...

Sign In or Register to comment.