def onDraw(self, offset): ESG.getImage("grass").draw(offset.x + self.pos.x, offset.y + self.pos.y) if self.mode == 0: ESG.getImage("verticalfence").draw(offset.x + self.pos.x, offset.y + self.pos.y) if self.mode == 1: ESG.getImage("horizontalfence").draw(offset.x + self.pos.x, offset.y + self.pos.y) if self.mode == 2: ESG.getImage("verticalfence").draw(offset.x + self.pos.x, offset.y + self.pos.y) ESG.getImage("horizontalfence").draw(offset.x + self.pos.x, offset.y + self.pos.y)
def onUpdate(self): BaseController.onUpdate(self) if self.health <= 0: Systenm.exit(0) if Keyboard.isKeyDown(Keyboard.KEY_UP) and self.a and self.shit > 0: ESG.addEntity(AIThrownShit(Point(-(self.pos.x+4), -(self.pos.y+40)), 1, Point(0, -1))) self.a = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_UP) and not self.a: self.a = True if Keyboard.isKeyDown(Keyboard.KEY_DOWN) and self.b and self.shit > 0: ESG.addEntity(AIThrownShit(Point(-(self.pos.x+4), -(self.pos.y-40)), 1, Point(0, 1))) self.b = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_DOWN) and not self.b: self.b = True if Keyboard.isKeyDown(Keyboard.KEY_RIGHT) and self.c and self.shit > 0: ESG.addEntity(AIThrownShit(Point(-(self.pos.x-20), -(self.pos.y)), 1, Point(1, 0))) self.c = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_RIGHT) and not self.c: self.c = True if Keyboard.isKeyDown(Keyboard.KEY_LEFT) and self.d and self.shit > 0: ESG.addEntity(AIThrownShit(Point(-(self.pos.x+25), -(self.pos.y)), 1, Point(-1, 0))) self.d = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_LEFT) and not self.d: self.d = True
def onThink(self, ignoreme): self.ct = System.currentTimeMillis() if self.pos.pointEquals(self.dest): marg = ESG.randInt(0, 43) if marg == 42: ESG.entities.add(EntityShit(self.pos)) self.positions = [] self.directions = [] for i in range(0, 4): if i == 0: despos = Point(self.pos.x + 32, self.pos.y) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(1, 0)) if i == 1: despos = Point(self.pos.x - 32, self.pos.y) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(-1, 0)) if i == 2: despos = Point(self.pos.x, self.pos.y + 32) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(0, 1)) if i == 3: despos = Point(self.pos.x, self.pos.y - 32) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(0, -1)) if len(self.directions) >= 1: chosen = ESG.randInt(0, (len(self.directions) - 1)) self.dest = self.positions[chosen] self.direction = self.directions[chosen] else: self.dest = self.pos if self.ct - self.lt >= 25: newpos = Point(self.pos.x + (self.direction.x * self.speed), self.pos.y + (self.direction.y * self.speed)) self.lt = self.ct if ESG.navmesh.legalMove(self.pos, newpos): self.pos = newpos
def onThink(self, ignoreme): self.ct = System.currentTimeMillis() if self.pos.pointEquals(self.dest): marg = ESG.randInt(0, 43) if marg == 42: ESG.entities.add(EntityShit(self.pos)) self.positions = [] self.directions = [] for i in range(0, 4): if i == 0: despos = Point(self.pos.x+32, self.pos.y) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(1, 0)) if i == 1: despos = Point(self.pos.x-32, self.pos.y) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(-1, 0)) if i == 2: despos = Point(self.pos.x, self.pos.y+32) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(0, 1)) if i == 3: despos = Point(self.pos.x, self.pos.y-32) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(0, -1)) if len(self.directions) >= 1: chosen = ESG.randInt(0, (len(self.directions)-1)) self.dest = self.positions[chosen] self.direction = self.directions[chosen] else: self.dest = self.pos if self.ct - self.lt >= 25: newpos = Point(self.pos.x + (self.direction.x * self.speed), self.pos.y + (self.direction.y * self.speed)) self.lt = self.ct if ESG.navmesh.legalMove(self.pos, newpos): self.pos = newpos
def onUpdate(self): BaseController.onUpdate(self) if self.health <= 0: Systenm.exit(0) if Keyboard.isKeyDown(Keyboard.KEY_UP) and self.a and self.shit > 0: ESG.addEntity( AIThrownShit(Point(-(self.pos.x + 4), -(self.pos.y + 40)), 1, Point(0, -1))) self.a = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_UP) and not self.a: self.a = True if Keyboard.isKeyDown(Keyboard.KEY_DOWN) and self.b and self.shit > 0: ESG.addEntity( AIThrownShit(Point(-(self.pos.x + 4), -(self.pos.y - 40)), 1, Point(0, 1))) self.b = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_DOWN) and not self.b: self.b = True if Keyboard.isKeyDown(Keyboard.KEY_RIGHT) and self.c and self.shit > 0: ESG.addEntity( AIThrownShit(Point(-(self.pos.x - 20), -(self.pos.y)), 1, Point(1, 0))) self.c = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_RIGHT) and not self.c: self.c = True if Keyboard.isKeyDown(Keyboard.KEY_LEFT) and self.d and self.shit > 0: ESG.addEntity( AIThrownShit(Point(-(self.pos.x + 25), -(self.pos.y)), 1, Point(-1, 0))) self.d = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_LEFT) and not self.d: self.d = True
def onGUI(graphics): ESG.getImage("healthbar").draw(10, 10) i = 19 num = 0 while num < ESG.player.health: ESG.getImage("healthrect").draw(i, 18) i = i + 10 num = num + 1 ESG.getImage("bigshit").draw(10, 65) graphics.drawString("x " + str(ESG.player.shit), 52, 70) graphics.drawString("Player: x" + str(-ESG.player.pos.x) + " y" + str(-ESG.player.pos.y), 10, 100) arg = 130 for i in range(0, ESG.entities.size()): ent = ESG.entities.get(i) if ent.name == "evilsheep": graphics.drawString("evilsheep: x" + str(ESG.entities.get(i).pos.x) + " y" + str(ESG.entities.get(i).pos.y), 10, arg) arg = arg + 30
def onGUI(graphics): ESG.getImage("healthbar").draw(10, 10) i = 19 num = 0 while num < ESG.player.health: ESG.getImage("healthrect").draw(i, 18) i = i + 10 num = num + 1 ESG.getImage("bigshit").draw(10, 65) graphics.drawString("x " + str(ESG.player.shit), 52, 70) graphics.drawString( "Player: x" + str(-ESG.player.pos.x) + " y" + str(-ESG.player.pos.y), 10, 100) arg = 130 for i in range(0, ESG.entities.size()): ent = ESG.entities.get(i) if ent.name == "evilsheep": graphics.drawString( "evilsheep: x" + str(ESG.entities.get(i).pos.x) + " y" + str(ESG.entities.get(i).pos.y), 10, arg) arg = arg + 30
Point(1, 0))) self.c = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_RIGHT) and not self.c: self.c = True if Keyboard.isKeyDown(Keyboard.KEY_LEFT) and self.d and self.shit > 0: ESG.addEntity( AIThrownShit(Point(-(self.pos.x + 25), -(self.pos.y)), 1, Point(-1, 0))) self.d = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_LEFT) and not self.d: self.d = True ESG.setImage("healthbar", "resources/images/healthbar.png") ESG.setImage("healthrect", "resources/images/healthrect.png") ESG.setImage("grass", "resources/images/grass.png") ESG.setImage("void", "resources/images/void.png") ESG.setImage("happysheep", "resources/images/happysheep.png") ESG.setImage("player", "resources/images/farmer.png") ESG.setImage("shit", "resources/images/shit.png") ESG.setImage("bigshit", "resources/images/bigshit.png") ESG.setImage("evilsheep", "resources/images/angrysheep.png") ESG.setImage("corpse", "resources/images/corpse.png") ESG.setImage("verticalfence", "resources/images/verticalfence.png") ESG.setImage("horizontalfence", "resources/images/horizontalfence.png") ESG.setPlayer(Player(Point(-64, -64), 1)) ESG.addEntity(AIHappySheep(Point(-128, -128)))
def onDraw(self): ESG.getImage("player").draw((400-32), (300-32))
def onDraw(self, offset): ESG.getImage("evilsheep").draw(offset.x + (self.pos.x-8), offset.y + (self.pos.y-32))
def onDraw(self, offset): ESG.getImage("evilsheep").draw(offset.x + (self.pos.x - 8), offset.y + (self.pos.y - 32))
def onDraw(self): ESG.getImage("player").draw((400 - 32), (300 - 32))
def onThink(self, ignoreme): self.ct = System.currentTimeMillis() for i in range(0, ESG.entities.size()): ent = ESG.entities.get(i) if ent.name == "happysheep": if (System.currentTimeMillis() - self.lastHit) >= 1000: if ent.pos.inRange(2, self.pos): self.lastHit = System.currentTimeMillis() ESG.entities.get(i).destroy = True ESG.entities.add(AIEvilSheep(ent.pos, [Point(0, 0)])) ppos = Point(-ESG.player.pos.x, -ESG.player.pos.y) if ppos.inRange(32, Point(self.pos.x + 16, self.pos.y + 16)): if (System.currentTimeMillis() - self.lastHit) >= 1000: self.lastHit = System.currentTimeMillis() ESG.player.onDamage(1) if self.pos.pointEquals(self.dest): if len(self.positions) - 1 >= self.cdest: self.dest = self.positions[self.cdest] self.direction = Point(0, 0) if self.dest.x > self.pos.x: self.direction = Point(1, self.direction.y) elif self.dest.x < self.pos.x: self.direction = Point(-1, self.direction.y) else: self.direction = Point(0, self.direction.y) if self.dest.y > self.pos.y: self.direction = Point(self.direction.x, 1) elif self.dest.y < self.pos.y: self.direction = Point(self.direction.x, -1) else: self.direction = Point(self.direction.x, 0) self.cdest = self.cdest + 1 else: self.positions = [] self.directions = [] self.cdest = 0 for i in range(0, 4): if i == 0: despos = Point(self.pos.x + 32, self.pos.y) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(1, 0)) if i == 1: despos = Point(self.pos.x - 32, self.pos.y) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(-1, 0)) if i == 2: despos = Point(self.pos.x, self.pos.y + 32) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(0, 1)) if i == 3: despos = Point(self.pos.x, self.pos.y - 32) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(0, -1)) if len(self.directions) >= 1: chosen = ESG.randInt(0, (len(self.directions) - 1)) self.dest = self.positions[chosen] self.direction = self.directions[chosen] else: self.dest = self.pos if self.ct - self.lt >= 25: self.direction = Point(0, 0) if self.dest.x > self.pos.x: self.direction = Point(1, self.direction.y) elif self.dest.x < self.pos.x: self.direction = Point(-1, self.direction.y) else: self.direction = Point(0, self.direction.y) if self.dest.y > self.pos.y: self.direction = Point(self.direction.x, 1) elif self.dest.y < self.pos.y: self.direction = Point(self.direction.x, -1) else: self.direction = Point(self.direction.x, 0) newpos = Point(self.pos.x + (self.direction.x * self.speed), self.pos.y + (self.direction.y * self.speed)) self.lt = self.ct if ESG.navmesh.legalMove(self.pos, newpos): self.pos = newpos
def onDraw(self, offset): ESG.getImage("void").draw(offset.x + self.pos.x, offset.y + self.pos.y)
def onThink(self, ignoreme): self.ct = System.currentTimeMillis() for i in range(0, ESG.entities.size()): ent = ESG.entities.get(i) if ent.name == "happysheep": if (System.currentTimeMillis() - self.lastHit) >= 1000: if ent.pos.inRange(2, self.pos): self.lastHit = System.currentTimeMillis() ESG.entities.get(i).destroy = True ESG.entities.add(AIEvilSheep(ent.pos, [Point(0, 0)])) ppos = Point(-ESG.player.pos.x, -ESG.player.pos.y) if ppos.inRange(32, Point(self.pos.x+16, self.pos.y+16)): if (System.currentTimeMillis() - self.lastHit) >= 1000: self.lastHit = System.currentTimeMillis() ESG.player.onDamage(1) if self.pos.pointEquals(self.dest): if len(self.positions)-1 >= self.cdest: self.dest = self.positions[self.cdest] self.direction = Point(0, 0) if self.dest.x > self.pos.x: self.direction = Point(1, self.direction.y) elif self.dest.x < self.pos.x: self.direction = Point(-1, self.direction.y) else: self.direction = Point(0, self.direction.y) if self.dest.y > self.pos.y: self.direction = Point(self.direction.x, 1) elif self.dest.y < self.pos.y: self.direction = Point(self.direction.x, -1) else: self.direction = Point(self.direction.x, 0) self.cdest = self.cdest + 1 else: self.positions = [] self.directions = [] self.cdest = 0 for i in range(0, 4): if i == 0: despos = Point(self.pos.x+32, self.pos.y) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(1, 0)) if i == 1: despos = Point(self.pos.x-32, self.pos.y) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(-1, 0)) if i == 2: despos = Point(self.pos.x, self.pos.y+32) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(0, 1)) if i == 3: despos = Point(self.pos.x, self.pos.y-32) if ESG.navmesh.legalMove(self.pos, despos): self.positions.append(despos) self.directions.append(Point(0, -1)) if len(self.directions) >= 1: chosen = ESG.randInt(0, (len(self.directions)-1)) self.dest = self.positions[chosen] self.direction = self.directions[chosen] else: self.dest = self.pos if self.ct - self.lt >= 25: self.direction = Point(0, 0) if self.dest.x > self.pos.x: self.direction = Point(1, self.direction.y) elif self.dest.x < self.pos.x: self.direction = Point(-1, self.direction.y) else: self.direction = Point(0, self.direction.y) if self.dest.y > self.pos.y: self.direction = Point(self.direction.x, 1) elif self.dest.y < self.pos.y: self.direction = Point(self.direction.x, -1) else: self.direction = Point(self.direction.x, 0) newpos = Point(self.pos.x + (self.direction.x * self.speed), self.pos.y + (self.direction.y * self.speed)) self.lt = self.ct if ESG.navmesh.legalMove(self.pos, newpos): self.pos = newpos
def onDraw(self, offset): ESG.getImage("shit").draw(offset.x + (self.pos.x-8), offset.y + (self.pos.y-8))
def onDraw(self, offset): ESG.getImage("shit").draw(offset.x + (self.pos.x - 8), offset.y + (self.pos.y - 8))
if not Keyboard.isKeyDown(Keyboard.KEY_DOWN) and not self.b: self.b = True if Keyboard.isKeyDown(Keyboard.KEY_RIGHT) and self.c and self.shit > 0: ESG.addEntity(AIThrownShit(Point(-(self.pos.x-20), -(self.pos.y)), 1, Point(1, 0))) self.c = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_RIGHT) and not self.c: self.c = True if Keyboard.isKeyDown(Keyboard.KEY_LEFT) and self.d and self.shit > 0: ESG.addEntity(AIThrownShit(Point(-(self.pos.x+25), -(self.pos.y)), 1, Point(-1, 0))) self.d = False self.shit = self.shit - 1 if not Keyboard.isKeyDown(Keyboard.KEY_LEFT) and not self.d: self.d = True ESG.setImage("healthbar", "resources/images/healthbar.png") ESG.setImage("healthrect", "resources/images/healthrect.png") ESG.setImage("grass", "resources/images/grass.png") ESG.setImage("void", "resources/images/void.png") ESG.setImage("happysheep", "resources/images/happysheep.png") ESG.setImage("player", "resources/images/farmer.png") ESG.setImage("shit", "resources/images/shit.png") ESG.setImage("bigshit", "resources/images/bigshit.png") ESG.setImage("evilsheep", "resources/images/angrysheep.png") ESG.setImage("corpse", "resources/images/corpse.png") ESG.setImage("verticalfence", "resources/images/verticalfence.png") ESG.setImage("horizontalfence", "resources/images/horizontalfence.png") ESG.setPlayer(Player(Point(-64, -64), 1)) ESG.addEntity(AIHappySheep(Point(-128, -128)))