Online Python Editor for Pokitto!

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

I went for a try too.
It’s fun even if I’m not used to python. The IDE with sprite editing and sim allow to stay focus on idea. The constraints make it fun. Low res, low color, no debug (and I hate no debug).
I’m not an artist, colors are a punch in the eye right now so maybe I’ll go for Black&White only version.
Never try on Pokitto so I’m not sure about speed and playability, please tune/hack as you at wish

Really a great job @Hanski and @FManga

rex

rexitto.zip (25.9 KB)

rexitto.bin (140.8 KB)

5 Likes

1

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.

Update: Life bars change color. Lose/Win tracking. Updated license (MIT).
Update 2: Better scenery. Scene change after fight.
Binary: build(48).bin (175.3 KB)
Source: pokitto-mpy-project(20).zip (153.3 KB)
Art: Superpowers Asset Pack - CC0
Palette: Eroge Copper

7 Likes

In fairness that’s probably the best CC0 art I’ve seen so far.

Blimey, are we allowed to use the word ‘eroge’ on the forum? :P

It’s a good name for a palette with that much skintone… :stuck_out_tongue:

1 Like

TIP: How to print (in the emulator) the amount of free ram left for a Python program ?

Note: Do not call gc methods on every frame,as it slows down the execution. Do it just before the main loop etc.

import gc

print("Hello world!")

# Collect all freed memory. 
gc.collect()

# Print free memory amount
print ("free:",gc.mem_free())
1 Like

The garbage collector doesn’t trigger on its own?

It does when needed but, before getting the free RAM amount, it is better to make sure about it to get the correct result.

Edit: FYI, here is the link to the GC methods in Micro Python: http://docs.micropython.org/en/v1.9.3/pyboard/library/gc.html

1 Like

Is it just me or it feels weird that the player is on the right side? At first I was sure that the game wasn’t working correctly, and then I saw I was on the other side.

1 Like

You’re right… I was lazy about flipping the sprites. :rofl:

@Hanski: it would be really good if surface.blit could flip/mirror sprites. :thinking:

1 Like

Oh wow, this is amazing! Thanks @Hanski and @FManga! This will let a noob like me write something for pokitto finally!

I am kinda sad I won’t have time to take part in the competition, but I will keep an eye on the Python Editor and try making something with it in the near future!

One thing I think would help popularize pokitto even more, is having ability to export an html5 version of the emulated game, so we can share games on stuff like itch.io - and through those games people can find their way to pokitto :slight_smile: (We can add some pokitto splash screen before the game loads, similar to what PICO-8 does when exporting to html5).

5 Likes

I am going to try to promo this now (I have been away travelling and busy at work)

Does anybody have any creative feedback before I put this on twitter?

  • is 30th March enough time to code?

compo

7 Likes

Looks good to me.