Skip to content

Instantly share code, notes, and snippets.

@stelonix
Created November 19, 2012 00:16
Show Gist options
  • Save stelonix/4108307 to your computer and use it in GitHub Desktop.
Save stelonix/4108307 to your computer and use it in GitHub Desktop.
Simple pygame tests
#!/usr/bin/env python
# log-default-2012-11-17.py
# IPython automatic logging file
# 17:33:23
# =================================
# =================================
# 17:35:06
# =================================
# =================================
# 17:36:39
# =================================
# =================================
# 17:38:10
# =================================
dir(__main__)
# =================================
# 17:40:43
# =================================
# =================================
# 17:40:59
# =================================
# =================================
# 17:41:53
# =================================
# =================================
# 17:42:06
# =================================
# =================================
# 17:42:24
# =================================
dir(__main__)
while True:
make_transmission_shift()
# =================================
# 17:43:19
# =================================
# =================================
# 18:46:14
# =================================
import pygame
pygame.init()
#[Out]# (6, 0)
dir(pygame.display)
#[Out]# ['Info',
#[Out]# '_PYGAME_C_API',
#[Out]# '__PYGAMEinit__',
#[Out]# '__doc__',
#[Out]# '__file__',
#[Out]# '__name__',
#[Out]# '__package__',
#[Out]# 'flip',
#[Out]# 'get_active',
#[Out]# 'get_caption',
#[Out]# 'get_driver',
#[Out]# 'get_init',
#[Out]# 'get_surface',
#[Out]# 'get_wm_info',
#[Out]# 'gl_get_attribute',
#[Out]# 'gl_set_attribute',
#[Out]# 'iconify',
#[Out]# 'init',
#[Out]# 'list_modes',
#[Out]# 'mode_ok',
#[Out]# 'quit',
#[Out]# 'set_caption',
#[Out]# 'set_gamma',
#[Out]# 'set_gamma_ramp',
#[Out]# 'set_icon',
#[Out]# 'set_mode',
#[Out]# 'set_palette',
#[Out]# 'toggle_fullscreen',
#[Out]# 'update']
pygame.display.set_mode(640,480)
pygame.display.set_mode((640,480))
#[Out]# <Surface(640x480x32 SW)>
pygame.display.set_mode(())
pygame.display.set_mode((640,480))
#[Out]# <Surface(640x480x32 SW)>
surf = pygame.display.set_mode((640,480))
screen.fill((255,255,0))
surf.fill((255,255,0))
#[Out]# <rect(0, 0, 640, 480)>
surf.update()
pygame.display.flip()
squares = []
pygame.draw.rect(surf,(255,0,0),(0,0,0,0))
#[Out]# <rect(0, 0, 1, 1)>
pygame.display.flip()
pygame.display.update()
pygame.display.flip()
pygame.draw.rect(surf,(255,0,0),(0,0,0,0))
#[Out]# <rect(0, 0, 1, 1)>
pygame.display.update()
pygame.display.flip()
pygame.draw.rect(surf,(255,0,0),(0,0,420,240))
#[Out]# <rect(0, 0, 420, 240)>
pygame.display.flip()
pygame.display.flip()
pygame.draw.rect(surf,(255,0,0),(0,0,20,20))
#[Out]# <rect(0, 0, 20, 20)>
pygame.display.flip()
pygame.display.update()
pygame.display.flip()
surf.fill()
surf.fill((0,0,0)
)
#[Out]# <rect(0, 0, 640, 480)>
pygame.display.flip()
def do_fill(surface,numrects):
for i in xrange(numrects):
pygame.draw.rect(surface,rand_color(),rand_pos())
import random
def rand_color():
def gc():
return random.randrange(0,256)
return (gc(),gc(),gc())
def do_draw(surface,num_rects):
for i in xrange(num_rects):
pygame.draw.rect(surface,rand_color(),(random.randrange(0,640),random.randrange(0,480),20,20))
while True:
do_draw()
pygame.display.flip()
while True:
do_draw(surf,200)
pygame.display.flip()
while True:
do_draw(surf,200)
pygame.display.flip()
import time
time.sleep(1)
time.sleep(0.1)
time.sleep(0.1)
while True:
do_draw(surf,200)
pygame.display.flip()
while True:
do_draw(surf,200)
pygame.display.flip()
while True:
do_draw(surf,10)
pygame.display.flip()
while True:
do_draw(surf,1)
pygame.display.flip()
while True:
do_draw(surf,1)
pygame.display.flip()
time.sleep(0.067)
while True:
do_draw(surf,1)
pygame.display.flip()
time.sleep(0.067)
while True:
do_draw(surf,1)
pygame.display.flip()
time.sleep(0.067)
def do1():
while True:
do_draw(surf,200)
pygame.display.flip()
time.sleep(0.067)
do1()
def do1():
while True:
do_draw(surf,200)
pygame.display.flip()
time.sleep(0.01)
do1()
def do2():
while True:
surf.fill((0,0,0))
do_draw(surf,20)
pygame.display.flip()
time.sleep(0.01)
do2()
def do2():
while True:
surf.fill((0,0,0))
do_draw(surf,20)
pygame.display.flip()
time.sleep(0.01)
do2()
do1()
surf = pygame.display.set_mode((800x800))
surf1 = pygame.display.set_mode((800,800))
do1()
surf = pygame.display.set_mode((640,480))
do1()
do2()
do2()
do1()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment