Game dev question

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. :wink:

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.

Thanks very much for all this information guys.

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!

Regards,
Jaco

3 Likes

Here are plenty of examples made for the Python GameJam we had some time ago.

3 Likes

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 :wink: 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.

1 Like

Oh you spoiled youngsters! When I was a kid, we only had abacuses with half the beads missing!

2 Likes

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.

@FManga Couldn’t we reflash the data portion with the compiled uPy bytecode /

run compiled uPy bytecode from SD ?

:stuck_out_tongue::stuck_out_tongue::stuck_out_tongue::stuck_out_tongue::stuck_out_tongue::star_struck::star_struck::star_struck::star_struck:

Unfortunately, no. The bytecode needs to be compiled into the binary. :frowning_face:

Oh come on, Felipe. I know you can do it!! :brain::point_left::muscle::innocent:

Law of equivalent exchange. We’d probably have to sacrifice the framebuffer and a lot of speed.

1 Like

exactly what I was thinking!

1 Like

… in exchange for almost unlimited code size games :stuck_out_tongue:

Unlimited code size, but probably only fast enough for visual novels or something.
Sigh, there goes my compo entry… :stuck_out_tongue:

2 Likes

Please no. I’m only joking you know. @jvdw007 will be just fine with 70kB

Wow. Talkative :slight_smile:
I’m sure 70kb is enough for most ideas. I just need to curb my enthusiasm for wanting to create grander games is all :slight_smile:

All I was really trying to say is that it is a pity that sound and graphics data eats up code space.

That or learn a new programming language… I’ll just leave this here…

1 Like