Working on PokiSnake, a Pokitto port of my Arduboy “ArduSnake” snake game. Here is the source for the simulator. There is no sound, there is still work to do on gameplay and graphics, there is a bug with the snake speed at the 6th food but it is fully playable.
I hope that it will be useful for someone.
Viewing my game on the real Pokitto is like a dream that becomes reality !
As I said on Twitter, thank you so much for having tested it !
I can’t wait to have the real Pokitto in my hands
@Initgraph something I noticed: you do not need to pass the Pokitto::Core class to your objects. Pokitto::Core and all ::button ::display etc. classes only contain static members.
This means that Pokitto::Core is essentially a singleton (or a static class, although it does not exist as such in C++). There is only one instance of the Core class in the memory, no matter how many times you initialize it.
If I do this:
Pokitto::Core a;
Pokitto::Core b;
void foo() {
Pokitto::Core c;
}
Then
a, b, and c are the EXACTLY SAME structure in the memory. If you call members of a,b,c they will point to the same data locations in memory.
I chose this structure over a singleton, because I found the syntax easier to handle. It is (gasp!) like having a giant global variable, but in a C++ class form.
@Initgraph Another example of application of static member only class: you have food as a member of the snake class. Now, let’s say (ahem) maybe I would like to have several snakes on the screen at once. What to do? Each snake instance has member food in it, how do I make sure there is only 1 food on the screen at a given time? Do I have to take food out from inside the snake class?
No I don’t. I simply make food static. In this way, each snake is calling the one single allowed instance of food in the program memory. Problem solved, no other changes in program required.
Oh I can’t believe it, you did a multiplayer arcade game with my game on Pokitto !
It’s really awesome, we can do a small arcade device with the Pokitto !
Thank you very much for the dev tricks, I appreciate when someone can improve my code because I like to learn new things, you’re awesome ! Can’t wait to see more code on Pokitto