Try and keep px+py integers, so force dx+dy to be integers as well