instead of writing things like this
if event == E_LEFT {
player.x += 10
} else if event == E_RIGHT {
player.x -= 10
} else if .... {
...
}
split it up into "decide what to do" and "do the thing", and don't overwrite the current state until you're done, either:
if event == E_LEFT {
action = ACTION_MOVE_LEFT
} else if ... {
....
}
var player_next = player
if action == ACTION_MOVE_LEFT {
player_next.x += 10
} else if .... {
...
}
player = player_next
why?
