當前位置: 首頁>>代碼示例>>Python>>正文


Python GUI.make_rect方法代碼示例

本文整理匯總了Python中GUI.make_rect方法的典型用法代碼示例。如果您正苦於以下問題:Python GUI.make_rect方法的具體用法?Python GUI.make_rect怎麽用?Python GUI.make_rect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GUI的用法示例。


在下文中一共展示了GUI.make_rect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update

# 需要導入模塊: import GUI [as 別名]
# 或者: from GUI import make_rect [as 別名]
def update(towers):
	import GUI
	global scalar
	global themap
	global end
	global blocks_per_side
	global monsters
	global bullets
	global rects_to_replace
	global mpath

	for rect in rects_to_replace:
		GUI.make_rect((rect[0]//scalar)*scalar,(rect[1]//scalar)*scalar,rect[2])

	monsters_past = []

	rects_to_replace = []

	for index,monster in enumerate(monsters):
		#Directions: 0 = left, 1 = up, 2 = right, 3 = down

		moves = monster.is_move_time()

		cover_thing(monster,[1])

		for i in xrange(moves):
			x,y = monster.get_pos()
			
			pathindex = monster.get_pathindex()
			if pathindex >= len(mpath):
				print "A monster got past! One lifepoint down!"
				monsters_past.append(index)
				break
			direction = mpath[pathindex]

			monster.move()

			if direction == 0:
				x -= 1
			elif direction == 1:
				y -= 1
			elif direction == 2:
				x += 1
			elif direction == 3:
				y += 1

			monsters[index].set_pos(x,y)
			monsters[index].set_prev_direction(direction)

			monster.set_pos(x,y)
			monster.set_prev_direction(direction)

		GUI.draw_monster(monster)

	for index in reversed(monsters_past):
		del monsters[index]

	for tower in towers:

		if not tower.is_time_to_shoot():
			continue

		target = 0
		tax = 0
		tay = 0

		trange = tower.get_range()
		walked = 0

		for monster in monsters:
			mx,my = monster.get_pos()
			tx,ty = tower.get_pos()
			xoff,yoff = monster.get_offset()
			mx += xoff
			my += yoff
			tx *= scalar
			ty *= scalar
			tx += scalar/2
			ty += scalar/2
			distance = getdistance(mx,my,tx,ty)
			moved = monster.get_pxmoved()
			if distance <= trange and moved > walked:
				target = monster
				walked = moved
				tax = tx
				tay = ty

		if target == 0:
			continue

		tower.shot()

		bullet = Bullet.Bullet(tax,tay,target,tower.get_bullet_speed(),tower.get_damage())
		bullets.append(bullet)

	bullets_to_remove = []

	for index,bullet in enumerate(bullets):

		cover_thing(bullet,[0,1,2,3,4,5,6,7,8,9,10,11])
#.........這裏部分代碼省略.........
開發者ID:MoltenMan,項目名稱:Dual-Tower-Defense,代碼行數:103,代碼來源:Game.py


注:本文中的GUI.make_rect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。