Sunday, August 1, 2021

Virtual Pet (Part 4)

 


Step I: Create variables play, eat, bath and sleep for each buttons.


Step II: In setup() function, create buttons and position them.


Step III: Create different functions for different buttons which will change the gameState in database. You can use updateState() function inside that functions which you have created on previous part.


Step IV: In setup() function, create mousePressed property for all that created buttons and call the functions which you created inside mousePressed() function.


Step V: In draw() function, come to if condition where you wrote that if gameState is not equal to hungry thne you were hiding the add food and feed food button. There you have to add one more line to show eat button and in else part, you hide the eat button.


Step VI: Now come to the if condition where you are updating gameState according to feed time and there change the if condition to gameState === '........' and inside that if condition, remove updateState() function.



Video:~





Previous Post
Next Post

post written by:

0 Comments: