def setheight(self, h=0): self.z = terrain.height(self.x, self.y) + h
def rendershadow(self, screen): px, py = camera.screenpos(self.x, self.y, terrain.height(self.x, self.y)) pygame.draw.ellipse(screen, (20, 20, 20, 100), (px - 4, py - 2, 8, 4))
def lookatme(self): camera.lookat(self.x, self.y, terrain.height(self.x, self.y))
def trackme(self): camera.track(self.x, self.y, terrain.height(self.x, self.y), settings.trackvalue)
def __init__(self, x, y, z=None): self.vx, self.vy = 0, 0 self.x, self.y = terrain.toCenterRender(x, y) self.z = terrain.height(self.x, self.y) if z is None else z self.alive = True self.hp = self.hp0
if cursorpos is not None: cx, cy, s = cursorpos for a in range(s): for b in range(s): highlighttile(screen, cx-a+b, cy-a-b) drawfadinggrid(screen, cx, cy) esort = sorted(entities, key = lambda e: -e.y) for entity in esort: entity.render(screen) if __name__ == "__main__": import pygame from pygame import * screen = display.set_mode((800, 600)) display.set_caption("Don't worry, the real game will be much faster at this.") for y in range(600): for x in range(800): h = terrain.height(x, y) c = hcolor(h) screen.set_at((x, y), c) draw.rect(screen, (255, 255, 255), (100, 100, 20, 30), 1) pygame.display.flip() if any(event.type in (KEYDOWN, QUIT) for event in pygame.event.get()): exit() while not any(event.type in (KEYDOWN, QUIT) for event in pygame.event.get()): pass image.save(screen, "map-example.png")