def __init__(self, screenScale, scl): self.spriteLocation = r"Images\Maps\LittleRootTown\TrainerHouseUpstairs.png" self.gridpos = p5.Vector(4, 4) self.bannedList = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (6, 0), (8, 0), (8, 1), (7, 0), (6, 1), (5, 0), (4, 1), (5, 1), (3, 1), (2, 1), (1, 1), (0, 1), (1, 5)] self.bannedfromDown = [] self.bannedfromUp = [] self.bannedfromRight = [] self.bannedfromLeft = [] self.extraSprite = p5.load_image( r"Images\Maps\LittleRootTown\TrainerHouseUpstairsExtraSprites.png") self.extraActiveCoords = [(1, 4)] self.DoorCoords = [(7, 1)] self.DoorDestination = [LittlerootTrainerBot] super().__init__(screenScale, scl)
def drawProjectionLine(self,line): p5.stroke(255,0,0) p5.fill(255,0,0) if line.p1.x!=line.p2.x: #not a vertical line posfromLine=self.pos-line.p1 multiplier=(posfromLine.dot(line.Vector))/(abs(line.Vector)**2) proj=line.Vector*multiplier closestPoint=proj+line.p1 if closestPoint.x>line.p1.x and closestPoint.x<line.p2.x: p5.circle((closestPoint),10) p5.line((closestPoint),(self.pos)) elif closestPoint.x<line.p1.x: p5.circle((line.p1),10) p5.line((line.p1),(self.pos)) elif closestPoint.x>line.p2.x: p5.circle((line.p2),10) p5.line((line.p2),(self.pos)) else: #a vertical line #print("Vertical") closestPoint=p5.Vector(line.p1.x,self.pos.y) if closestPoint.y>line.p1.y and closestPoint.y<line.p2.y: p5.circle((closestPoint),10) p5.line((closestPoint),(self.pos)) elif closestPoint.y<line.p1.y: p5.circle((line.p1),10) p5.line((line.p1),(self.pos)) elif closestPoint.y>line.p2.y: p5.circle((line.p2),10) p5.line((line.p2),(self.pos))
def __init__(self, x, y, w, h): self.pos = p5.Vector(x, y) self.width = w self.height = h
def __init__(self, scl): self.pos = p5.Vector(0, 0) self.vel = p5.Vector(1, 0) self.scl = scl self.length = 0 self.tail = []
def __init__(self, x, y): self.pos = p5.Vector(x, y) #self.vel=p5.Vector(1,-1) self.vel = p5.Vector.random_2D()
def make_fire(self): f = p.Vector(self.pos.x + 15, self.pos.y) return f
def __init__(self,p1,p2): if p1[0]<p2[0]: #p1 is the left most self.p1=p5.Vector(p1[0],p1[1]) self.p2=p5.Vector(p2[0],p2[1]) self.Vector=p5.Vector(p2[0]-p1[0],p2[1]-p1[1]) elif p1[0]>p2[0]: #p2 is the left most #will swap the points so p1 is the left most self.p1=p5.Vector(p2[0],p2[1]) self.p2=p5.Vector(p1[0],p1[1]) self.Vector=p5.Vector(p1[0]-p2[0],p1[1]-p2[1]) else: #if vertical p1 will always be the higher point if p1[1]<p2[1]: self.p1=p5.Vector(p1[0],p1[1]) self.p2=p5.Vector(p2[0],p2[1]) self.Vector=p5.Vector(p2[0]-p1[0],p2[1]-p1[1]) elif p1[1]>p1[1]: self.p1=p5.Vector(p2[0],p2[1]) self.p2=p5.Vector(p1[0],p1[1]) self.Vector=p5.Vector(p1[0]-p2[0],p1[1]-p2[1]) else: raise ValueError("Invalid Line")
def __init__(self,x,y,r): self.pos=p5.Vector(0,0) self.r=r
def followMouse(self): self.pos=p5.Vector(mouse_x,mouse_y)