Пример #1
0
    def init(self, *args, **kwargs):

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

        game = Game()

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

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

        ssound.Preload('rc/snd/1.wav', ['alias0'])

        musmap = {
            0: 'rc/snd/music/Welcome.mp3',
            1: 'rc/snd/music/Time.mp3',
            2: 'rc/snd/music/0x4.mp3'
        }

        for x in xrange(0, 3):
            layer = GUITextItem(layout={
                'width': 100,
                'height': 20,
                'left': 50,
                'right': 50,
                'offset_y': 70 * x,
                'padding': [20, 10],
                'force-size': False
            },
                                text=musmap[x])
            layer.on(
                'ui:click',
                (lambda x: lambda *a: music.Play(musmap[x], loop=True))(x))
            self.pushLayerFront(layer)

        tile = _9Tiles(LoadTexture('rc/img/ui-frames.png'),
                       Rect(left=0, bottom=0, width=12, height=12))

        self.pushLayerFront(
            GUI9TileItem(tiles=tile,
                         layout={
                             'left': 100,
                             'right': 100,
                             'top': 200,
                             'bottom': 200
                         }))

        GAME_CONSOLE.write('Startup screen created.')
Пример #2
0
	def init(self,*args,**kwargs):

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

		game = Game()

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

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

		ssound.Preload('rc/snd/1.wav',['alias0'])

		musmap = {0:'rc/snd/music/Welcome.mp3',1:'rc/snd/music/Time.mp3',2:'rc/snd/music/0x4.mp3'}

		for x in xrange(0,3):
			layer = GUITextItem(
				layout={
					'width':100,
					'height':20,
					'left':50,
					'right':50,
					'offset_y':70*x,
					'padding':[20,10],
					'force-size':False
					},
				text=musmap[x]);
			layer.on('ui:click',(lambda x: lambda *a: music.Play(musmap[x],loop=True))(x))
			self.pushLayerFront(layer)

		tile = _9Tiles(LoadTexture('rc/img/ui-frames.png'),Rect(left=0,bottom=0,width=12,height=12))

		self.pushLayerFront(GUI9TileItem(
			tiles=tile,
			layout = {
				'left': 100,
				'right': 100,
				'top': 200,
				'bottom': 200
			}))

		GAME_CONSOLE.write('Startup screen created.')
Пример #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.')
Пример #4
0
	def setUp(self):
		self.game = Game()
		self.e = [GameEntity() for i in range(2)]
		for e in self.e:
			self.game.addEntity(e)
Пример #5
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)
Пример #6
0
	def __init__(self,level_data):
		Game.__init__(self)
		self._generation = level_data['generation']

		self.initialGenerate()
		self._spent_fuel = 0
Пример #7
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.')