Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
ludwik
· 10mo ago · 0 comments
Shouldn't the code say:
position = (position + direction + 1) % 12;
Or have I misunderstood something?
Comments
[–]
LiamPowell
10mo ago
The +12 is to keep the number positive. The direction contains the movement so a +1 wouldn't make sense.
[–]
nulptr
10mo ago
The +12 there is so that % works correctly (ie the number never becomes negative)