Frogger Assignment.Super late causing me to fail.Help please!

My frogger assignment is super late and i got 2 more assignments to do including exams.I would really appreciate if anyone could help me. :)

Tagged:
«1

Answers

  • sure, post your code

    where are you stuck?

  • have you done OOP?

    make one class Player, one Frog etc.

  • what are the other 2 assignments ?

  • edited May 2015

    You now have two people (probably more) willing to help you, and there is absolutely nothing they can do to help you because no one knows what your goal or assignment is, or what you have working so far.

  • it's a known game.....

  • If it's for an assignment, it's probably not an exact clone.

  • true.....

    ;-)

  • And there is a difference between helping and doing the assignment for OP. :P

  • edited May 2015

    Here is what i managed to do on my own. I've asked for help from my teacher but he is'nt much help,neither are my friend in class. :I

    float y[] = new float [60]; float speed [] = new float [60]; void setup(){ frameRate(60); size(700,600); rectMode(CENTER); ellipseMode(CENTER); noStroke(); // Carssetup();

    }

    void draw(){ cars(); logs(); background(); Froggy(); }

    void drawbackground() { //background background(0);

    //Grass fill(57,149,58); rect(0,520,600,90);

    //Side walk fill(152,149,149); rect(0,500,600,20);

    //Middle grass and curb //Grass fill(57,149,58); rect(0,300,600,50);

    //Curb#1 fill(152,149,149); rect(0,290,600,10);

    //Curb#2 fill(152,149,149); rect(0,350,600,10);

    //More grass fill(57,149,58); rect(0,100,600,50);

    //Curb#3 fill(152,149,149); rect(0,150,600,10);

    //Water fill(51,155,173); rect(0,50,600,60);

    //Even more grass! fill(57,149,58); rect(0,0,600,50);

    //Passing lanes fill(216,245,57); rect(0, 425.5, 30, 10); rect(40, 425.5, 30, 10); rect(80, 425.5, 30, 10); rect(120, 425.5, 30, 10); rect(160, 425.5, 30, 10); rect(200, 425.5, 30, 10); rect(240, 425.5, 30, 10); rect(280, 425.5, 30, 10); rect(320, 425.5, 30, 10); rect(360, 425.5, 30, 10); rect(400, 425.5, 30, 10); rect(440, 425.5, 30, 10); rect(480, 425.5, 30, 10); rect(520, 425.5, 30, 10); rect(560, 425.5, 30, 10); rect(600, 425.5, 30, 10);

    //Passing lanes#2 rect(0, 226, 30, 10); rect(40, 226, 30, 10); rect(80, 226, 30, 10); rect(120, 226, 30, 10); rect(160, 226, 30, 10); rect(200, 226, 30, 10); rect(240, 226, 30, 10); rect(280, 226, 30, 10); rect(320, 226, 30, 10); rect(360, 226, 30, 10); rect(400, 226, 30, 10); rect(440, 226, 30, 10); rect(480, 226, 30, 10); rect(520, 226, 30, 10); rect(560, 226, 30, 10); rect(600, 226, 30, 10);

    //void froggy();{

    //}

    //void cars();{ // }

  • Also bare with the disorganization,Im new at this.

  • Immediate syntax concerns: 1) Don't put a semicolon between the parentheses following a function name and the brackets that surround that function's body. (No: void func();{} Yes: void func(){}). 2) Make sure you match opening brackets with closing ones. Where is drawbackground()'s closing bracket?

  • edited May 2015

    You've called a logs() function, but haven't defined it. You call a Froggy() function, but have defined it as froggy() (case matters).

    Your background's rectangles only show up on half the screen because you have rectMode(CENTER) in setup(), yet appear to be defining rectangle as if CORNER mode were being used.

    Many rectangles are only 600 pixels long, yet the window is 700 pixels wide. I suggest you adjust the size to 600 by 600.

    You probably don't want the call to frameRate() in setup() either.

  • edited May 2015 Answer ✓

    You call ellipseMode(CENTER), but draw no ellipses. You have a Carssetup() function commented out, which isn't meaningful. You have unused y and speed arrays.

    You're got a lot of repetitive code to draw the yellow rectangles for the passing lanes. This is easily replaced by a for loop. My OCD kicked in and I have to make the spacing even too, so I shifted them over by 5 pixels. This was easy to do since the code used a loop (I didn't have to replace a bunch of numbers, only one!).

    Calling functions that don't do anything, while useful for breaking things apart, is rather unnecessary. Everything can go in draw().

    And with all that taken care of, we have a starting point:

    void setup() { 
      size(600, 600); 
      noStroke();
    }
    
    void draw() { 
      background(0);
      fill(57, 149, 58); 
      rect(0, 520, 600, 90);
      fill(152, 149, 149); 
      rect(0, 500, 600, 20);
      fill(57, 149, 58); 
      rect(0, 300, 600, 50);
      fill(152, 149, 149); 
      rect(0, 290, 600, 10);
      fill(152, 149, 149); 
      rect(0, 350, 600, 10);
      fill(57, 149, 58); 
      rect(0, 100, 600, 50);
      fill(152, 149, 149); 
      rect(0, 150, 600, 10);
      fill(51, 155, 173); 
      rect(0, 50, 600, 60);
      fill(57, 149, 58); 
      rect(0, 0, 600, 50);
      fill(216, 245, 57);
      for(int i=5; i<=width; i+=40){ 
        rect(i, 425.5, 30, 10);
        rect(i, 226, 30, 10);
      }
    }
    

    Or, if you were to save the result of that as bg.PNG via save(), the code becomes:

    PImage bg;
    void setup(){
      size(600,600);
      bg = loadImage("bg.PNG");
    }
    void draw(){
      image(bg,0,0);
    }
    

    Now, you want to make a frogger game?

  • edited May 2015

    You'll probably need:

    //- Classes for Cars and Logs, to define what those objects are.
    //- A class for the frog.
    //- Class methods to move and draw those objects.
    //- Code to add those objects at appropriate times.
    //- Detect keyboard input.
    //- Rectangle-rectangle collision detection.
    //- Game states.
    //- Lives and score counters, on-screen display.
    

    There is a lot to do. Post some code attempting any of the above for more help.

  • _vk_vk
    edited May 2015

    As our academics friends likes to say: :)

    Break it in pieces, work each piece separated and when you got them working, put it all together.

    one sketch - draw the "board"

    other - make a "frog"that can be driven by keys make a collision test for it…

    other - make cars that travels across screen modify this one to draw logs instead

    and so on…

    Later, try to put all together.

    Ask along the way… Also Google is your friend.

  • well, honestly, how much days have you left?

    have you done OOP?

    make one class Player, one Frog etc.

    really, when time is pressing just say so

  • edited May 2015

    Re: Chrisir

    Well i got my progress report and I'm an 38 in class which meas my frogger was due on the 15th of April and my Pac-man game was due on the 8th of this month and the exam game was due on the 20th.

    Also can you define OP?

  • Re:TFGuy44

    yes I'm wanting to make a Frogger game for a class assignment.

  • OP = original / first post in a forum thread

  • ah, OOP, you mean

    that's object oriented programming like when you use classes and objects

  • edited May 2015

    TFGuy wrote:

    no one knows what your goal or assignment is, or what you have working so far.

    so, what is the exact assignment??

    one frog and many cars?

    TfGuy has posted a lot of code and tasks.

    Have you done anything of these tasks?

  • edited May 2015

    The Exam Assignment is for me,the student to make a frogger game, one frog and many cars , goal to get to the other side.

    So far I've got this,the only thing I've got correctly is the background. V

    int x1=0,x2=0,x3=0,x4=0,x5=0;
    
    void setup(){
      size(600,600);
      noStroke();
    }
    
    void draw(){
        background(0);
        background(0);
      fill(57, 149, 58); 
      rect(0, 520, 600, 90);
      fill(152, 149, 149); 
      rect(0, 500, 600, 20);
      fill(57, 149, 58); 
      rect(0, 300, 600, 50);
      fill(152, 149, 149); 
      rect(0, 290, 600, 10);
      fill(152, 149, 149); 
      rect(0, 350, 600, 10);
      fill(57, 149, 58); 
      rect(0, 100, 600, 50);
      fill(152, 149, 149); 
      rect(0, 150, 600, 10);
      fill(51, 155, 173); 
      rect(0, 50, 600, 60);
      fill(57, 149, 58); 
      rect(0, 0, 600, 50);
      fill(216, 245, 57);
      for(int i=5; i<=width; i+=40){ 
        rect(i, 425.5, 30, 10);
        rect(i, 226, 30, 10);
      }
    }
       //cars
     for(int i=10; i > xxx.length; i++){
      fill(250,10,10);
      rect(xxx[i],yyy[i],70,30);
     }
    //Restart cars when they get to right side
      if (xxx[i] >= width) {
        xxx[i]=random(-500,0);
        yyy[i]=random(0,height);
         speedxx[i]=random(3,12);
    
           for(int  i=0; i < xxx.length; i++){ 
         xxx[i]=xxx[i]+speedxx[i];
      }
      }
    
    }
    
    {
      fill(30, 198, 68);{
      ellipse(xx,yy,40,40);
    
      //Keybored controll
      if (keyPressed) {
        //Control ellipse
        if (keyCode==RIGHT)
          xx=xx+3;
        if (keyCode==LEFT)
          xx=xx-3;
        if (keyCode==DOWN)
          yy=yy+3;
        if (keyCode==UP)
          yy=yy-3;
      }
      }
    }
    //Cars
    //Variables
    float userxxx=width/2, useryyy=height/2;
    
    
    int i=1; 
     //Arrays for logs to move across screen in water
     float xxx[] = new float[300];
     float yyy[] = new float [300];
     float speedxx [] = new float [300];
    
    
    //Frog
    int xx=300,yy=550;{
    
    }
    
    //Logs
      //Variables 
     //float userx=width/2, usery=height/2;
     //int i=1;
    
     //Arrays for logs to move across screen in water
     float x[] = new float [300];
     float y[] = new float [300];
     float speed [] = new float [300];
    
    
    
     void drawlogs() {
     //Logs
     for(int i=10; i > x.length; i++){
      fill(90,46,46);
      rect(x[i],y[i],70,30);
     }
    
     //Restart logs when 
    
        //they get to right side
      if (x[i] >= width) {
        x[i]=random(-500,0);
       y[i]=random(0,height);
         speed[i]=random(3,12);
    
           for(int i=0; i < x.length; i++){ 
         x[i]=x[i]+speed[i];
      }
     }
    
    }
    

    The reason its so late is because well I'm a beginner at a college level and my teacher has taught me a lot but hasn't showed me how to do any of this information.Other than Arrays,collision, methods,menu's, ifs, and control structure. Making this program drive me insane with anxiety of not know what the hell I'm doing.(sorry for the use of hell, it makes me upset to have stuff late)

  • edited May 2015

    go back.

    edit your post,

    format your code properly

    2 empty lines before and after the code

    select the code with the mouse

    hit ctrl-o

  • read what tfguy and others have written

    write it

    ask concrete questions like I've tried A, wanted top achieve this and my problem is that....

    plan 3 free days for this

  • edited May 2015

    Okay. I've formatted my code. My problem is that I haven't been able to make my Cars appear once I've added the arrays and loops.My main problem is making the other objects move besides the player. I also dont quite understand the use of this segment along with he use of [i]. VV

      if (x[i] >= width) {
        x[i]=random(-500,0);
       y[i]=random(0,height);
         speed[i]=random(3,12);
    
           for(int i=0; i < x.length; i++){ 
         x[i]=x[i]+speed[i];
      }
     }
    
  • edited May 2015
    • W/o planning you won't go far! In order to have your Car objects you'll need OOP.
    • If you dunno OOP, you're gonna need to use multiple arrays bound to an index variable.
    • You gotta decide what a Car has. That is, its properties.
    • Like current coordinates, dimensions, speed, color, etc.
    • Decide which approach you're gonna take. Be it multiple arrays or OOP even before start.
    1. http://forum.processing.org/two/discussion/8082/from-several-variables-to-arrays
    2. http://forum.processing.org/two/discussion/8081/from-several-arrays-to-classes
    3. https://processing.org/tutorials/objects
  • edited May 2015

    Your brackets are all over the place. In the Processing editor, press Ctrl + t to auto-format your code. Once you've done this, you'll realize that you have a for loop outside of any function! Also, I'd put all your global variables at the top.

    Oh wait, the code outside of any function is a duplicate of what's inside drawLogs()... but labeled for cars, and uses xxx and yyy instead of xx and yy arrays. It's like you're trying to do logs and cars at the same time, without getting one working before the other.

    I suggest you forget about using multiple arrays with different names for different objects, and instead step up your game and learn to encapsulate things into logical objects, using OOP. This means you should look up the keyword "class" in the reference.

    It's already late? How much later can it be?

  • edited May 2015

    Here's an example object...........

    class Transient {
      float x, y, w, h, dx;
      Transient() {
        reset();
      }
      void reset() {
        dx = 0;
        while (dx==0) dx = random(-5, 5);
        w = 20;
        h = 20;
        x = dx > 0 ? -w : height;
        y = random(50, 110-h);
      }
      void draw() {
        simulate();
        render();
      }
      void simulate() {
        x+=dx;
        if ( x < -w || x > width) reset();
      }
      void render() {
        fill(0,128,0);
        ellipse(x, y, w, h);
      }
    }
    
    Transient t;
    
    void setup() {
      size(220,220);
      t = new Transient();
    }
    
    void draw() {
      background(255);
      t.draw();
    }
    
  • Re:TfGuy44

    Its already late and i have until the 19th of June to hand in any late work.

  • so...

    get to work...

  • Re:Chrisir

    Okay okay I'm workin'!

  • int userx=300, usery=580;//The chcaracters posotion
    int rs, ls, ts, bs;//collison detection
    int dir = 1;
    int userxx, useryy;
    float x[] = new float [60];
    float y[] = new float [60];
    float speed [] = new float [60];
    void setup() { 
      frameRate(50);
      size(600, 600); 
      noStroke();
      smooth(); 
     carsetup();
    }
    
    void draw(){
      background();
      Cars();
      user();
    }
    //background
    void background() { 
      background(0);
      //Grass
      fill(57, 149, 58); 
      rect(0, 520, 600, 90);
      //Side walk
      fill(152, 149, 149); 
      rect(0, 500, 600, 20);
      //Middle grass
      fill(57, 149, 58); 
      rect(0, 300, 600, 50);
      //Curb
      fill(152, 149, 149); 
      rect(0, 290, 600, 10);
      //Curb#1
      fill(152, 149, 149); 
      rect(0, 350, 600, 10);
      //More grass
      fill(57, 149, 58); 
      rect(0, 100, 600, 50);
      //Curb#2
      fill(152, 149, 149); 
      rect(0, 150, 600, 10);
      //Water
      fill(51, 155, 173); 
      rect(0, 50, 600, 60);
      //Even more grass
      fill(57, 149, 58); 
      rect(0, 0, 600, 50);
      fill(216, 245, 57);
    
          for(int i=5; i<=width; i+=40){ 
        rect(i, 425.5, 30, 10);
        rect(i, 226, 30, 10);
      }
    }
    //Cars
    void Cars(){
      for (int i=0; i < 10; i++) {
        x[i]=x[i]+speed[i];
        if (x[i] >= 0) {
          x[i]=(0);
        }
    
      }
    
      for (int i=40; i < 60; i++) {
        x[i]=x[i]+speed[i];
        if (x[i] <= 0) {
          x[i]=(0);
        }
      }
    
      for (int i=0; i < 60; i++) {
        fill(#6F1FFC);
        rect(x[i], y[i], 40, 40);
      } 
    }
    
    void carsetup(){
     for(int i=0; i < 10; i++) {
        x[i]=(0);
        y[i]=(300);
        speed[i]=(2);
      }
    
       for(int i=0; i < 20; i++) {
        x[i]=(0);
        y[i]=(200);
        speed[i]=(2);
      }
        for(int i=0; i < 30; i++) {
        x[i]=(0);
        y[i]=(450);
        speed[i]=(2);
      }
         for(int i=0; i < 40; i++) {
        x[i]=(0);
        y[i]=(200);
        speed[i]=(2);
      }
         for(int i=0; i < 50; i++) {
        x[i]=(500);
        y[i]=(380);
        speed[i]=(2);
      }
         for(int i=0; i < 60; i++) {
        x[i]=(550);
        y[i]=(380);
        speed[i]=(2);
      }
    } 
    //User
    void user(){
    if (keyPressed) {
        if (key==CODED) {
          if (keyCode==RIGHT)
            userx=userx+8;
          if (keyCode==LEFT)
            userx=userx-8;
          if (keyCode==UP)
            usery=usery-8;
          if (keyCode==DOWN)
            usery=usery+8;
        }
      }
    fill(0,255,200);
    ellipse(userx,usery,30,30);
    rs = get(userx+15,usery);
    ls = get(userx-15,usery);
    ts = get(userx,usery+15);
    bs = get(userx,usery-15);
    text(""+rs,100,50);
    text(""+ls,100,60);
    text(""+ts,100,70);
    text(""+bs,100,80);
    if (rs == -64765){
    exit();
    }
    if (ls == -64765) {
    exit();
    }
    if (ts == -64765) {
    exit();
    }
    if (bs == -64765) {
    exit();
    }
    
    }
    
  • edited May 2015

    ok, I see you don't want to use classes or OOP / Objects

    That's ok for now I guess

    The arrays

    you have the arrays x and y and speed

    I am not sure you get what you want here

    the idea is that these are 3 parallel lists (imagine 3 shopping lists lying next to each other)

    ok, the first car (lets call it CARL) is described by the stuff in the first line:

    • the first line in the first list is CARLs x

    • the first line in the 2nd list is CARLs y

    • the first line in the 3rd list is CARLs speed

    so to display CARL say draw car at first line in first list and at y being first line 2nd list :

      rect(x[i], y[i], 40, 40);
    

    well done. you got that!

    rect(x[1], y[1], 40, 40); or rather rect(x[0], y[0], 40, 40); draws CARL

    Next car is BOB, it's at rect(x[1], y[1], 40, 40);

    Question

    but in carsetup, why do you have 60 cars and place the first 10 cars at the same position?

    moreover, in carsetup you start each for-loop at 0 so you write over the old data from the first for-loops

    re-think that

    or give your reasons

    ;-)

  • in

    void Cars() {
    

    this is stopping it all!!!!!!!!!!!!!!!!!!!!!

      if (x[i] >= 0) {
          x[i]=(0);
        }
    
  • edited May 2015

    two times.....................

    you could make them reappear

  • edited May 2015

    Well I'm unsure about the carsetup in general since i used my friends car setup from their frogger because he managed to get it working.But now that I've tried to fix the numbers for my game it ain't working and my friends cant fix em'. Also the way your explaining the arrays is a little confusing especially around this area.

    the first line in the first list is CARLs x

    the first line in the 2nd list is CARLs y

    the first line in the 3rd list is CARLs speed

  • err.....

    list one is x[]

    list 2 is y[]

    list 3 is speed[]

    in your code

    I want you to understand this and your code.

    one car is described in three lists

    Carl: 1st line in all lists

    Bob: 2nd line in all lists

    understand the difference between list and line (line number) here

    it's useless to copy code from a friend you don't understand

  • You have a point. I'm still confused about lists and lines.

  • the idea is that these are 3 parallel lists (imagine 3 shopping lists lying next to each other)

  • I wrote some code to you could make them reappear.

    that was wrong. ouch

    anyway.

    I fixed your program and can lead you through

    I also understand your carsetup now:

    you got 6 for-loops there, one for each lane, so the y can be different

    but as I said, don't start with 0 every time

    better:

     for (int i=0; i < 10; i++) {
        x[i]=(-22);
        y[i]=(300);
        speed[i]=(2);
      }
    
      for (int i=10; i < 20; i++) {
        x[i]=(-40);
        y[i]=(200);
        speed[i]=(2);
      }
    

    see?

  • the idea is that these are 3 parallel lists (imagine 3 shopping lists lying next to each other)

    to draw first car CARL you would look into the first line of all 3 lists

    then Bob, same lists, but next line of them

  • also in carsetup()

    some cars should go from left to right, others from right to left

    now you have 10 cars right on top of each other

    not good

    you could say x[i]= i*40;

    or so

  • Okay....this is a lot to take in. :-?

  • ??

    come on, you're almost there

    also, what are the other 2 assignments??

  • or in carsetup() just get rid of all for-loops and change the rest accordingly

  • Okay....now my program says"Unexpected void token"

Sign In or Register to comment.