Exemplo n.º 1
0
	def init(self,*args,**kwargs):
		self.winner = None
		self.freeze = False
		gl.glClearColor(0x1d/255.0,0x5b/255.0,0x70/255.0,1)

		# self.pushLayerFront(StaticBackgroundLauer('rc/img/256x256bg.png','fill'))

		game = Game()
		self.camera = Camera()

		self.game = game

		self.game.listen('win')
		self.game.on('win',self.event('win'))

		game.loadFromJSON('rc/lvl/level0.json')

		for pid, pcl in PLAYER_CHOICES.items():
			p = pcl()
			game.addEntity(p)
			# p.animations = 'rc/ani/player-test-'+pid+'.json'
			p.position = 500 if pid == 'player-right' else -500, 0
			p.id = pid
			p.trigger('configured')

		self.gameLayer = GameLayer(game=game,camera=self.camera)
		self.pushLayerFront(self.gameLayer)

		self.pushLayerFront(HpProgressBar(grow_origin='top-left',
			expression=lambda: game.getEntityById('player-left').health / 100.0,
			layout=ProgressBar.LEFT_LAYOUT,player=game.getEntityById('player-left')))
		self.pushLayerFront(HpProgressBar(grow_origin='top-right',
			expression=lambda: game.getEntityById('player-right').health / 100.0,
			layout=ProgressBar.RIGHT_LAYOUT,player=game.getEntityById('player-right')))

		self.timer = Timer(layout={'top':70,'width':100,'height':20,'force-size':True})
		self.pushLayerFront(self.timer)

		self.pushLayerFront(GUITextItem_(layout={'top':20,'width':100,'height':20},text=('ROUND #'+str(GLOBAL_STATE['round']))))
		self.counters = {pid : GUITextItem_(layout={'top':40,pid[7:]:40,'width':0,'height':0},text=str(GLOBAL_STATE['player-left'])) for pid in ['player-left','player-right']}
		for z,x in self.counters.items():
			self.pushLayerFront(x)

		GAME_CONSOLE.write('Startup screen created.')
Exemplo n.º 2
0
class GameTestCase(TestCase):
	def setUp(self):
		self.game = Game()
		self.e = [GameEntity() for i in range(2)]
		for e in self.e:
			self.game.addEntity(e)
Exemplo n.º 3
0
    def init(self, *args, **kwargs):
        self.winner = None
        self.freeze = False
        gl.glClearColor(0x1d / 255.0, 0x5b / 255.0, 0x70 / 255.0, 1)

        # self.pushLayerFront(StaticBackgroundLauer('rc/img/256x256bg.png','fill'))

        game = Game()
        self.camera = Camera()

        self.game = game

        self.game.listen('win')
        self.game.on('win', self.event('win'))

        game.loadFromJSON('rc/lvl/level0.json')

        for pid, pcl in PLAYER_CHOICES.items():
            p = pcl()
            game.addEntity(p)
            # p.animations = 'rc/ani/player-test-'+pid+'.json'
            p.position = 500 if pid == 'player-right' else -500, 0
            p.id = pid
            p.trigger('configured')

        self.gameLayer = GameLayer(game=game, camera=self.camera)
        self.pushLayerFront(self.gameLayer)

        self.pushLayerFront(
            HpProgressBar(grow_origin='top-left',
                          expression=lambda: game.getEntityById('player-left').
                          health / 100.0,
                          layout=ProgressBar.LEFT_LAYOUT,
                          player=game.getEntityById('player-left')))
        self.pushLayerFront(
            HpProgressBar(grow_origin='top-right',
                          expression=lambda: game.getEntityById('player-right')
                          .health / 100.0,
                          layout=ProgressBar.RIGHT_LAYOUT,
                          player=game.getEntityById('player-right')))

        self.timer = Timer(layout={
            'top': 70,
            'width': 100,
            'height': 20,
            'force-size': True
        })
        self.pushLayerFront(self.timer)

        self.pushLayerFront(
            GUITextItem_(layout={
                'top': 20,
                'width': 100,
                'height': 20
            },
                         text=('ROUND #' + str(GLOBAL_STATE['round']))))
        self.counters = {
            pid: GUITextItem_(layout={
                'top': 40,
                pid[7:]: 40,
                'width': 0,
                'height': 0
            },
                              text=str(GLOBAL_STATE['player-left']))
            for pid in ['player-left', 'player-right']
        }
        for z, x in self.counters.items():
            self.pushLayerFront(x)

        GAME_CONSOLE.write('Startup screen created.')