Talk:Roguelike Tutorial, using python3+tdl
Jump to navigation
Jump to search
Worthwhile considering is a better condensed movement code using pythons dict.
using a simple constant
DIR = dict([('KP8', (0, -1)), ('KP2', (0, 1)), ('KP4', (-1, 0)), ('KP6', (1, 0)),
('KP7', (-1, -1)), ('KP9', (1, -1)), ('KP1', (-1, 1)), ('KP3', (1, 1)), ('KP5', (0, 0))])
you can change your player handling movement to
if key in DIR: (dx, dy) = DIR.get(key) #Do something with deltas player_attack_or_move(dx, dy)
instead of the giant block it currently is.