Ejemplo n.º 1
0
	def __init__(self, event_id, art, art_tile, on, z, blocked, enter, one_time, locked, immediate, extra):
		self.event_id 	= event_id 	#the type of event
		self.on 		= on 		#tile position
		self.z 			= z 		#z level
		self.blocked 	= blocked 	#whether or not the event causes the tile to be blocked
		self.enter 		= enter 	#whether it's activated by enter or stepping on (T/F)
		self.one_time 	= one_time 	#whther it can be activated once or inifinite times (T/F)
		self.locked 	= locked 	#whether the event is currently available or not (T/F)
		self.immediate 	= immediate #whether the event is activated as soon as it's available (T/F)
		self.extra 		= extra		#the text in the evt file that defines the specific event

		if art is not None:
			art = pg.image.load(art).convert_alpha()
			self.art = art.subsurface(g.tile2rect(art_tile)).copy()
			self.art_outlined = g.makeOutlinedArt(self.art, g.RED)
		else:
			self.art = pg.Surface(g.TILE_RES, SRCALPHA, 32).convert_alpha()
			self.art_outlined = self.art.copy()
			for i in range(g.TILE_RES[0]):
				self.art_outlined.set_at((i, 0), g.RED)
				self.art_outlined.set_at((i, g.TILE_RES[1]-1), g.RED)
			for i in range(g.TILE_RES[1]):
				self.art_outlined.set_at((0, i), g.RED)
				self.art_outlined.set_at((g.TILE_RES[0]-1, i), g.RED)
		

		
		self.rect = g.tile2rect(on)
		self.behind = None #WE get stacked behind other events on the same tile, that is, when one gets executed and removed the one behind it gets placed
Ejemplo n.º 2
0
	def collisionWithBlockedTile(self, tile, z, player = True, enemies = True, tiles = True, events = True, ignoreEnemy = None):
		rect = g.tile2rect(tile)

		#if any corners are on player
		if player and self.player.getRect().colliderect(rect):
			return True

		#if any corners are on an enemy
		if enemies:
			for e in self.curEnemies:
				if e is not ignoreEnemy:
					if e.getRect().colliderect(rect):
						return True

		# if any of the corners are on a blocked map tile or WE tile
		if tiles:
			try:
				if self.map.getTile(tile, z, pixel = False).blocked():
				# if self.map.blocked(rect, zs):
					return True
			except:
				return True
				pass
			# 	print "blocked on tile", tile, "and z", z
			# 	quit()

		# if any of the corners are on a WE tile
		if events and self.eventForeground.blocked(rect, z):
			return True
Ejemplo n.º 3
0
	def setPlace(self, position, z):
		#make a rect for where it is
		self.pos = g.tile2rect(position).topleft  #given in tile coordinates, convert to topleft pixel
		self.rect= pg.Rect(self.pos, self.size)
		# self.fourCorners = (self.rect.topleft, self.rect.topright, self.rect.bottomleft, self.rect.bottomright)
		self.previousRect = self.rect.copy()
		
		#what floor "level" is the player on
		self.z = z
Ejemplo n.º 4
0
	def genSubsurfaces(self, squareSize):
		tileDict = {}
		imgRect = self.tileImg.get_rect()
		x, y = 0, 0
		morey = True
		while morey:
			while True:
				tile = g.tile2rect((x, y))
				if imgRect.contains(tile):
					tileDict[(x, y)] = self.tileImg.subsurface(tile)
					x += 1
				else:
					if x == 0:
						morey = False
					else:
						x = 0
					break
			y += 1
		return tileDict