Hello guys ,
I want to make few games and play them on the Arduino mega with TFT screen and I don’t want to go to my computer when I want to play another game.
Hello guys ,
I want to make few games and play them on the Arduino mega with TFT screen and I don’t want to go to my computer when I want to play another game.
Ok.
And your question is?
You can only upload one sketch at a time but, if there is enough memory available the sketch could execute code to provide more than one game
duplicate thread
https://forum.arduino.cc/t/can-i-have-more-memory-for-sketsches/1146541/3
Edit - what games are you running now?
There is no operating system so you can only load one program but you can have a program with different sections.
You can use an if-statement or switch - case (1) in your main loop to decide what code (which game) you want to run. When the game is over, or when you quit, you can go back to your main loop and choose again.
...I made some lighting effects where the main loop is mostly just a switch - case and a random number determines which lighting effect runs. Each effect has it's own loop which runs for a certain amount of time and then it goes back to the main loop and another random choice is made.
(1) This is called "conditional execution". It's how computers "make decisions".
Conditional execution and loops (doing something over-and-over, usually until some condition is reached or until some condition changes) are the two concepts that make programming useful.
Last month this forum had a request for assistance to "combine two games" which were Pong and Snake. I was able to make the combining happen by "wrapping" each game in its own setup() and loop() function then calling the games main loop() So... yes, you can combine games. For your reference, here is the result of Pong and Snake (I called snekping):
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.