예제 #1
0
def mainloop():
  while alive:
  
    for x in range(0,80):
        for y in range(0,20):
            c = gamemap[y][x]
            if c == "#":
                noteye.settextattr(4, 0)
            else:
                noteye.settextattr(8, 0)
            noteye.move(2+y, x)
            noteye.addstr(gamemap[y][x])
    
    noteye.move(2+player.y,player.x)
    noteye.settextattr(14, 0)
    noteye.addstr("@")
    
    for m in monsters:
        noteye.move(2+m.y, m.x)
        noteye.settextattr(13, 1)
        noteye.addstr(m.char)
  
    noteye.move(0,20)
    noteye.settextattr32(0x9090FF, 0)
    noteye.addstr("Sample Roguelike in Python!")
    
    ch = noteye.getch()
    
    if noteye.isdir(ch):
      dx,dy = noteye.dxy(ch)
      pcx = player.x + dx
      pcy = player.y + dy
      if findmonster(pcx, pcy):
          killmonster(pcx, pcy)
      elif gamemap[pcy][pcx] == "#":
          pass
      else:
          player.x = pcx
          player.y = pcy
      
      movemonsters()
      if random.random() < 0.1:
          newmonster()
    elif ch == ord("."):
      movemonsters()
      newmonster()
    elif ch == ord("q"):
      print("Exiting the game.")
      break
    elif ch >= 0 and ch < 256:
      print("Key pressed: character "+chr(ch))
    elif ch == noteye.NOTEYEERR:
      print("Reinitializing NotEye due to error")
      noteye.halt()
      noteye_initall()
    else:
      print("Other key pressed: "+str(ch))
예제 #2
0
          killmonster(pcx, pcy)
      elif gamemap[pcy][pcx] == "#":
          pass
      else:
          player.x = pcx
          player.y = pcy
      
      movemonsters()
      if random.random() < 0.1:
          newmonster()
    elif ch == ord("."):
      movemonsters()
      newmonster()
    elif ch == ord("q"):
      print("Exiting the game.")
      break
    elif ch >= 0 and ch < 256:
      print("Key pressed: character "+chr(ch))
    elif ch == noteye.NOTEYEERR:
      print("Reinitializing NotEye due to error")
      noteye.halt()
      noteye_initall()
    else:
      print("Other key pressed: "+str(ch))

noteye_initall()
mainloop()
noteye.finishinternal(1)
noteye.uifinish()
noteye.halt()