Midterm Progress (Covid Ninja) – Rhythm Kukreja

For our midterm project, we were tasked with making a game on Processing.

Inspiration

I was inspired by Fruit Ninja to make this kind of game. In fruit ninja, you slice fruits and avoid bombs.

Idea

My idea is to make a game that works similar to fruit ninja but instead of cutting fruits, we cut covid related things; like pills, vaccines, masks, etc and avoid cutting the virus. This game is called covid ninja.

Process

I started by assigning an X and Y variable that works for assigning the coordinates of the fruits. We want gravity in the covid objects, so we added randomize gravity between 0.1 and 0.5, which is further added with velocity to make it look like a free-falling object. Then, I will use a mouse pressed at the location of the object to slice the items. There will also be a slow time powerup which will come to a couple of times in the game for a few seconds to make the items go slower.

This is what the free-falling objects would look like for now:-

The code goes like this:-

int height = 720;
int width = 1040;

String[] covidType = {"mask", "sanitizer", "virus", "vaccine", "pills"};
Game game = new Game();

void setup(){
  size(1040, 720);
  background(0);
}

void draw(){
  background(0);
  game.display();  
}

class Covid {
  int x, y;
  float vy, g;
  PImage img;
  int img_w, img_h;
  
  Covid() {
    x = (int) random(150, width-150);
    y = 0;
    g = random(0.1,0.4);
    img = loadImage(str((int) random(1,6)) + ".png");
    img_w = 100; img_h = 100;
  }
  
  void gravity() {
    vy = vy + g;
  }
  
  void update() {
    gravity();
    y += vy;
  }
  
  void display() {
    update();
    image(img, x, y, img_w, img_h);
  }
}

class Game {
  int difficulty;
  int score;
  int missed;
  int numCovidItems;
  boolean roundOver;
  Covid[] covid;
  
  Game() {
    difficulty = 1;
    score = 0;
    missed = 0;
    roundOver = true;
  }
  
  void updateCovid(){
    numCovidItems = difficulty*3;
    covid = new Covid[numCovidItems];
    for (int i=0; i<numCovidItems; i++){
      covid[i] = new Covid();
    }
  }
  
  void display(){
    if(roundOver == true){
      updateCovid();
      roundOver = false;
    }
    numCovidItems = difficulty*3;
    for (int i=0; i<numCovidItems; i++){
      covid[i].display();
    }
  }
}

 

One thought on “Midterm Progress (Covid Ninja) – Rhythm Kukreja”

  1. Looks great Rhythm. Will the images themselves slice apart or just disappear? Slicing apart would be nice, but given the time constraints just disappearing would work just fine too. Will there be some sort of slicing animation on screen as feedback like in fruit ninja?

Leave a Reply