Online Python Editor for Pokitto!

Hi,

I am happy to announce an online Python Editor for Pokitto, made by @fmanga ! It is a free tool which enables you to write and test Micro Python programs online, and finally create the binary for Pokitto. No installation or login needed :slight_smile:

The editor has some unique and advanced features, like:

  • An inline pixel editor that enables you to draw bitmaps inside the text editor!
  • An integrated Pokitto emulator to immediately see your program in action
  • An integrated builder to make a binary packet for flashing to Pokitto.
  • Ready-made example projects to immediately run in the emulator and Pokitto

This really is the easiest way to develop simple games for Pokitto!

Click on the link below to try the editor:
https://pyinsky.herokuapp.com/

Look at the video for a quick overview of the features of the editor:

Below are some links to help you with the Python development on Pokitto:

13 Likes

Python Coding Competition! (competition ended)

compo

First of all, a very big thank you to @Hanski and @FManga for their hard work on the incredible Python IDE and the tutorials and wikis. These will make Python coding on Pokitto much easier!

To celebrate this, the Batcomputer has decided to host a small competition to encourage people to try out Python coding on Pokitto and give to feedback and ideas about the tools.

RULES

( NOTE, “by 30th” means you can send your entry ON 30th. Sorry for saying it unclearly.

It is NOT so serious. On sunday the 31st I intend to start feeding the entries into the Batcomputer. I need time to conver the Python into punchcards.)

  • make a Pokitto game / app using our Python editor pyinsky.herokuapp.com

  • and submit it in this thread by (and including)! 30.3.2019 or by sending to python@pokitto.com

  • entry must include
    – .py source code
    – game binary saved from our python editor
    – license information for graphics or other resources that you have not made yourself

  • if you need help in getting up and running with the tools, come here to this thread to ask for help

  • the game must be “complete” in the sense that it can be loaded on Pokitto, played and enjoyed

  • game code has to be open-source so other can benefit from your wisdom!

  • game can not use images / other copyrighted material that the author does not own

  • author gives permission for game to be put on next gamedisk compilation

  • winners shall be chosen by the almighty Batcomputer and @Hanski the boy wonder. We citizens of Gotham can trust them to be fair judges

  • this competition will also be announced on Twitter

  • I reserve the right to amend rules if the situation requires it! Nobody will be cheated but if something happens, I will simply deal with it.

  • warning: rude, offensive or impolite stuff will get deleted

PRIZES

Fully kitted Pokitto + Pokitto logo T-shirt for THREE best entries:

  • best beginner
  • best mid range
  • best advanced coder
    Everyone has a chance! The jury won’t just give prizes to old experienced coders. We will look at the submissions and we can see the effort of the individual submissions.

… and ofcourse the admiration of Pokitto community to prize winners and participants!

COMPETITION ENTRIES

COMPETITION IS OVER! Here are all 18 entries in one zip-packet (thanks @spinal). Unzip the bin files to your SD card or flash each file separately:Spring 2019 Contest.zip (2.0 MB)


Here are competition entries (in release order).


Entry: Mandelbrot set
Author: @drummyfish
Sources:

Here
# Drummyfish, CC0

import upygame as upg
import framebuf

upg.display.init()
screen_sf = upg.display.set_mode()

RESOLUTION = (40,25)
ITERATIONS = 100
PIXEL_SIZE = 3

SUBDIV = 1000

COLORS = 5

center = [-500,0]
view_width = 2500

step = view_width // RESOLUTION[0]

top_left = (center[0] - RESOLUTION[0] // 2 * step, center[1] - RESOLUTION[1] // 2 * step)

def mandelbrot(point):
  z = [0,0]   # complex number to iterate

  color = 0

  try: 
    for n in range(ITERATIONS):
      # Mandelbrot formula: f_c(z) = z^2 + c
      z = ((z[0] * z[0] - (z[1] * z[1])) // SUBDIV + point[0],
           (2 * z[0] * z[1]) // SUBDIV             + point[1])

      abs1 = z[0] if z[0] >= 0 else -1 * z[0]
      abs2 = z[1] if z[1] >= 0 else -1 * z[1]

      length = abs1 if abs1 >= abs2 else abs2

      if length > 1000000000 or length != length:
        return 1
  except Exception:
    return 1

  return 0

point = [top_left[0], top_left[1]]

fractal = []

for y in range(RESOLUTION[1]):
  for x in range(RESOLUTION[0]):
    fractal.append(mandelbrot(point))

    point[0] += step

  point[0] = top_left[0]
  point[1] += step

while True:
  eventtype = upg.event.poll()

  i = 0
  
  for y in range(RESOLUTION[1]):
    for x in range(RESOLUTION[0]):
      screen_sf.fill(fractal[i],upg.Rect(x * PIXEL_SIZE,y * PIXEL_SIZE,PIXEL_SIZE,PIXEL_SIZE))
      i += 1
  
  upg.display.flip()

Binary:
Screenshot or video:

image


Entry: Bounce!
Author: @wuuff
Sources:

Here
# Welcome to Python on Pokitto!
import upygame as pygame

import umachine as pok

pygame.display.init()
screen = pygame.display.set_mode() # full screen
screenRect = screen.get_rect()
screenW = screenRect.width
screenH = screenRect.height

ballPixels = b'\
\x01\x70\
\x17\xcf\
\x7c\xcf\
\x0f\xf0\
'

ball2Pixels = b'\
\x01\x60\
\x16\xae\
\x6a\xae\
\x0e\xe0\
'

ballSurface = pygame.surface.Surface(4,4,ballPixels)
ball2Surface = pygame.surface.Surface(4,4,ball2Pixels)

#pok.draw_text(0,10,"hello", 1)
pygame.display.flip()

balls = [{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},\
         {'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5}]
    
currBall = 0
ballTimer = 0
bounce = 'bounce!'
    
while True:
    ballTimer += 2
    if ballTimer == 10 and currBall < len(balls):
        ballTimer = 0
        currBall += 1
    #pok.draw_text(myX,10,"hello", 1)
    #screen.blit( ballSurface, myX, myY, 0 )
    for b in range(0,currBall):
        ball = balls[b]
        if b < 7:
            pok.draw_text(ball['x'],ball['y']-10,bounce[6-b], 1)
        ball['x'] += 2
        if ball['x'] > 110:
            ball['x'] = 0
        if ball['y'] < 44:
            ball['vy'] += 1
        else:
            ball['vy'] -= 1
        ball['y'] += ball['vy']
        screen.blit( ballSurface, ball['x'], ball['y'], 0 )
        screen.blit( ball2Surface, ball['y'], ball['x'], 0 )
    pygame.display.flip()

Binary:
Screenshot or video:
image


Entry: Rexitto
Author: @HomineLudens
Source: Rexitto.zip (26.3 KB)
Binary: rexitto.bin (152.6 KB)

Screenshot or video:
rex


Entry: You shall not pass
Author: @FManga
Source: pokitto-mpy-project(20).zip (153.3 KB)
Binary: build(48).bin (175.3 KB)

Instructions or other info

How to play:

You’re a knight on an important quest… but a pesky lizard is in your way.
Left : Sword attack. Effective against attempts to heal.
Up : Heal yourself. Makes you vulnerable to sword attacks.
Right : Block. Reflects sword damage back to opponent.

Screenshot or video:
1


Entry: Dr Mriller
Author: @fmanga
Source: pokitto-mpy-project(49).zip (81.4 KB)
Binary: build(79).bin (155.8 KB)
Screenshot or video:
1


Entry: Noggin
Author: @spinal
Source: NogginSource.zip (151.0 KB)
Binary:Noggin.bin (188.8 KB)

Instructions and other info

Each tile gives you a number, make that many moves without crossing your path then hit A.
Wildcards are as follows,
Jack - swap a tile from the spares pile.
Queen - choose any tile horizontally or vertically, but all tiles in that line will flip.
King - Same as Queen, but only your selected tile will flip.
! - Move one tile, but reserve the ability to move anywhere by pressing B when on your starting tile.

A - Turn a tile
B - return to start tile
C - start fresh game
01 02

Screenshot or video:
03 04


Entry: KameraKatze
Author: @ServalKatze
Source: KameraKatze_sfx.zip (116.8 KB)
Binary: kamerakatze (4).bin (173.9 KB)

Instructions and other info

You are a kitty. :cat2:

Take pictures of the sleeping lion to score points. Note how the environment changes as your score increases. Don’t get noticed by the scary lion. :lion:

start ingame


Entry: Pyrates
Author: @jonne
Source:pyrates.zip (237.5 KB)
Binary: pyrates.bin (210.3 KB)

Instructions and other info

Pyrates !!

ARRR, me mateys!

1. Objective of the game

For a pirate,

a fate far worse than the treacherous rocks ripping the ship to shreds, far worse than the raging seas, the howling winds, or the mystical sea-monster Kraken

… is running out of Grog

Sailing the dangerous waters of the Spanish Main, you as a captain have to take care of your ship and crew. Your goal is to sail to different islands, land on the ports and make sure your ship stays brimmed with Grog.

2. Buttons

  • Left, Right steer ship to Port (anticlockwise) or Starboard (clockwise)
  • C restart game
  • A (while sailing) fire cannon (needs time to reload)
  • A (while docked at port) boost yourself out of a harbour
  • Left, Right (while ‘Landed’) jiggle ship to traverse through land

3. Basics of Sailing

  • Watch the wind direction
  • You can’t go against the wind
  • Sideways to wind is often faster than directly downwind
  • ‘Tacking’ i.e. going slightly against the wind allows you to climb upwind - if wind is strong enough

sailing_guide

4. Gameplay hints

  • if you get lost at sea, just press ‘C’ to restart the challenge
  • PRESS A several times in the beginning to start
  • if you are Landed you can jiggle your boat to get loose
  • if you wish to exit a port, turn your ship and press A to give it a push
  • the ship’s mast watch will call “Land Ahoy” when he sights land. You can then try to sail in that direction. It is easy to miss the islands!
  • not all islands are safe to land - the port may be in an impossible place. Sail away to another island

Now go learn the ropes, ya miserable landlubber!!

1

Interesting factoid: What is Grog?

giphy

license info

all gfx, code by me
sfx by me
“Bonnie Lass” trad. Irish song, Public Domain midi played through a FM synthesis soundfont

pyrates_final


Entry: **Tor’s Game Gallery **
Author: @torbuntu
Source:TorsGameGallery.zip (97.8 KB)
Binary:tgg.bin (173.3 KB)
Binary:

Instructions and other info

Mecha Narwhal
Explore the ocean depths as the Mecha Narwhal! Dodge shark poky coral, avoid or dash through dangerous jellyfish, and keep an eye out for those pesky sharks!
The farther you explore, the faster you’ll go! Keep your eyes open.

Angry space toast
Just a simple avoidance game where you’re objective is to not get clobbered by the angry space toast. You have a shield, but it can only take so much buttery angst. Once that is depleted you have minimal health remaining before you’re toast.
A is the button to start the round. Movement is with D-pad but thrust is either UP or A. No other controls yet.

mechaNarwhal ast


Entry: Big Blue
Author: @andrewb
Source: BigBlue.zip (32.2 KB)
Binary: file.bin (156.5 KB)

Instructions and other info

Your goal in it is to guide the astronaut home, avoiding aliens, comets and rockets across 5 different levels of increasing difficulty.

gameplay


Entry: U.F.O.
Author: @sbmrgd
Source:ufo.zip (60.5 KB)
Binary:ufo.bin (159.8 KB)

Instructions and other info

You have to defend your planet against aliens by shooting ufos. There are three types of ufos: a big one , a medium one and a small one. In the left upper corner there is some kind of a compass that gives an idea where the current ufo is situated. You have 2 minutes to shoot as many ufos as possible:
Controls:
d-pad controls your ship
a-button fires the lasers
b-button goes to game over screen
c-button: starts game

ufo


Entry: ScummPy Quest I: The Jammed Door
Author: @jpfli
Source: scummpy.zip (76.3 KB)
Binary: scummpy.bin (178.3 KB)

Instructions and other info

Point-and-click puzzle.

scummpy


Entry: 1q48
Author: @chame
Source:
1q48_v0_2.zip (9.9 KB)
Binary:1q48_v0_2.bin (161.8 KB)
1q48_v0_2


Entry: Boblo
Author: @HomineLudens
Source: boblo.zip (84.4 KB)
Binary: boblo.bin (174.3 KB)

Instructions and other info

Boblo is a strange creature, it’s made of air and water but it’s not affected by gravity.
It bubbles trough the space and can’t stop until it crash against a wall.

Help Boblo to collect as much coins as you can in this little puzzle game.
It’s a dangerous world filled with secret passages and switches.
There’s always more then a way to reach the exit.

Enjoy!

More Boblo levels can easily added in “levelData.py”:
Here an example and syntax for each tile. I’d like to add more level in future.

lvl00 = (\
'.x.x.',\
'x..zx',\
'...x.',\
'x..ax',\
'.x.x.',\
)

Here a list of possibles tiles:

x = blue box
w = wall, state ON (solid)
W = wall, state OFF (invisible, not solid)
+ = blades state ON (they hurts!)
= = blades state OFF (not solid)
! = vertical moving blades
B = toogle button, state ON (activate/deactivate tiles)
b = toogle button, state OFF
K = Key, open final locked gate 
o = coin
| = red box, vertical moving
- = red box, horizontal moving
< = left pushing tile
> = right pushing tile
^ = up pushing tile
v = down pushing tile
z = final tile state OPEN
Z = final tile state CLOSED (solid)
a = start tile

boblo


Entry: Jetpack
Author: @bl_ackrain
Source:jetpack_v1(1).zip (57.4 KB)
Binary: jetpack_v1_1.bin (165.6 KB)

Jetpack


Entry: The Villainy of Cat Food Inc
Author: @ServalKatze
Source:VoCFI.zip (25.8 KB)
Binary:vocfi.bin (154.2 KB)

Instructions and other info

The Story
Cat Food Inc. - the major supplier of cat food in town - has catnapped Nanji, Guy’s cat, and wants to use her to promote their latest brands of cat foods.

Help Guy to rescue Nanji from the evil clutches of Cat Food Inc.

How to play
This is a little puzzle game. The goal is to reach the exit.

Push crates out of the way.
Pick up keys and use them to open normal doors.
Push the pushbutton to open the pushbutton door.

2


Entry: Legend of Lanea
Author: @dir3kt
Source: https://github.com/jlauener/Legend-of-Lanea
Binary: lanea.bin (190.9 KB)

Instructions and other info

Legend of Lanea is a Zeldaesque adventure for the Pokitto.

Controls

  • Directional stick: move
  • A: interact/attack
  • C: start game, pause

banner


Entry: Top Fish
Author: @wuuff
Source:topfish.zip (11.5 KB)
Binary: topfish.bin (148.0 KB)

Instructions and other info

There are a lot of fish in this pond, and you’re the tiniest. Avoid the bigger fish and eat smaller or same-sized fish to get bigger, so you can become the Top Fish!

1


12 Likes

Amazing, looks like a huge leap in accessibility for the beginners. Going to test!

And a coding competition ahead! It’s a good day today :slight_smile:

5 Likes

Just go for it :slight_smile: The prizes are very, very nice also!
Just ask here if you have any questions or comments about the editor, uPyGame, Micro Python, etc.

1 Like

TIP: The speed of the Python program on Pokitto HW is actually significantly faster than in the integrated emulator.

1 Like

Question… is Pokitto Python for 110x88 only? of is 220x176 possible?

For simplicity, the online editor supports only 110x88 with 16 colors. It is also for memory usage reasons, as there is not too much free RAM left for Python programs.

Does float work? It doesn’t want to compile with float numbers and float(2) gives me unknown name.

Floats are not supported.
Here you can get hints what MP features are supported, and which aren’t: https://github.com/haviital/micropython/blob/master/ports/pokitto/mpconfigport.h

2 Likes

Floats are not supported.

Okay, switched to integers. Here is Mandelbrot set :slight_smile:

image

Summary
# Drummyfish, CC0

import upygame as upg
import framebuf

upg.display.init()
screen_sf = upg.display.set_mode()

RESOLUTION = (40,25)
ITERATIONS = 100
PIXEL_SIZE = 3

SUBDIV = 1000

COLORS = 5

center = [-500,0]
view_width = 2500

step = view_width // RESOLUTION[0]

top_left = (center[0] - RESOLUTION[0] // 2 * step, center[1] - RESOLUTION[1] // 2 * step)

def mandelbrot(point):
  z = [0,0]   # complex number to iterate

  color = 0

  try: 
    for n in range(ITERATIONS):
      # Mandelbrot formula: f_c(z) = z^2 + c
      z = ((z[0] * z[0] - (z[1] * z[1])) // SUBDIV + point[0],
           (2 * z[0] * z[1]) // SUBDIV             + point[1])

      abs1 = z[0] if z[0] >= 0 else -1 * z[0]
      abs2 = z[1] if z[1] >= 0 else -1 * z[1]

      length = abs1 if abs1 >= abs2 else abs2

      if length > 1000000000 or length != length:
        return 1
  except Exception:
    return 1

  return 0

point = [top_left[0], top_left[1]]

fractal = []

for y in range(RESOLUTION[1]):
  for x in range(RESOLUTION[0]):
    fractal.append(mandelbrot(point))

    point[0] += step

  point[0] = top_left[0]
  point[1] += step

while True:
  eventtype = upg.event.poll()

  i = 0
  
  for y in range(RESOLUTION[1]):
    for x in range(RESOLUTION[0]):
      screen_sf.fill(fractal[i],upg.Rect(x * PIXEL_SIZE,y * PIXEL_SIZE,PIXEL_SIZE,PIXEL_SIZE))
      i += 1
  
  upg.display.flip()
6 Likes

Ooh! First entry. It’s game on!!!

I’ve never even looked at python before, but I’m going to try something. Why not :slight_smile:

4 Likes

Is there a reason that my images don’t do that re-colour thing that the examples do?

yes, something I have forgot to mention. There has to be “pixels” in the variable name.

1 Like

cool, I don’t suppose image arrays are a thing? I want to use a 14 frame sprite sheet.

you have to use a separate surface for each frame

This looks really nice, and the image editing in the code reminds me of fantasy consoles like the Pico-8, where all the development tools are integrated together. This should make it a lot easier for people to start developing for the Pokitto. I definitely want to find some time to try this out.

2 Likes

I think it would make more sense to put that in a comment above rather than restricting the programmer’s word choice.
Unless that’s too much extra effort?

1 Like

Hi,
I made a FAQ about all questions related to Python in Pokitto: FAQ: Python in Pokitto

I will collect all the information in this discussion thread to there.

1 Like

I wanted to try something really quick with this and I hadn’t done any demoscene-style stuff before, so I put something simple together. I’m amazed how fast this runs on the Pokitto! It’s super smooth, even without trying to do any optimizations. Hoping to be able to do more later.

image

Code
# Welcome to Python on Pokitto!
import upygame as pygame

import umachine as pok

pygame.display.init()
screen = pygame.display.set_mode() # full screen
screenRect = screen.get_rect()
screenW = screenRect.width
screenH = screenRect.height

ballPixels = b'\
\x01\x70\
\x17\xcf\
\x7c\xcf\
\x0f\xf0\
'

ball2Pixels = b'\
\x01\x60\
\x16\xae\
\x6a\xae\
\x0e\xe0\
'

ballSurface = pygame.surface.Surface(4,4,ballPixels)
ball2Surface = pygame.surface.Surface(4,4,ball2Pixels)

#pok.draw_text(0,10,"hello", 1)
pygame.display.flip()

balls = [{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},\
         {'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5},{'x':0,'y':44,'vy':5}]
    
currBall = 0
ballTimer = 0
bounce = 'bounce!'
    
while True:
    ballTimer += 2
    if ballTimer == 10 and currBall < len(balls):
        ballTimer = 0
        currBall += 1
    #pok.draw_text(myX,10,"hello", 1)
    #screen.blit( ballSurface, myX, myY, 0 )
    for b in range(0,currBall):
        ball = balls[b]
        if b < 7:
            pok.draw_text(ball['x'],ball['y']-10,bounce[6-b], 1)
        ball['x'] += 2
        if ball['x'] > 110:
            ball['x'] = 0
        if ball['y'] < 44:
            ball['vy'] += 1
        else:
            ball['vy'] -= 1
        ball['y'] += ball['vy']
        screen.blit( ballSurface, ball['x'], ball['y'], 0 )
        screen.blit( ball2Surface, ball['y'], ball['x'], 0 )
    pygame.display.flip()
4 Likes