forked from pygamelib/pygamelib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_neighbors.py
36 lines (28 loc) · 889 Bytes
/
test_neighbors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from gamelib.Game import Game
from gamelib.Characters import Player
import gamelib.Sprites as Sprites
import gamelib.Utils as Utils
import gamelib.Constants as Constants
g = Game()
b = g.load_board('hac-maps/kneighbors.json',1)
g.player = Player(model=Sprites.FLYING_SAUCER,name='player')
g.change_level(1)
key = None
while True:
if key == 'w':
g.move_player(Constants.UP,1)
elif key == 's':
g.move_player(Constants.DOWN,1)
elif key == 'a':
g.move_player(Constants.LEFT,1)
elif key == 'd':
g.move_player(Constants.RIGHT,1)
elif key == 'q':
break
g.clear_screen()
g.display_board()
for i in g.neighbors(1):
print(f'Player: {i.name} ({i.pos[0]},{i.pos[1]})')
for i in g.neighbors(1, g.current_board().item(7,7) ):
print(f'NPC: {i.name} ({i.pos[0]},{i.pos[1]})')
key = Utils.get_key()