pygame is
pygame.org is
|
Wiki
CookBookPosting A Recipe: - Please start a new page for each recipe. - Use the <pre><code>YOUR CODE</code></pre> tags to put in code.(View source of some other pages to see how it is done.) - Except where otherwise noted, recipes posted in the pygame cookbook are in public domain. - Tabs are lost when posting, so convert tabs to spaces first if you use them. another list of cookbook code examples.# Render Text Example: 'I love pygame!' pygame.init() screen = pygame.display.set_mode([300,100]) screen.fill([255,255,255]) mainloop, x, y, color, fontsize, delta, fps = True, 25 , 0, (32,32,32), 35, 1, 30 Clock = pygame.time.Clock(). while mainloop: tickFPS = Clock.tick(fps) pygame.display.set_caption("Press Esc to quit. FPS: %.2f" % (Clock.get_fps())) fontsize = random.randint(35, 150) myFont = pygame.font.SysFont("None", fontsize) color = (random.randint(0,255), random.randint(0,255), random.randint(0,255)) screen.fill((255,255,255)) screen.blit(myFont.render("I love pygame!", 0, (color)), (x,y)) for event in pygame.event.get(): if event.type == pygame.QUIT: mainloop = False # Be IDLE friendly! elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: mainloop = False # Be IDLE friendly! pygame.display.update() pygame.quit() # Be IDLE friendly! [edit] |
|