File tree Expand file tree Collapse file tree 1 file changed +16
-26
lines changed
Expand file tree Collapse file tree 1 file changed +16
-26
lines changed Original file line number Diff line number Diff line change @@ -10,33 +10,23 @@ public enum SnakeMove {
1010 /**
1111 * Offset to apply to the body piece when the snake moves
1212 **/
13- UP ,
14- DOWN ,
15- LEFT ,
16- RIGHT ;
13+ UP ( 0 , + 10 ) ,
14+ DOWN ( 0 , - 10 ) ,
15+ LEFT ( + 10 , 0 ) ,
16+ RIGHT ( - 10 , 0 ) ;
1717
18- private final byte OFFSET = 10 ;
18+ private SnakeMove (int offsetX , int offsetY ) {
19+ this . offsetX = (byte ) offsetX;
20+ this . offsetY = (byte ) offsetY;
21+ }
1922
20- /**
21- * Get the offset to apply to the body piece when the snake moves
22- * @return byte[] - Offset to apply to the body piece when the snake moves
23- **/
24- public byte [] getOffset () {
25- byte [] result = {};
26- switch (this ) {
27- case UP :
28- result = new byte []{0 , + OFFSET };
29- break ;
30- case DOWN :
31- result = new byte []{0 , - OFFSET };
32- break ;
33- case LEFT :
34- result = new byte []{+ OFFSET , 0 };
35- break ;
36- case RIGHT :
37- result = new byte []{- OFFSET , 0 };
38- break ;
39- }
40- return result;
23+ private byte offsetX, offsetY;
24+
25+ public byte getOffsetX () {
26+ return offsetX;
27+ }
28+
29+ public byte getOffsetY () {
30+ return offsetY;
4131 }
4232}
You can’t perform that action at this time.
0 commit comments