osso73 / classic_games

A series of classic games in Kivy
MIT License
3 stars 1 forks source link

Transform GameBoard to a grid #45

Closed osso73 closed 3 years ago

osso73 commented 3 years ago

The GameBoard is a square grid of n x n. The position of objects there is defined by 2 coordinates, that the class will transform to pixels. This simplifies the moves of snake, and makes it easier to position walls, food and other objects.

Size can be dependent on the screen size. The grid has a predefined number of positions: n x n. Eventually, n can be chosen to be different values.

osso73 commented 3 years ago

Done. Added methods to transform grid to size, and operate everything using the grid. Grid is not n x n, but it is calculated based on the screen size, assuming the smaller size (e.g. width or height) will be 10 units of grid. The larger side grid will be calculated based on this unit and the size of the screen. So grid will be n x m.

Reorganized the screen to center the game board in the middle of the available space.