本文整理汇总了Python中World.World.draw方法的典型用法代码示例。如果您正苦于以下问题:Python World.draw方法的具体用法?Python World.draw怎么用?Python World.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World.World
的用法示例。
在下文中一共展示了World.draw方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import draw [as 别名]
class Application:
def __init__(self):
pygame.init()
pygame.display.set_caption('SideScroller')
pygame.display.set_mode([1024,600])
self.world = World()
self.world.addManager('player',MovementManager())
self.world.addManager('scrollable',ScrollManager())
self.world.addManager('friction',FrictionManager())
self.world.load('lvl/maps.txt','lvl/1.txt')
self.clock = pygame.time.Clock()
self.go = True
def loop(self):
while self.go:
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
sys.exit()
self.clock.tick(60)
self.world.update( events )
self.world.draw(pygame.display.get_surface())
pygame.display.flip()
示例2: build
# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import draw [as 别名]
def build(self):
Config.set('graphics', 'width', self.settings.WINDOW_WIDTH)
Config.set('graphics', 'height', self.settings.WINDOW_HEIGHT)
game = World(self.settings)
game.draw()
Clock.schedule_interval(game.update, self.settings.UPDATE_SPEED)
return game
示例3: main
# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import draw [as 别名]
def main():
pygame.init()
world = World(screen_size=(600, 600), one_second=1000.)
ball = Ball()
ball.set_pos(pymunk.Vec2d(2.0, 8.0))
ball.body.velocity = pymunk.Vec2d(1.0, 1.0)
world.add(ball)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT: return
world.step()
world.draw()
示例4: str
# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import draw [as 别名]
world.players = [player]
world.crates = [crate]
world.gravity = 2
world.mobSpawns = [[100, 100]]
for i in world.drawList:
for e in i:
print i.size, i.position
enemySpawn = 0
while 1:
world.buildDrawList()
world.buildEntList()
screen.fill((255,255,255))
world.draw(screen)
fps = str(int(round(clock.get_fps())))
fpsSurf = font.render(fps, True, (0,0,0))
fpsRect = fpsSurf.get_rect()
fpsRect.topleft = [10,10]
screen.blit(fpsSurf, fpsRect)
world.eList = pygame.event.get()
for e in world.eList:
if e.type == KEYDOWN and e.key == K_ESCAPE:
pygame.quit()
sys.exit()
if e.type == QUIT:
pygame.quit()
示例5: Game
# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import draw [as 别名]
#.........这里部分代码省略.........
def blackhole(self):
""" Resets players position and stats if caught in black hole """
if self.player1.spaceship.pos.diff(self.screen.blackhole.pos) < 50:
self.player1.reset()
if self.player2.spaceship.pos.diff(self.screen.blackhole.pos) < 50:
self.player2.reset()
def statscheck(self):
""" Checks the status of fuel level and lives """
#fuelcheck
if self.player1.fuel.value < 1:
self.player1.lockthrust = True
if self.player2.fuel.value < 1:
self.player2.lockthrust = True
#livescheck
if self.player1.Lives.value < 1:
self.player1.reset()
if self.player2.Lives.value < 1:
self.player2.reset()
def collidepad(self):
""" Checking if spaceship is on its pad """
if pygame.sprite.collide_mask(self.player1.spaceship, self.screen.platform1):
self.player1.spaceship.on_pad = True
if self.player1.fuel.value < 500:
self.player1.fuel.value += 3
self.player1.Bullets.value = 100
else:
self.player1.spaceship.on_pad = False
if pygame.sprite.collide_mask(self.player2.spaceship, self.screen.platform2):
self.player2.spaceship.on_pad = True
if self.player2.fuel.value < 500:
self.player2.fuel.value += 3
self.player2.Bullets.value = 100
else:
self.player2.spaceship.on_pad = False
def draw(self):
""" Drawing all visible objects on screen """
self.screen.draw()
self.stats.draw(self.screen.screen)
self.players.draw(self.screen.screen)
self.player1.shots.draw(self.screen.screen)
self.player2.shots.draw(self.screen.screen)
pygame.display.flip()
def handle_events(self):
""" Handles all the events thrown by pygame """
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
elif event.type == pygame.USEREVENT+1:
self.player1.lock = False
elif event.type == pygame.USEREVENT+2:
self.player2.lock = False
keys = pygame.key.get_pressed()
if keys[pygame.K_UP]:
self.player1.thrust()
if not self.player1.lockthrust:
self.player1.fuel.value -= 1
elif keys[pygame.K_DOWN]:
self.player1.reverse()
if not self.player1.lockthrust:
self.player1.fuel.value -= 1
if keys[pygame.K_LEFT]:
self.player1.turn_left()
elif keys[pygame.K_RIGHT]:
self.player1.turn_right()
if keys[pygame.K_RCTRL]:
self.player1.fire()
if keys[pygame.K_w]:
self.player2.thrust()
if not self.player2.lockthrust:
self.player2.fuel.value -= 1
elif keys[pygame.K_s]:
self.player2.reverse()
if not self.player2.lockthrust:
self.player2.fuel.value -= 1
if keys[pygame.K_a]:
self.player2.turn_left()
elif keys[pygame.K_d]:
self.player2.turn_right()
if keys[pygame.K_SPACE]:
self.player2.fire()
def run(self):
""" Main run loop """
self.draw()
while(True):
self.clock.tick(60)
self.handle_events()
self.update()
self.draw()
示例6: print
# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import draw [as 别名]
crashed = False
while cycleCount < args.cycles and not crashed:
## event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
crashed = True
## logic
start = pygame.time.get_ticks()
world.performCycle(cycleCount)
timeTook = pygame.time.get_ticks() - start
print("Cycle {} ({} bonks): took {}ms ".format(str(cycleCount), world.bonkTotal, str(timeTook)))
## draw stuff
gameDisplay.fill(WHITE)
world.draw(gameDisplay)
## end
pygame.display.flip() ## redraw screen
clock.tick(cyclesPerSecond) ## 1 cycle per second
cycleCount += 1
bonkFpsData[0].append(cycleCount)
bonkFpsData[1].append(timeTook)
bonkFpsData[2].append(world.bonkTotal)
gameDisplay.fill(WHITE)
Graphing.graphData(bonkFpsData, gameDisplay, width_height)
pygame.display.flip() ## redraw screen
clock.tick(cyclesPerSecond) ## 1 cycle per second