I have some homework for my school and I have to make a snake game, like Nokia’s, in Delphi. I wonder which solution is the best. I want my snake be a class and the body is an array of points (parent class) or a linked list of points. What’s the best? An array or a linked list?
Share
A Linked list is better. (Each node can point to the previous and next node) It is easier to add nodes to the end of a linked list.
If you use an array you would either need to resize it or initialise it to the Maximum possible snake length to start with which can be wasteful on memory.
UPDATE
This article talks about pointers in Delph and even suggests a simple Node definition delphi article