def ShowMap(): """Рисует карту.""" curmap = GameMap[CurMap] Lowlevel.PrepareMap() for x in xrange(curmap.LocalMapLeft, curmap.LocalMapLeft + Const.LOCAL_MAP_WIDTH + 1): for y in xrange(curmap.LocalMapTop, curmap.LocalMapTop + Const.LOCAL_MAP_HEIGHT + 1): Lowlevel.ShowCell(curmap.Cells[x][y], x, y) # Хак. Monsters.ShowMonsters() Hero.ShowHero(Hero.CurHero) Lowlevel.main()
def ShowMap(): """Рисует карту.""" curmap = GameMap[CurMap] Lowlevel.PrepareMap() for x in xrange( curmap.LocalMapLeft, curmap.LocalMapLeft + Const.LOCAL_MAP_WIDTH + 1): for y in xrange(curmap.LocalMapTop, curmap.LocalMapTop + Const.LOCAL_MAP_HEIGHT + 1): Lowlevel.ShowCell(curmap.Cells[x][y], x, y) # Хак. Monsters.ShowMonsters() Hero.ShowHero(Hero.CurHero) Lowlevel.main()
def SetHeroVisible(HeroNum): hero = Heroes[HeroNum] curmap = Map.GameMap[Map.CurMap] for x in xrange(hero.x - hero.VisLong, hero.x + hero.VisLong + 1): for y in xrange(hero.y - hero.VisLong, hero.y + hero.VisLong + 1): curmap.Cells[x][y].IsVisible = True Lowlevel.ShowCell(curmap.Cells[x][y], x, y)
def MoveHero(dx, dy): hero = Hero.Heroes[Hero.CurHero] curmap = Map.GameMap[Map.CurMap] if not Map.FreeTile(curmap.Cells[hero.x + dx][hero.y + dy].Tile): return x, y = hero.x, hero.y hero.x += dx hero.y += dy Hero.SetHeroVisible(Hero.CurHero) Hero.CleaningUp(x, y) Monsters.ShowMonsters() Hero.ShowHero(Hero.CurHero) if (abs(hero.x - curmap.LocalMapLeft) < Map.SCROLL_DELTA) or \ (abs(hero.y - curmap.LocalMapTop) < Map.SCROLL_DELTA) or \ (abs(hero.x - (curmap.LocalMapLeft + Const.LOCAL_MAP_WIDTH)) < Map.SCROLL_DELTA) or \ (abs(hero.y - (curmap.LocalMapTop + Const.LOCAL_MAP_HEIGHT)) < Map.SCROLL_DELTA): Map.ScrollMap() Lowlevel.ShowHeroInfo(Hero.CurHero)
def CleaningUp(x, y): Lowlevel.CleaningUp(x, y)
def ShowHero(HeroNum): hero = Heroes[HeroNum] x, y = (Const.WINDOW_LEFT + hero.x, Const.WINDOW_TOP + hero.y) Lowlevel.ChangeTileSourceWithSavingPrevious(x, y, './resource/img/hero.png')
def ShowGame(): Lowlevel.ShowHeroInfo(Hero.CurHero) Map.ShowMap()
def main(): Lowlevel.VideoInitialize() Map.MapGeneration(1) Monsters.GenerateMonsters(Map.CurMap) Hero.InitHeroes() Game.ShowGame()
def ShowMonsters(): """Сканирует список монстров, определяет, какие из живых созданий находятся в видимой части окна, и выводит их на экран.""" for mns in Monsters: if (mns.HP > 0) and Map.VisiblePoint(mns.x, mns.y): Lowlevel.ShowMonster(mns)