I recently bought a Pokitto and love it. There’s a fun game that I’d love to make for the Pokitto, but since I’m new to the Pokitto and Micro Python in general, I was wondering if you could help answer some questions I have.
I’m interested in using the Online MBED editor found at https://pyinsky.herokuapp.com/ as it makes it easy for me to code wherever I am, however I’m not sure of its limitations…
My questions are:
Do I need to learn Micro Python elsewhere first to know how to use it in this IDE as the IDE has zero documentation from what I can tell…
What/where can I find documentation on how to do things like change the screen mode (in particular) for the Pokitto using the IDE?
What’s the (sd) disc space and ram/memory space for games and how will I know if I run out?
I’m going to look around on Youtube and elsewhere to get more familiar with Micro Python in the meantime, but thought I’d ask these questions above anyway!
For a bit of background, I am an indie game dev on the side and have made several games before on other systems along with a good mate of mine, so I’m pretty familiar on how to build games. I just need guidance on the machine’s limitations really.
Online Python Editor is different from Online MBed environment. The latter is ment for C++ coding. Python Editor is by far the easiest way to make games for Pokitto, but if you know C++, that is much more versatile and powerful. .C++ is the “native” language of Pokitto.
In Python Editor you can select the high resolution screen mode (220x176) from the “Flags” tab in the bottom right window. The RAM size in Pokitto is 36 kb, but for Python games there is less than 20 kb free. You can check the.free memory in Python like this:
Thanks very much for that info, it’s great!
I plan to start with Micro Python as I’ve been meaning to learn Python for many years now, eventually moving up to C++ I hope.
Hanski, I presume the 20kb free limit is due to the Python runtime taking the rest of the space I imagine and is also the limitation on the real hardware?
I think the code for the game idea I have in mind should fit in 20kb, but not sure. I suspect after this first game, I will look into MBed as the next step. I presume it is this you’re talking about? https://www.mbed.com/en/
I will be patiently waiting for that moment.
(It’s very likely I’ll be one of the ones answering your questions when that time comes.)
As @Hanski said, you don’t need to use the Mbed online compiler for making Python games, it’s only for C++ code.
That said, personally I recommend against using Mbed online for C++ development because it only implements the old C++03 standard.
The other options (mainly Embitz, which is Windows only, and PlatformIO, which is multiplatform but a bit more difficult to set up) support C++11 (and later) standards.
C++11 was a big step forward for the language and many of the added features provide big benefits.
(Not to mention the fact there’s a very long list of them.)
Just something to consider for when you do cross that bridge.
That’s the site, but not quite where the compiler is.
I think you need to create an account before you can access the compiler.
Your code does not have to fit in 20kb. Unlike regular computers, code does not need to loaded into RAM to run, it’s executed directly from flash. Things like code, images and sound effects only take up flash space. RAM is only for storing variables.
As @torbuntu said, the help tab has links to lots of documentation. The IDE also has a bunch of examples that can help you get started.
As far as I understood, Micropython code is compiled to a “regular” binary, so there is no actual Python runtime on the little Pokitto.
However, the RAM is actually limited to 20kb, so you’ll need to do some clever coding if you want to make huge open world game.
Additionally, the binary file (the .bin file that Pynski offers for download after you press “play”) should not be larger than about 200kb - otherwise it may run in the online editor (and offline emulator) but it won’t fit into the Pokitto’s ROM.
Right, but the program is actually interpreted as Python bytecode which is frozen in ROM by Python Editor. It is possible also to use interactive REPL and give python commands or scripts from the terminal application.
The online editor seems to be a great starting point, and seeing assets don’t need to be loaded into RAM as such, I think my game should fit in the space available both in binary size and ram size.
Now it’s just getting more familiar with Micro Python.
I’m going on holiday for 2 weeks, so will use that time to get more familiar with the language.
I’m keen to get proper familiar with Python as I want to make games both for the Raspberry Pi and Clockwork Pi in addition to the Pokitto, so it’ll make life easier for the various platforms to have a very similar or same code-base so I don’t spend forever re-coding stuff too much.
Will start a new thread with my game once I have something up and running!
Sorry to be coming back to this guys, but after thinking about the file size, space size, variable size setup, it seems to me there’s actually VERY little space to make a game.
For example: When you build a binary of the online IDE Hello world example, it’s 147kb. That’s pretty much the smallest build you can get with nothign in it. You state the binary can’t be more than 200kb (my previous game was about 220kb or so and flashed fine), but what I’m trying to say is that means you really only have about 70kb of actual space to use which gets taken up by code, graphics, animations, audio etc.
Some people would say it is much There are MCU devices which have less free ROM. But relatively that is a little as the total is 256 kb. Much of it is taken by the Python interpreter. In Femto there is more possibilities to tweak speed vs. space optimisations.
It’s very little if you use a resource-hungry dynamically typed language like Python.
The runtime flexibility of Python comes at a cost.
As @Hanski says, the interpreter gobbles up a large chunk of ROM,
and on top of that objects are dynamically allocated, which adds yet more overhead.
If you use C++ you don’t need an interpreter and you have a lot more control over resource usage,
so not only do you have more spare memory, but you can do more with less space.
Having SD card access increases the possibilities of both.
I think the SD card is probably the most underused component of the Pokitto at the moment.