Made in the fall 2018 college semester
By Trevor Thacker

Cat Game is a simple program that I made in my free time after showing someone how to code in Processing. At first it was going to be a simple game for a cat to swat a moving ball on the scree, it turned into something more complex (and also less cat related).

Game Overview
public class ball{
  float radius;
  float x;//Location of the ball
  float y;
  float xMove;//X movement distance per frame
  float yMove;//Y movement distance per frame
  float speedMulti;//Speed multiplier for the circle
  float distLeft = 100;
  
  ball(){
    radius = height/35;
    x = width/2;
    y = height/2;
    xMove = width/200;
    yMove = height/200;
    speedMulti = height/200;
  }
  
  ball(float d){
    radius = d;
    x = width/2;
    y = height/2;
    xMove = width/50;
    yMove = height/50;
    speedMulti = height/50;
  }
  
  public void drawBall(){
    checkCollision();
    ellipse(x,y,radius*2,radius*2);
    x+=xMove;
    y+=yMove;
  }
}
void rainbow(){
  if(phase==0){
    r++; 
    b--; 
  }
  if(phase==1){
    g++; 
    r--; 
  }
  if(phase==2){
    b++; 
    g--; 
  }
  if(r==255||g==255||b==255){
    if(phase==2)phase=-1;
    phase++;
  }
}
public class block{
  float radius = height/140;
  float x;
  float y;
  int hp = 2;
  int load;
  
  block(float xi, float yi){
    x = xi; 
    y = yi;
    load = 1000;
  }
  
  block(float xi, float yi, int t){
    x = xi; 
    y = yi;
    load = t;
  }
  
  float getX(){return x;}
  float getY(){return y;}
  
  boolean hasCollision(){
    if(load <= 0)return true;
    return false;
  }
  
  int alp(){
    if(hasCollision())return 255;
    return 0;
  }
}
void checkCollision(){
  block destroy = null;
  float x = baal.x;
  float y = baal.y;
  for(block temp:boxes){//Check for collision will any blocks
    if(temp.hasCollision()){
      if(abs((x-temp.getX())*(x-temp.getX()))+((y-temp.getY())*(y-temp.getY())) <= (baal.radius+temp.radius)*(baal.radius+temp.radius) && x-temp.getX() != 0 && y-temp.getY() != 0){
        baal.xMove=baal.speedMulti*map(x-temp.getX(),0,sqrt(((x-temp.getX())*(x-temp.getX()))+((y-temp.getY())*(y-temp.getY()))),0,1);
        baal.yMove=baal.speedMulti*map(y-temp.getY(),0,sqrt(((y-temp.getY())*(y-temp.getY()))+((y-temp.getY())*(y-temp.getY()))),0,1);
        temp.hp--;
        if(temp.hp <= 0)destroy = temp;//Will mark a block to be destroyed if its hp is 0
      }
    }
  }
  if(destroy != null)boxes.remove(destroy);
  //Check for collision with screen borders
  if(y-15<=0)baal.yMove=-baal.yMove;
  if(y+15>=height)baal.yMove=-baal.yMove;
  if(x-15<=0)baal.xMove=-baal.xMove;
  if(x+15>=width)baal.xMove=-baal.xMove;
}