Small Brain, sadly not Big brain

So, after the weird phase of having two separate codes that did two separate things (for those weird ones reading this post of mine for some unknown reason, that post is private because I am so ashamed of my level that you shall never see it or else I am going to die from embarrassment) I moved on more risky stuff (at least in my opinion) (and if this is Professor Aaron reading this code and seeing that it’s private, it means that halfway though I got very self-conscious about my code and decided to privatize it).

So, what I did was “merging” them in a way. I needed to substitute ellipses for the images of the books and Instagram. On the way there I changed the pictures because I didn’t like the way the designs of the ones I had looked next to each other, especially now that the background changes from black to white.

In order to change the images, I went to the Drop class and changed the ellipse shape to (image) and there I added all the required global variables and yay, it worked 😀

class Drop {
  float x;
  float y;
  float r;
  float speedY;
  float c;
  PImage dropbrain;
  boolean isCaught;

  Drop() {
    r = 8;
    x = random(width);
    y = -r*4;
    speedY = random(1, 50);
    isCaught = false;
  }

  void update() {
    //position

    y += speedY;

    //check bounds

    if (y>height + r) {
      y = -r;
    }
  }

  void display() {
    if (isCaught != true) {
      imageMode(CENTER);
      dropbrain = loadImage("dropbrain.png");
      image(dropbrain, x, y, r*4, r*4);
    }
  }

  void caught() {
    isCaught = true;
  }

  void reset() {
  }
}

//If (drops[I].alive==true){drops[I].show; drops[I].move}

Then, a few interesting things happened, because I needed to add another drop class for the “bad” things that were going to serve as a distraction (aka instagram). I figured that I needed to create another class, and it would be exactly similar to the drop class I already have. So, I create badDrop class and copied the information from the class above with few alterations of changing the image and adding changes in names of for() loops in the main CatcherGame tab.

The tricky part gets when the images did not disappear when intersecting with the little brain image of a catcher. I asked Mister Jack about this, and he showed a pretty handy solution.

My main issue is that despite having drops[i].caught in the main sketch, I didn’t put the code in there, so it wasn’t running any functions. I needed a boolean that would indicate whether the drop is caught or not. So, after adding it, it worked, yay!

So, now that I had a game that was running with everything except without a score that went down when you caught badDrops. I needed to solve that. So, I just added the score-- in the for() loop for badDrop in the main sketch.

      if (intersect(catcher, badDrops[i]) == true) {
        badDrops[i].caught(); 
        score--;
      }

That worked, however, now the score went to a negative number and I needed the player to lose when the score was less than a zero. Finally… Time for an if function has come. You may not believe it, but I actually never used it because for some unknown reason I was very scared of the power it had. It is partially the reason why I choose switch screen function instead of multiple if functions. I have been avoiding it for as long as I could. So, when I used it today it was a pretty big deal. And of course, I failed :,)

The function worked, however, the reset part of the score did not work, so the game did not switch back to screen 0 (or instructions page) since the score did not reset back to zero. So it basically prevented me from changing the screen by pressing the key. I sat there watching the screen and changing the placement for a good 3 hours and after almost giving up and thinking about dropping Interactive media I decided to ask help from, you guessed it, Mister Jack. Mister Jack enlightened me in the simple truth that my screen was reset, but my small brain should’ve focused on void keyPressed() instead of changing the placement of the if function. So, after changing the placement of score = o to void keyPressed(), my game worked, and now I am here  :3

My final game*:

CatcherGame – PRESS ON ME IT WOULD BE FUNNY!!!

  • – I love seeing the suggestions of videos everyone has since mine are always Minecraft related, and it’s accurate, so we actually get a sneak peek of what every one of us watches haha

Conclusions:

  • Mister Jack is great! If Mister Jack ever reads this, the biggest, huge, enormous thanks to you. You literally saved many (and I don’t have many of them) nerves of mine 😀

P.s. Mister Aaron is great as a given 😀 😀

  • Private button her is just as great in helping me not die from embarrassment in front of many people. Instead, I just need to feel ashamed in from of Mister Aaron, and I am getting quite used to it. Triple 😀 😀 😀

References:

  • The YouTube tutorial for the catcher explanation: https://www.youtube.com/watch?v=dti_mVscdxY and https://www.youtube.com/watch?v=gXPf_R_hDP0
  • The YouTube tutorial for changing the game states that never actually became useful: https://www.youtube.com/watch?v=vgKQHocitd4

Leave a Reply