Make this game work? (hamburgers)

edited December 2013 in How To...

Hi! I'm a Multimedia Designer student and I'm having trouble making my game work. In the game, you're a cooker who makes hamburguers. I have a grid where my ingredients will be, some "recipes" saying what and in wich order to put them, a plate where the ingredients will appear, a time counter, and points.

sssss

Now my questions: should I make a class for the recipes, the hamburguers, and the ingredientes, with arrays on them, then make the arrays compare to know if the hamburguer is well done?

I have a class Recipe (5 ingredients) :

class Recipe{
  int ingredientes [] = new int [5];


Receta (int a, int b, int c, int d, int e){


ingredientes [0]= a;
ingredientes [1]= b;
ingredientes [2]= c;
ingredientes [3]= d;
ingredientes [4]= e;
;
}

in order to know if the hamburguer has the same ingredients like in the recipe (i should make them random later) do I have to make an hamburguer class with the same array of ingredients?

then, how can i make to put those numbers in my grid and know than when I click them, they would fit to the ingredients and make them appear over the plate?

sorry guys i'm so new and desseperate ahaha :(

Tagged:

Answers

  • Just like anything with programming, there are a million different ways to do this. You should choose whichever way makes the most sense to you, not the way that makes the most sense to somebody else.

    You'll probably get a bunch of answers saying "you should do it XYZ" but really all it comes down to is how it fits in your head.

    You've described a couple different approaches already. What happened when you tried each?

  • Receta (int a, int b, int c, int d, int e) {

    What do those passed parameters represent? Quantity or a code for the ingredients themselves?

    Anyways, if you're not gonna deal w/ more than 1 hamburger at a time, there's no real need
    to create a class just for that! Even though it's nice for encapsulation!

  • they are a code for the ingredients.

    now I have that Recipe class and an hamburguer class that goes like this:

    class hamburguer {

    int ingredientes [] = new int [5]; int counter;

    Hamburguer () {

    ingredientes [0]= 0;
    ingredientes [1]= 0;
    ingredientes [2]= 0;
    ingredientes [3]= 0;
    ingredientes [4]= 0;
    

    }

    // to asign ingredients from my grid with each click:

    void asignarIngrediente( int num ) {

    ingredientes[counter] = num;
    if ( counter == 4 ) {
      counter = 0;
      comparar();
    }
    
    
    counter++;
    

    }

    // compare ingredients between the recipe and hamburguer INCOMPLETE

    void comparar() {

    if ((recetas[0]).ingredientes [0] == ingredientes [0]) {
    
    
      image (ok, 380, 10, 70, 70);
      fill (255);
      rect(360, 0, 460, 360);
      fill (#ADD9B6);
      rect (0, 360, width, height-360);
    }
    

    }

    any help for that?

  • i dont know if those zeros are well in those last arrays

Sign In or Register to comment.