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 __init__(self, position, z, size, img, pixStep=.20):
		self.size = (size[0]*g.TILE_RES[0], size[1]*g.TILE_RES[1]) #given in tile size, convert to pixel size 

		#make a rect for where it is
		self.pos = None #g.tile2rect(position).topleft  #given in tile coordinates, convert to topleft pixel
		self.rect = None #pg.Rect(self.pos, self.size)
		self.previousRect = None #self.rect.copy()
		# self.fourCorners = None
		
		#what floor "level" is the player on
		self.z = None #zs

		self.setPlace(position, z) #sets pos,rect,previousrect,zs

		#the image of the player
		img = pg.image.load(img).convert_alpha()

		#the image of the player facing in all directions
		img = {
			"D": img.subsurface(pg.Rect((0,0),              (self.size[0]*3, self.size[1]))),
			"L": img.subsurface(pg.Rect((0,1*self.size[1]), (self.size[0]*3, self.size[1]))),
			"R": img.subsurface(pg.Rect((0,2*self.size[1]), (self.size[0]*3, self.size[1]))),
			"U": img.subsurface(pg.Rect((0,3*self.size[1]), (self.size[0]*3, self.size[1])))  }

		self.udlrFacing = {}
		for k in img.keys():
			self.udlrFacing[k] = {
				0: img[k].subsurface(pg.Rect((0,0),self.size)).copy(),
				1: img[k].subsurface(pg.Rect((1*self.size[0],0),self.size)).copy(),
				2: img[k].subsurface(pg.Rect((0,0),self.size)).copy(),
				3: img[k].subsurface(pg.Rect((2*self.size[0],0),self.size)).copy()   }

		self.udlrFacing_outline = {}
		for d in self.udlrFacing:
			tempDict = {}
			for s in self.udlrFacing[d]:
				tempDict[s] = g.makeOutlinedArt(self.udlrFacing[d][s], g.BLUE)
			self.udlrFacing_outline[d]=tempDict

		#the current direction the player is facing
		self.facing = "D"
		# The number of pixels stepped since last change in image
		self.pixStepped = 0
		self.previousPixStepped = 0
		#the number of pixels before the image is changed
		self.pixStepSize = 20
		#the number of pixels traversed in a millisecond
		self.pixStep = pixStep + 0
		# The surrent image (still, left foot, right foot)
		self.currentImg = 0

		#the player defaulted to face forward
		self.art = (self.udlrFacing[self.facing][self.currentImg], self.udlrFacing_outline[self.facing][self.currentImg])
		self.previousArt = self.art

		#the directions the player is currently going
		self.udlr = [False, False, False, False]