gobadge icon indicating copy to clipboard operation
gobadge copied to clipboard

Use point struct as position

Open didiermichel opened this issue 2 years ago • 4 comments

This PR intend is to improve code readability. I introduce Point type that handle x and y value for an element (snake body, apple)

I hope it does bring more readability to the code.

didiermichel avatar Oct 28 '22 17:10 didiermichel

Note: code compiles, but I still need to flash and validate everything is still fine.

didiermichel avatar Oct 28 '22 17:10 didiermichel

Wouldn't it be better to use image.Point for this? https://pkg.go.dev/image#Point

deadprogram avatar Oct 28 '22 17:10 deadprogram

At the time I wrote the original code (many years ago :rofl: ), image.Point was causing some compilation errors, that should have been fixed by now, but, image.Point uses int instead of int16 (used by the display coords), casting will be needed in many places and in my opinion it will make readability worse. I vote for maintaining custom Point Struct instead of image.Point.

conejoninja avatar Oct 28 '22 17:10 conejoninja

I cannot say I had thought this through as I didn't know about image.Point 😆

didiermichel avatar Oct 28 '22 21:10 didiermichel