I want to make a fruit ninja game on p5.js, then use gesture sensor with Arduino as the sword. Originally, I spent a lot of time brainstorming about sound and emotions, but I realized that'd take me a while to learn machine learning from scratch. It wasn't intuitive to use gesture sensor to control the sound and visual either because of the delays. So, I started thinking of user friendly ways that gesture sensor could put in a good use. Through researching, the fruit ninja game came to my mind. I used to play it a long time ago when the first version of the app came out. I remembered that my thumb would get tired by slicing the fruits all the time. Apparently, the game has a VR version now, which is really cool! Even though it's in VR, I still want to use gesture sensor to make the game in p5.js. I think it'd still be cool to be able to create it and make it more accessible since not everyone has VR set. Also, I have never made games before, so I thought this would be a good challenge.
I downloaded vector arts for fruits and bomb and sword from freepik.com. I write all the references on the p5.js sketch (see the code at https://editor.p5js.org/Jenny-yw/sketches/4AGWDsAhg). I also added sound effects to make the experience more fun. I got help from the coding lab because there were a lot of problems with the p5.play since I was using it for the first time. The project challenged my coding skill, and I'm happy with the results that came out.
There was one part where I took a long time to debug (see screenshoot below). All fruits on canvas keep disappearing at once when the sword overlaps with just one fruit. I knew it had something to do with fruitGroup, so I needed to pick each fruit and make each fruit disappear. However, I just didn't know how I could code it. Cezar from Coding Lab eventually helped me to debug that.
Challenges & Next Steps
It was hard to start using p5.play, which I haven't explored before. But, just like how I used every other p5.js libraries, I realized that the logic and basic functions are the same as long as I know the key syntaxes from the library. The main thing I used was array, which was challenging to not get confused because there are so many elements in the sketch. I also developed a huge appreciation for game developers. I have always thought simple games like fruit ninja is not hard to make, but there are so many details that go into the game in order to perfect the user experience. Making this game is an experiment and learning process for me. If I were to continue building onto it, I want to play around with how the fruit appears in the canvas and add different levels to the game.
Comments