当前位置: 首页>>代码示例>>Python>>正文


Python Map.drawMap方法代码示例

本文整理汇总了Python中map.Map.drawMap方法的典型用法代码示例。如果您正苦于以下问题:Python Map.drawMap方法的具体用法?Python Map.drawMap怎么用?Python Map.drawMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在map.Map的用法示例。


在下文中一共展示了Map.drawMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Levels

# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import drawMap [as 别名]
class Levels():
    def __init__(self,surface):
        self.surface = surface
        self.coords = {'WilliamBradford':[10,10]}
        self.sound = True

        self.banned = []
        self.run = True
        self.talk = False
        self.coming = ''
        #Blocks allowed to move in
        self.allowedPaths = {'main':'data\\levels\\1620\\allowed.txt'}
        self.cant_talk_box = Conversation(self.surface)

    def cant_talk(self, time):
        if self.talk:
            #Can't talk message
            self.cant_talk_box.chat(time, [None], 'data\\cant_talk.txt', 1)
            
    def stay_on_screen(self, x, y):
        self.allowed = open(self.allowedPaths['main'], 'r')
        x2 = 0
        y2 = 1
        if self.run:
            self.run = False
            for lines in range(0, 18):
                line = self.allowed.readline()
                for tile in line:
                    if tile == 'Y':
                        pass #Do Nothing. You can walk on this tile.
                    if tile == 'N':
                        self.banned.append([x2,y2])
                    x2 += 1
                x2 = 0
                y2 += 1

        for coord in self.banned:
            if y + 1 == coord[1] and x == coord[0]:
                self.coming = 'top'
            elif y - 1 == coord[1] and x == coord[0]:
                self.coming = 'bottom'
            elif x + 1 == coord[0] and y == coord[1]:
                self.coming = 'left'
            elif x - 1 == coord[0] and y == coord[1]:
                self.coming = 'right'
                
            if x == coord[0] and y == coord[1]:
                if self.coming == 'left':
                    x = x - 1
                if self.coming == 'right':
                    x = x + 1
                if self.coming == 'top':
                    y = y - 1
                if self.coming == 'bottom':
                    y = y + 1
                self.coming = ''
                self.talk = True
                self.cant_talk_box = Conversation(self.surface)
                    
        return x,y
    
    def Y1620(self,clock):
        #Setup objects
        self.layout = Map(self.surface)
        self.man = Character(self.surface)
        self.WilliamBradford = Character(self.surface)
        self.keyboard = Keyboard()
        self.settings = Settings(self.surface)
        self.inventory =  Inventory(self.surface)
        self.chat = Conversation(self.surface)
        self.mayflower = Mayflower(self.surface)
        
        self.x = 15
        self.y = 15
        self.direction = 'S'
        self.time = [0,0,100]
        self.go = False
        self.sun = -2
        self.firstSound = False
        pygame.mixer.music.load('data\\sound\\Godbless.mid')
        self.quit = 0
        while True:
            if self.sun > 8:
                pass #self.quit = self.layout.blackout(time)
            if self.sun < 0:
                self.layout.begin(time,'1620',self.sun)
            self.layout.sky(self.sun)
            self.x, self.y = self.stay_on_screen(self.x,self.y)
            self.layout.drawMap()
            self.x, self.y, self.go = self.man.move(self.x,self.y,self.direction,self.time,self.go)
            self.WilliamBradford.move(self.coords['WilliamBradford'][0],self.coords['WilliamBradford'][1],'S',self.time,False,1)
            self.WilliamBradford.check_for_chat(self.time, self.x, self.y, self.coords['WilliamBradford'][0], self.coords['WilliamBradford'][1])
            self.end, self.sound, self.pause, self.help = self.settings.settings_button()
            self.inventory.inventory_button()

            self.cant_talk(self.time)
            
            #Blit Mayflower
            self.mayflower.blit()
            
#.........这里部分代码省略.........
开发者ID:victormanakkat,项目名称:america,代码行数:103,代码来源:level.py

示例2: main

# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import drawMap [as 别名]
def main(arg):
	f = file(arg,'r')
	clock = pygame.time.Clock()
	bullets = []

	#init Map(grid, money, score, lives) depending on level
	level = Map(f, 200, 0, 20)

	level.popGrid(f)
	level.drawMap()

	exswitch = False
	exswitch2 = False
	startswitch = False
	helpswitch = False
	returnswitch = False
	towerArray = []
	minions = []
	t_minions = 1


	# run the game loop
	while True:
		gswitch = pygame.key.get_pressed()[K_g]
		cswitch = pygame.key.get_pressed()[K_c]
		pswitch = pygame.key.get_pressed()[K_p]
		while level.bool is True and level.lives is not 0:
			if(t_minions <= 10):
				minions.append(Minions(level))
				level.moveX(minions)
				t_minions = t_minions + 1
			else:
				mousex, mousey = pygame.mouse.get_pos()
				#print("MOUSE",mousex,mousey)
				level.moveX(minions)
			#level.live_out()
			#level.score_out()
			level.updateLevel()
			level.updateLives()
			level.updateScore()
			level.updateMoney()
				#level.money_out()
				#level.blit_update()
			if(not minions):
				level.bool = False
				level.level = level.level + 1
				level.moveX([])
				level.updateLevel()
				level.updateLives()
				level.updateScore()
				level.updateMoney()
				t_minions = 1
				print("success")
			for x in range(len(minions)):
				print(minions[x].HP)
			print('\n')
			for x in minions:
				for y in towerArray:
					if(y.pingTower(x) is True):
						level.bulletShoot(x,y)
						if(y.damMini(x) is True):
							level.score = level.score + x.score
							level.updateScore()
							#level.score_out()
							level.money = level.money + x.value
							#level.updateMoney()
							try:
								minions.remove(x)
							except ValueError:
								pass
							print("LEVELmoney", level.money)
						#break
				break
			level.blit_update()

		if(level.lives is 0):
			fonts = FontTemplate(('arial', 15))
			rect = pygame.Rect(level.screenWidth/2,level.screenHeight/2,300,150)
			pygame.draw.rect(level.windowSurface, constants.RED, rect)
			fonts.Draw(level.windowSurface, 'arial', 12, 'YOU SUCK!! (Main Menu to return)', rect, constants.WHITE, 'center', 'center', True)
			level.blit_update()

		if(level.level is 10):
			fonts = FontTemplate(('arial', 15))
			rect = pygame.Rect(level.screenWidth/2,level.screenHeight/2,300,150)
			pygame.draw.rect(level.windowSurface, constants.GREEN, rect)
			fonts.Draw(level.windowSurface, 'arial', 12, 'CONGRATS,YOU STILL SUCK! :)', rect, constants.WHITE, 'center', 'center', True)
			level.blit_update()
		if(gswitch == 1):
			level.drawGrid()
			level.drawRange(towerArray)
		if(cswitch == 1):
			thing = True
			level.drawMap()

		for event in pygame.event.get():
			if(exswitch is True and event.type is pygame.MOUSEBUTTONDOWN):
				mousex, mousey = pygame.mouse.get_pos()
				cord = level.getGridCord(mousex,mousey)
				temporary = Tower(1)
#.........这里部分代码省略.........
开发者ID:kdoidge12,项目名称:blitznchips,代码行数:103,代码来源:main.py


注:本文中的map.Map.drawMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。