1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! This module contains the core components of the game logic, it includes the following sub-modules:
//!
//! - [`fruit`]: Represents the fruit element, including its position, score, and image.
//! - [`map`]: Manages the game logic map, layout, and boundaries.
//! - [`snake_body`]: Tracks and manages the snake's body and its movement.
/* Just to have some fun with moving letter
pub fn left(&mut self) {
let mut current: u16 = self.body[0].x;
self.body[0].x -= self.CASE_SIZE;
let mut previous: u16 = current;
for i in 1..self.body.len() {
current = self.body[i].x;
self.body[i].x = previous;
previous = current;
}
}
pub fn right(&mut self) {
let mut current: u16 = self.body[0].x;
self.body[0].x += self.CASE_SIZE;
let mut previous: u16 = current;
for i in 1..self.body.len() {
current = self.body[i].x;
self.body[i].x = previous;
previous = current;
}
}
pub fn up(&mut self) {
let mut current: u16 = self.body[0].y;
self.body[0].y -= self.CASE_SIZE / 2;
let mut previous: u16 = current;
for i in 1..self.body.len() {
current = self.body[i].y;
self.body[i].y = previous;
previous = current;
}
}
pub fn down(&mut self) {
let mut current: u16 = self.body[0].y;
self.body[0].y += self.CASE_SIZE / 2;
let mut previous: u16 = current;
for i in 1..self.body.len() {
current = self.body[i].y;
self.body[i].y = previous;
previous = current;
}
}
*/