So, I created a snake game for the 89 but I'm having difficulty actually killing the snake. If the snake runs into the boundaries it just says Error: Dimentions and breaks the program. I could probably fix the problems but I want to make it faster and more optimized but unfortunately I do not have a model for that. Does anybody know or have seen a loop that can fix that?
Well, I've tried building snake before and knew before starting that it would fail. When you build a programme with Basic don't expect anything to go quickly. It's a mathematical language so it's takes a while to make all the calculations. Once I finished the programme, it advanced one pixel per three quarters of a second. It's would go faster if you drawed the thing on paper and made it flip.
But to help you, here is what I did (and it worked). So that the snake can collide with itself, create a list of it's past whereabouts. And each time it takes a step, augment the list with the new coordinates and remove the last ones. I used a mid(List, 2, length) to remove the tail. And so that it hits the wall or crosses over to the other side (witch some snake games have) use an "If" the head reaches the side of the screen, "stop". Hope that helps.
You can make basic snake games that go incredibly quickly if you know the right tricks.
Creating a radial list is a very efficient way to make a snake game. Basically you create a list that runs in a circle. That way instead of shifting the continents of the list, you only have to shift the location to where you are reading and writing from.
Using traditional lists, this can be accomplished by having the pointer wrap around to the beginning of regular linear lists, so it behaves like a radial list.
Well, that is something that I don't know. What is a radial list and how can do you use it? And if you have a link that you could give me I would also appreciate.
I'm not sure about radial lists, but the way you mentioned is pretty efficient. Augment the list to put the new position in the first element (and turn that point on), and if they didn't get an "apple", truncate the list to remove the last element (and then turn off that location) (and if they did get it don't do anything). To check if they hit any part of the snake just check to see if the head has the same coordinates as any other part.
You can also basically integrate wall-detection into colliding with the rest of the snake. When you move, put the new position into a secondary variable and check to see if it's off the screen. If it isn't, store it back into your position variable, otherwise just store the old location. This works since there will be a repeat of the current location in the list, so they would lose. This saves you from having to add code to jump/quit/execute/etc. to the 'lose' code after checking to see if they hit themselves and after seeing if they hit a wall.
you could do a simple pxl test to find if the next location is taken up. That way you make the screen have a border.
And radial lists are significantly faster than augmenting lists every frame. And they do not slow down as your snake grows.
EDIT: I just realized I'm in the 68K forum, so what i say might not hold :/