Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Comparing pygame and pys60

I take the pygame code from here. Then, write my own pys60 part.
   1  
   2  # pygame's typical beginning
   3  import pygame
   4  from pygame.locals import *
   5  
   6  # pys60
   7  import e32, graphics
   8  from appuifw import *

Setting up the screen
   1  
   2  # pygame
   3  window = pygame.display.set_mode((468, 60)) 
   4  
   5  # pys60
   6  app.screen = 'full'   # or 'normal', 'large'

Get screen or canvas
   1  
   2  # pygame
   3  screen = pygame.display.get_surface() 
   4  
   5  # pys60
   6  app.body = canvas = Canvas(None, key.handle_event) 
   7  # you need to create key (a Keyboard instance) before this

Loading image
   1  
   2  # pygame
   3  monkey_image = pygame.image.load(file_name)
   4  
   5  # pys60
   6  monkey_image = graphics.Image.open(file_name)

Drawing image onto the screen
   1  
   2  # pygame
   3  screen.blit(monkey_image, (0,0))
   4  pygame.display.flip()  
   5  
   6  # pys60
   7  canvas.blit(monkey_image, target=(0,0))
   8  # we may add a buffer, which will need buffer.blit(image)
   9  # and canvas.blit(buffer) for equivalent steps

Loading and playing sound
   1  
   2  # pygame
   3  sound = pygame.mixer.Sound(fullname)
   4  sound.play()
   5  
   6  # pys60
   7  import audio
   8  sound = audio.Sound.open(fullname)
   9  sound.play()


For Rect and Sprite, there is no pys60 equivalence yet.
I may write an equivalent class someday.
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS