本文整理汇总了Python中stage.Stage.next_stage方法的典型用法代码示例。如果您正苦于以下问题:Python Stage.next_stage方法的具体用法?Python Stage.next_stage怎么用?Python Stage.next_stage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stage.Stage
的用法示例。
在下文中一共展示了Stage.next_stage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import next_stage [as 别名]
class Gamelolz:
#This is the __init__
#its important.
def __init__(self,parent):
self.parent=parent
globalvars.asdf = 0
##some key vars, the works
self.lagcount=0
#a little hack so that the background works nicer
self.background=globalvars.screen
#make the rectlist to handle dirty updating
self.updaterects=[]
#background object
self.bgstars=BackgroundManager()
##make the lists to handle various sprites
self.list_enemys=EnemyManager()
self.player_list=pygame.sprite.RenderUpdates()
self.list_allie_shots=pygame.sprite.OrderedUpdates()
self.enemy_shots=pygame.sprite.RenderUpdates()
self.token_list=pygame.sprite.RenderUpdates()
##make a new stage object
self.stage=Stage(self,self.list_enemys,self.player_list,self.enemy_shots,self.list_allie_shots)
#self.setup_events()
self.new_display()
def new_display(self):
self.side_panel= pygame.sprite.RenderUpdates()
self.points=Points()
self.side_panel.add(self.points)
self.health=Health()
self.healthbar=HealthBar(self.health)
self.livesbar=LivesBar(self.health,self.healthbar)
self.side_panel.add(self.healthbar)
self.side_panel.add(self.health)
self.side_panel.add(self.livesbar)
#clears all the variables
def clear_vars(self):
self.leftkeydown=0
self.rightkeydown=0
self.points.set_points(0)
globalvars.x=400
globalvars.y=globalvars.WIN_RESY-60
self.stage.set_stage(0)
self.list_enemys.empty()
self.list_allie_shots.empty()
self.player_list.empty()
self.enemy_shots.empty()
print "Game Restarted"
def register_inputs(self):
import defaultinputs
defaultinputs.setup(self.inputmanager,self)
#define function to draw player ship on X, Y plane
def pship(self):
self.player_list.clear(globalvars.surface,self.background)
self.updaterects+=self.player_list.draw(globalvars.surface)
#Define function to move the enemy ship
def emove(self):
self.list_enemys.clear(globalvars.surface, self.background)
self.updaterects+=self.list_enemys.draw(globalvars.surface)
#So i'm trying out having the program check for collisions, instead of the enemy objects
#i think i might switch to the objects, but still keep this function just hand the computing to the object
#seems most efficient
def test_collision(self):
todie=ecollision.groupcollide(self.list_enemys, self.list_allie_shots,0,0,ecollision.BOTTOM)
#todie=pygame.sprite.groupcollide(self.list_enemys, self.list_allie_shots,0,0)
#print todie
for enemy,bullet in todie.iteritems():
bullet.set_hit(1)
enemy.hit(bullet.damage)
self.points.add_points(1)
for q in pygame.sprite.spritecollide(self.player, self.enemy_shots,0):
#for q in ecollision.spritecollide(self.player, self.enemy_shots,0,ecollision.TOP):
#print "ZOMFG SHOTZORZ"
self.player.set_hit(q.damage)
self.enemy_shots.remove(q)
#if self.token_list:
# for token in ecollision.spritecollide(self.player, self.token_list,0, ecollision.TOP):
# print token
#if there are no enemys left, go to the next stage
def check_done(self):
if not globalvars.asdf%20 and not self.list_enemys: #the %20 lets it wait a fraction of a second
self.stage.next_stage()
#checks to see if we can expand the ranges of the bots so its nice and.... umm... nice.
def check_rows(self):
if globalvars.asdf % 20==0:
self.list_enemys.check_enemy_rows()
#major hack just to get this thing playable..... sorry
def again(self):
if self.player.health <= 0:
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import next_stage [as 别名]
class Gamelolz:
#This is the __init__
#its important.
def __init__(self,parent):
self.parent=parent
globalvars.asdf = 0
self.lagcount=0
self.leftkeydown=0
self.rightkeydown=0
self.enemylist=[]
self.list_enemys=EnemyManager()
self.stage=Stage(self.list_enemys,globalvars.player_list)
self.list_allie_shots=pygame.sprite.RenderUpdates()
self.enemy_shots=pygame.sprite.RenderUpdates()
#clears all the variables
def clear_vars(self):
self.leftkeydown=0
self.rightkeydown=0
health.set_health(globalvars.max_health)
points.set_points(0)
globalvars.x=400
globalvars.y=globalvars.WIN_RESY-60
self.stage.set_stage(-1) #hax
globalvars.enemy_bullet_odds=100
self.list_enemys.empty()
self.list_allie_shots.empty()
globalvars.player_list.empty()
self.enemy_shots.empty()
print "Game Restarted"
#define function to draw player ship on X, Y plane
def pship(self, x,y):
globalvars.player_list.clear(globalvars.surface,globalvars.screen)
self.enemylist+=globalvars.player_list.draw(globalvars.surface)
#Define function to move the enemy ship
def emove(self):
self.list_enemys.clear(globalvars.surface, globalvars.screen)
self.enemylist+=self.list_enemys.draw(globalvars.surface)
#draws all the enemys you ask it
def draw_enemys(self):
#k so now some recursive loops:
for enemycol in range(self.stage.get_stage()[0]):
#now for the rows
for enemyrow in range(self.stage.get_stage()[1]):
#make a new enemy object:
tempenemy=Enemy(self.list_enemys)
#this ones a long one, but it works:
tempenemy.set_pos(globalvars.xmin+enemycol*(globalvars.enemy_width+globalvars.enemy_spacing_x),globalvars.ymin+enemyrow*(globalvars.enemy_height+globalvars.enemy_spacing_y)-150)
#this one is even worse, but works even better:
tempenemy.set_range(globalvars.xmin+enemycol*(globalvars.enemy_width+globalvars.enemy_spacing_x),globalvars.xmax-(self.stage.get_stage()[0]-enemycol)*(globalvars.enemy_height+globalvars.enemy_spacing_x))
#now add the temp enemy to the array and we're good to go
self.list_enemys.add(tempenemy)
#So i'm trying out having the program check for collisions, instead of the enemy objects
#i think i might switch to the objects, but still keep this function just hand the computing to the object
#seems most efficient
def test_collision(self):
todie=pygame.sprite.groupcollide(self.list_enemys, self.list_allie_shots,0,0)
#print todie
for enemy,bullet in todie.iteritems():
self.list_allie_shots.remove(bullet)
enemy.set_state(0)
points.add_points(1)
if pygame.sprite.spritecollideany(self.player, self.enemy_shots):
#print "ZOMFG SHOTZORZ"
self.player.set_hit()
health.hit()
#if there are no enemys left, go to the next stage
def check_done(self):
if not self.list_enemys:
self.stage.next_stage()
self.draw_enemys()
#checks to see if we can expand the ranges of the bots so its nice and.... umm... nice.
def check_rows(self):
if globalvars.asdf % 20==0:
#simple sorting algorithm to find the highest values
highest=globalvars.xmin
lowest=globalvars.xmax
for enemy in self.list_enemys:
if enemy.get_range()[1] > highest:
highest=enemy.get_range()[1]
if enemy.get_range()[0] < lowest:
lowest=enemy.get_range()[0]
highest=globalvars.xmax-highest
lowest=lowest-globalvars.xmin
if highest != 0 or lowest != 0: #makes things |--| this much more efficient
for enemy in self.list_enemys:
erange=enemy.get_range()
enemy.set_range(erange[0]-lowest,erange[1]+highest)
#major hack just to get this thing playable..... sorry
def again(self):
#.........这里部分代码省略.........