本文整理汇总了Python中stage.Stage.get_stage方法的典型用法代码示例。如果您正苦于以下问题:Python Stage.get_stage方法的具体用法?Python Stage.get_stage怎么用?Python Stage.get_stage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stage.Stage
的用法示例。
在下文中一共展示了Stage.get_stage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import get_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):
#.........这里部分代码省略.........