示例#1
0
    def __init__(self):

        pygame.init()
        self.size = (1024, 600)
        self.surface = pygame.display.set_mode(self.size)
        self.clock = pygame.time.Clock()

        self.gameboard = Gameboard()
        self.player = Player(self.gameboard)
        self.level = Level(self.gameboard)
        self.level.update(0, self.gameboard)
        self.player.screenshot = self.printscreen
        self.view = Gameview(self.surface, self)

        self.time = 0

        while not (self.player.quit or self.player.hasLost()):
            self.clock.tick(Game.FPS)
            unit = self.gameboard.units.getSelected()
            if unit is None:
                continue
            if (int(self.time) is not int(self.gameboard.units.time)):
                self.level.update(int(self.gameboard.units.time),
                                  self.gameboard)
                self.gameboard.update()
            self.time = self.gameboard.units.time
            unit.owner.turn(self, unit)
            self.view.draw()
            self.gameboard.update()
示例#2
0
	def __init__(self):
		
		pygame.init()
		self.size = (1024, 600)
		self.surface = pygame.display.set_mode(self.size)
		self.clock = pygame.time.Clock()
		
		self.gameboard = Gameboard()
		self.player = Player(self.gameboard)
		self.level = Level(self.gameboard)
		self.level.update(0, self.gameboard)
		self.player.screenshot = self.printscreen
		self.view = Gameview(self.surface, self)
		
		self.time = 0
		
		while not (self.player.quit or self.player.hasLost()):
			self.clock.tick(Game.FPS)
			unit = self.gameboard.units.getSelected()
			if unit is None:
				continue
			if(int(self.time) is not int(self.gameboard.units.time)):
				self.level.update(int(self.gameboard.units.time), self.gameboard)
				self.gameboard.update()
			self.time = self.gameboard.units.time
			unit.owner.turn(self, unit)
			self.view.draw()
			self.gameboard.update()
示例#3
0
class Game(object):

	FPS = 30

	def __init__(self):

		pygame.init()
		pygame.display.set_caption("RPG Game")
		self.seed = 26281376
		self.world = World(self.seed, SoundCache())
		self.user = Player(self)
		self.view = Gameview(self.world, self.user, ImageCache(), self.debug)

		self.clock = pygame.time.Clock()
		self.renderTime = 0
		self.processTime = 0		
		
	def run(self):

		while(True):

			self.clock.tick(Game.FPS)
			t = time.time()
			self.view.draw()
			self.renderTime = time.time() - t
			
			t = time.time()
			if not self.world.update():
				continue
			
			if self.user.turn():
				continue

			self.world.turn()
			self.user.save()
			self.processTime = time.time() - t
	
	def debug(self):
		msg = []
		msg.append(['FPS: ' + str(int(self.clock.get_fps()))])
		msg.append(['Mobs: ' + str(len(self.world.mobManager.mobs))])
		msg.append(['Chunks: ' + str(len(self.world.chunkManager.chunkCache))])
		msg.append(['Render: ' + str(int(self.renderTime * 1000)) + 'ms'])
		msg.append(['World: ' + str(int(self.processTime * 1000)) + 'ms'])
		msg.append(['Time: ' + str(self.world.time)])
		return msg
示例#4
0
class Game(object):

    FPS = 30

    def __init__(self):

        pygame.init()
        self.size = (1024, 600)
        self.surface = pygame.display.set_mode(self.size)
        self.clock = pygame.time.Clock()

        self.gameboard = Gameboard()
        self.player = Player(self.gameboard)
        self.level = Level(self.gameboard)
        self.level.update(0, self.gameboard)
        self.player.screenshot = self.printscreen
        self.view = Gameview(self.surface, self)

        self.time = 0

        while not (self.player.quit or self.player.hasLost()):
            self.clock.tick(Game.FPS)
            unit = self.gameboard.units.getSelected()
            if unit is None:
                continue
            if (int(self.time) is not int(self.gameboard.units.time)):
                self.level.update(int(self.gameboard.units.time),
                                  self.gameboard)
                self.gameboard.update()
            self.time = self.gameboard.units.time
            unit.owner.turn(self, unit)
            self.view.draw()
            self.gameboard.update()

    def printscreen(self):
        date = time.gmtime()
        fileName = "screenshot_" + \
         str(date[0]) + '-' + \
         str(date[1]) + '-' + \
         str(date[2]) + '-' + \
         str(date[3]-8) + '-' + \
         str(date[4]) + '-' + \
         str(date[5]) + \
         '.jpg'
        pygame.image.save(self.surface, fileName)
示例#5
0
class Game(object):

	FPS = 30

	def __init__(self):
		
		pygame.init()
		self.size = (1024, 600)
		self.surface = pygame.display.set_mode(self.size)
		self.clock = pygame.time.Clock()
		
		self.gameboard = Gameboard()
		self.player = Player(self.gameboard)
		self.level = Level(self.gameboard)
		self.level.update(0, self.gameboard)
		self.player.screenshot = self.printscreen
		self.view = Gameview(self.surface, self)
		
		self.time = 0
		
		while not (self.player.quit or self.player.hasLost()):
			self.clock.tick(Game.FPS)
			unit = self.gameboard.units.getSelected()
			if unit is None:
				continue
			if(int(self.time) is not int(self.gameboard.units.time)):
				self.level.update(int(self.gameboard.units.time), self.gameboard)
				self.gameboard.update()
			self.time = self.gameboard.units.time
			unit.owner.turn(self, unit)
			self.view.draw()
			self.gameboard.update()
		
	def printscreen(self):
		date = time.gmtime()
		fileName =	"screenshot_" + \
			str(date[0]) + '-' + \
			str(date[1]) + '-' + \
			str(date[2]) + '-' + \
			str(date[3]-8) + '-' + \
			str(date[4]) + '-' + \
			str(date[5]) + \
			'.jpg'
		pygame.image.save(self.surface, fileName)
示例#6
0
	def __init__(self):

		pygame.init()
		pygame.display.set_caption("RPG Game")
		self.seed = 26281376
		self.world = World(self.seed, SoundCache())
		self.user = Player(self)
		self.view = Gameview(self.world, self.user, ImageCache(), self.debug)

		self.clock = pygame.time.Clock()
		self.renderTime = 0
		self.processTime = 0