HW
I feel like to do a little game this week. Because there will be a lot of variables running upon p5.js.
The very basic game on Google webpage inspired me. - A little dinosaur going forward and jumping across the trees by being controlled of "space" key on the keyboard.
![](https://cdn.myportfolio.com/24429b9db48383e7b7341c9fc19a98d4/4a610b5e-5752-4342-9982-a663a7768874_rw_3840.jpg?h=6183622b513cc0f5105b5c3e195b97c1)
drawing of basic visuals.
![](https://cdn.myportfolio.com/24429b9db48383e7b7341c9fc19a98d4/2051746d-9b3f-4e47-93ab-29669aa774b2_rw_3840.jpg?h=91867d6c8420fe058ea01f8fdc8aec9f)
BUT WHY IT'S NOT WORKING?
![](https://cdn.myportfolio.com/24429b9db48383e7b7341c9fc19a98d4/21e375cc-9ce7-4270-b711-2758a7fdc145_rw_3840.jpg?h=2dd6bf2483c21723631704144908f652)
![](https://cdn.myportfolio.com/24429b9db48383e7b7341c9fc19a98d4/41ab69c8-4f50-49a6-81db-c1320d2cbf0b_rw_1920.jpg?h=d48c9f59f9e11f4e28acbf0388e8b714)
I asked Ruian to help me with that.
Problem solved!! :D
I found out the problem that mousePressed function is not working is because of I didn't write it into the right position.
function mousePressed() {}
must outside of the function draw(){ }
witch means: function is paralleled!!!
![](https://cdn.myportfolio.com/24429b9db48383e7b7341c9fc19a98d4/7aca69c7-847e-4645-9969-b5615295ba4e_rw_1920.jpg?h=d9b3a66a64c8f9c8ba35ba9ff145d39e)
Then I tired to make it smoother and slower for jumping around ( mousePressed and mouseReleased )
![](https://cdn.myportfolio.com/24429b9db48383e7b7341c9fc19a98d4/0873c386-030f-4bda-8fe7-d77248bbc063_rw_1920.jpg?h=8c356ebfbed4c6f568b5006adc2bd8eb)
Week 3
continuing of week 2
I tested some algorithmic designs on p5.js.
Here are the results.
![](https://cdn.myportfolio.com/24429b9db48383e7b7341c9fc19a98d4/3592392e-3ec2-4ef6-83d8-68dbedbeb96b_rw_1920.png?h=24dab6fdb98142884a40e1a757116921)
![](https://cdn.myportfolio.com/24429b9db48383e7b7341c9fc19a98d4/dc70982d-1a8d-401c-92b2-7ee54483558f_rw_1920.png?h=f145743d1ae65c42186ba48912990fc4)
![](https://cdn.myportfolio.com/24429b9db48383e7b7341c9fc19a98d4/2021de0c-131d-43c1-95db-baf810e31306_rw_1200.png?h=82ca1883888e773fde3dcde5e63bacaa)
Then I tried to combine the "random" and beautiful background to my cute and simple game!
I made the background go changing over time, and wanted it will be like when we running outside while the views are going back.
I separated the code into to 3 parts.
1. draw the whole game graphics.
2. make it loop + add the mouse function
3. change the background into an algorithmic design.