For your question, the answer is NO. Your version is the most simple one. If it is relating to making it meaningful or more documented, you can try something like:
//checkDirection returns the direction for the key pressed: 'up', 'down', 'left', 'right'. Any other return variable (nil) will not result in any action. direction :=checkDirection(rl) switch direction { case 'left': p.Rect.X -= 1 ..... } =============================================================== On Wednesday, May 1, 2019 at 6:08:10 PM UTC+5:30, гусь wrote: > > if rl.IsKeyDown(rl.KeyA) { > p.Rect.X -= 1 > } > if rl.IsKeyDown(rl.KeyD) { > p.Rect.X += 1 > } > if rl.IsKeyDown(rl.KeyW) { > p.Rect.Y -= 1 > } > if rl.IsKeyDown(rl.KeyS) { > p.Rect.Y += 1 > } > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.