# OOP – Aigerim

Inspiration

For this assignment, I recreated my own version of the Rock, Paper, Scissors game I saw on TikTok. Having spent a little too much time watching it, I wanted to create my own version of it that is scalable and in which the simulation can be played over and over again.

The Product

Overall, I am very happy with the outcome. The code design underwent many changes as I added new features and removed the useless ones, for example, I started off with 3 different classes for Rock, Paper, and Scissors but realized that the code was a bit redundant and reduced it to one Obj class.

Challenges

```//function to check for collision of two objects (thisO and all the other objects)
function checkCollision(thisO) {
for (let i = 0; i < obj.length; i++) {
//check the distance between the two objects
let d = dist(thisO.x, thisO.y, obj[i].x, obj[i].y);
//if the two objects are within close proximity and are not the same apply the rock paper scissor rules
if (d <= thisO.size / 2 + obj[i].size / 2) {
//thisO.dx = -thisO.dx;
//thisO.dy = -thisO.dy;
//obj[i].dx = -obj[i].dx;
//obj[i].dy = -obj[i].dy
if (obj[i].id == "📄" && thisO.id == "🗿") {
thisO.id = "📄";
} else if (obj[i].id == "✂️" && thisO.id == "📄") {
thisO.id = "✂️";
} else if (obj[i].id == "🗿" && thisO.id == "✂️") {
thisO.id = "🗿";
}
}
}
}```

One of the biggest challenges was figuring out how to detect the collision between my objects, for which I ended up calculating the distance between all the objects at a given time and checking if that distance is less than the radius of my object. Another challenge is to make the collisions smooth without having two objects cross each other, which I am yet to work out. Apart from that, it was a really fun project to work on, and very entertaining to see which one will win every time I run it!