When working in a business environment, I really canβt get the code or use the old console. My work is repeated and therefore not very complicated.
I decided to challenge myself by writing a snake game on the C # console; and the boy did it so that my brain would work. I never had to think about it so much day by day, but I felt that my programming skills were not improving.
I have a problem. The main approach I took is to create a snake class and a food class. The snake class uses an array to store all coordinates, and then the drawing class decides which coordinates to draw on the screen.
The problem is that when moving the snake, the array is filled (maxsize is 250 for performance), so when I get to the end of the array, I want to copy the last few coordinates to the temp array, reset the original array and copy the time coordinates back to the main array.
The problem I have is copying the x coordinates back to the original array. I decided to do it manually to check, but this decision always makes my poor snake leave behind one of its segments on the screen when it should not be.
How will I do this programmatically?
spoints[4, 0] = stemp[249, 0]; spoints[4, 1] = stemp[249, 1]; spoints[4, 2] = stemp[249, 2]; spoints[3, 0] = stemp[248, 0]; spoints[3, 1] = stemp[248, 1]; spoints[3, 2] = stemp[248, 2]; spoints[2, 0] = stemp[247, 0]; spoints[2, 1] = stemp[247, 1]; spoints[2, 2] = stemp[247, 2]; spoints[1, 0] = stemp[246, 0]; spoints[1, 1] = stemp[246, 1]; spoints[1, 2] = stemp[246, 2]; spoints[0, 0] = stemp[245, 0]; spoints[0, 1] = stemp[245, 1]; spoints[0, 2] = stemp[245, 2];
I really don't mind posting the whole game here if someone really wants to delve into the code.