Hi all guys!
I'm making a game in phyton and have done all the hard part of the game. For test i've used canvas.rectangle instead of real image. Now i'm switching these rectangles to images with canvas.blit(image,target=(x,y),mask=testmask).
I have to draw 5 5x5 pixel image and 1 10x10 image. This is into a while loop with a sleep timer at the end. I've inserted the drawing code just after the canvas.clear(), but when i'm running the game it seems that the draw function is too slow and the screen is cleared before it finish to draw my images. i post some part of code:
automask code for images (called once at the beggining of program just after the image loading)
drawing code (executed every cycle)
width, height = im.size
mask = Image.new(im.size, '1') # black and white
tran = im.getpixel((0,0)) # transparent top-left
for y in range(height):
line = im.getpixel([(x, y) for x in range(width)])
for x in range(width):
if line[x] == tran:
mask.point((x,y), 0) # mask on the point
Am i doing something wrong? is there a way for speed up things? timer is already at the lowest sleep possibile and if i delete it i only obtain a faster game but with the same problem.
canvas.rectangle((ostacolox, ostacolo, (ostacolox + 10), (ostacolo + 30)), fill=color)
canvas.rectangle((ostacolo2x, ostacolo2, (ostacolo2x + 10), (ostacolo2 + 30)), fill=color)
canvas.text((290,18), spunti ,fill=0xffff00)
canvas.text((2,18), "Livello " + slivello, fill=0xffff00)
If you want you can watch my game working with canvas.rectagle here -> http://www.youtube.com/watch?v=OTqyHoNIlOw
Sorry for my bad english! I hope in some reply!!