Ejemplo n.º 1
0
def main():
    pygame.init()
    screen = pygame.display.set_mode((600,600)) 
    clock = pygame.time.Clock()
    font = pygame.font.SysFont("Arial", 16)
    
    space = pymunk.Space()
    
    add_objects(space)
            
    ### Draw it 
    screen.fill(pygame.color.THECOLORS["black"])
    
    pymunk.pygame_util.draw(screen, space)
                    
    # Info
    screen.blit(font.render("Demo example of shapes drawn by pygame_util.draw()", 1, pygame.color.THECOLORS["darkgray"]), (5, 580))
    screen.blit(font.render("Static shapes", 1, pygame.color.THECOLORS["white"]), (50, 20))
    screen.blit(font.render("Dynamic shapes", 1, pygame.color.THECOLORS["white"]), (250, 20))
    screen.blit(font.render("Constraints", 1, pygame.color.THECOLORS["white"]), (450, 20))
    screen.blit(font.render("Other", 1, pygame.color.THECOLORS["white"]), (450, 300))
   
    pygame.display.flip()
    
    while True:
        for event in pygame.event.get():
            if event.type == QUIT or \
                event.type == KEYDOWN and (event.key in [K_ESCAPE, K_q]):  
                return 
            elif event.type == KEYDOWN and event.key == K_p:
                pygame.image.save(screen, "pygame_util_demo.png")                
                                  
        clock.tick()
Ejemplo n.º 2
0
def main():
    pygame.init()
    screen = pygame.display.set_mode((600, 600))
    clock = pygame.time.Clock()
    font = pygame.font.SysFont("Arial", 16)

    space = pymunk.Space()

    add_objects(space)

    ### Draw it
    screen.fill(pygame.color.THECOLORS["black"])

    pymunk.pygame_util.draw(screen, space)

    # Info
    screen.blit(
        font.render("Demo example of shapes drawn by pygame_util.draw()", 1,
                    pygame.color.THECOLORS["darkgray"]), (5, 580))
    screen.blit(
        font.render("Static shapes", 1, pygame.color.THECOLORS["white"]),
        (50, 20))
    screen.blit(
        font.render("Dynamic shapes", 1, pygame.color.THECOLORS["white"]),
        (250, 20))
    screen.blit(font.render("Constraints", 1, pygame.color.THECOLORS["white"]),
                (450, 20))
    screen.blit(font.render("Other", 1, pygame.color.THECOLORS["white"]),
                (450, 300))

    pygame.display.flip()

    while True:
        for event in pygame.event.get():
            if event.type == QUIT or \
                event.type == KEYDOWN and (event.key in [K_ESCAPE, K_q]):
                return
            elif event.type == KEYDOWN and event.key == K_p:
                pygame.image.save(screen, "pygame_util_demo.png")

        clock.tick()
__docformat__ = "reStructuredText"

import sys

import pyglet
    
import pymunk
from pymunk.vec2d import Vec2d
import pymunk.pyglet_util

from shapes_for_draw_demos import add_objects

window = pyglet.window.Window(600, 600)
space = pymunk.Space()

add_objects(space)


textbatch = pyglet.graphics.Batch()
pyglet.text.Label('Demo example of shapes drawn by pyglet_util.draw()',
                      x=5, y=5, batch=textbatch, color=(200,200,200,200))
pyglet.text.Label('Static shapes', x=50, y=570, batch=textbatch)
pyglet.text.Label('Dynamic shapes', x=250, y=570, batch=textbatch)
pyglet.text.Label('Constraints', x=450, y=570, batch=textbatch)
pyglet.text.Label('Other', x=450, y=290, batch=textbatch)


batch = pyglet.graphics.Batch()

@window.event
def on_draw():
Ejemplo n.º 4
0
__docformat__ = "reStructuredText"

import sys

import pyglet

import pymunk
from pymunk.vec2d import Vec2d
import pymunk.pyglet_util

from shapes_for_draw_demos import add_objects

window = pyglet.window.Window(600, 600)
space = pymunk.Space()

add_objects(space)

textbatch = pyglet.graphics.Batch()
pyglet.text.Label('Demo example of shapes drawn by pyglet_util.draw()',
                  x=5,
                  y=5,
                  batch=textbatch,
                  color=(200, 200, 200, 200))
pyglet.text.Label('Static shapes', x=50, y=570, batch=textbatch)
pyglet.text.Label('Dynamic shapes', x=250, y=570, batch=textbatch)
pyglet.text.Label('Constraints', x=450, y=570, batch=textbatch)
pyglet.text.Label('Other', x=450, y=290, batch=textbatch)

batch = pyglet.graphics.Batch()