Hello, I have just started a snake game project for my class, however I’m a little confused with partial arrays in the sense that I am unsure about how to make it start in the top middle of the canvas, I am just confused as to how to make the array start in that place. Here is my code, I would really appreciate some help
final int ROWS=20, COLS=15, SQ_SIZE=40, DIAMETER = 20;
final int MAX_SIZE = 70;
/*state variables go here*/
int currentLength = 0;
//if debugging is needed, switch the place of this variable.
int startingLength;
/*global array variables go here*/
int [] currentHeadX = new int[MAX_SIZE];
int [] currentHeadY = new int[MAX_SIZE];
//will store up to the maximum circles that can fit in the canvas circles.
//int [] currentYPosition = new int[MAX_SIZE];
//Also known as the "size" variable.
void setup(){
//20*40, 15*40
size(800,600);
//controls the length of the snake at the start of each level, if debugging is needed, switch the place of this
}
void draw(){
resetSnake();
}
/*draws the circles that form the snake*/
void drawCircles(int[] x, int[] y, int n, int colour){
for(int i=0; i<n; i++){
fill(colour);
ellipse(x[i],y[i],DIAMETER,DIAMETER);
}
}
/*fills the array with data*/
void fillArray(int[] a, int n, int start, int delta){
for(int i=0; i<n; i++){
a[i] = start+(delta*i);
}
}
/*resets the snake in the proper position*/
void resetSnake(){
startingLength=5;
//starting length is 5
currentLength = startingLength;
//sets the starting length to the current length.
for(int i=0; i<currentLength;i++){
fillArray(currentHeadX,currentLength*i,startingLength,5);
//where im confused, need the snake to start in the middle of the canvas, and go down vertically.
fillArray(currentHeadY,currentLength*i,startingLength,5);
drawCircles(currentHeadX,currentHeadY,5,#FFFF00);
//draws the snake.
}
}