MidTerm Project- “Help Milo!”

Concept

My midterm project, “Help Milo!”, is a high score based game where the players help a cat named Milo collect as many food items as possible. When it came to deciding the kind of character and theme I would adopt for this game, I instantly knew it had to revolve around cats and specifically my pet cat, unsurprisingly named Milo. Initially, my sketch for this project was very abstract as I had created randomly sized platforms that emerged at different instances. But then the idea of creating an almost picture frame view of the game looked better, so I decided to go for a more organized platform design. 

 

In the game, the player uses LEFT and RIGHT arrow keys to move the cat along the platforms that continuously move upwards. Moving the cat to the top of the ladder causes it to climb down so it avoids touching the top of the frame. The player needs to collect as many food items as possible and avoid touching the upper frame or falling on the bottom frame. The score gets updated and high score is also displayed at the end. The game restarts when ENTER is pressed. 

Game Code

For this game, I created classes for both the player, platforms, and bonuses (food item). Through the classes, I was able to append the class objects into arrays for both platforms and bonuses so that the for loop in the draw function could iterate over the arrays for any function. At a specific frameRate, new platform objects and bonuses are created and then when they move beyond the frame, they are removed from the array to avoid lag in the game. 

 

I think I found it difficult to retrieve the attributes of different classes to use them in another class. I struggled to find a way in which I can use the y coordinate of the platform in the player class so that I can limit the movement of the player beyond the platform. Similarly, I wanted to access the coordinates of the bonuses for the player to collect them in a function. I figured out the solution by passing the entire object ‘platform’ or ‘bonus’ as an argument to the function in player. That way, I was able to access the different attributes of the other classes and use it to change the movement of the player. 

update(platform){
 
  //if the player in on the platform and not on the ladder space, then it stays on the platform
  if(this.y >= platform.y && this.y <= platform.y+platformsize && (this.x<platform.spacex || this.x > (platform.spacex+platform.spacewidth))){
    this.y = platform.y;
    
  }
  //if player on ladder space, it falls
  else if(this.x>platform.spacex && this.x < (platform.spacex+platform.spacewidth) && this.y >= platform.y && this.y <= platform.y+platformsize){
    this.rownum = 0;
    this.y+=1;
    this.col = (this.col+1)%4;
  }
  //initially it falls 
  else{
    this.y+=1;
    //this.col = (this.col+1)%4;

  }
}
//to check if the x and y coodinates of player and food is same to catch the food
bonuscatch(bonus){
  if(this.x>bonus.x && this.x < bonus.x+(bonus.size) && this.y>bonus.y && this.y <bonus.y+(bonus.size)){

    caught = true;
    success.play();
  }
}

 

A bug that constantly proved to be an ever present issue was the code placement in and outside the for loop to iterate over the arrays of platforms and bonuses. Due to the usage of a single for loop within the draw() function, it took me time to figure out how to manage iteration over the different arrays at the same time and call the different functions.  I think I found the use of sprite sheets and variable “gamestate” to change the user interface to be the most interesting to figure out.

Improvements

I think for future improvements, I would really like to implement some sort of obstacle in the game. I was able to implement the obstacles but could not edit their frequency because of the for loop and use of .splice() in the obstacle arrays. I would also like to add different levels to the game, add different elements to the levels to make them complex or easier. Creating different levels of the game through a random structure would also be an interesting aspect to develop.

Leave a Reply