[A83] Re: nibbles / snake
[Prev][Next][Index][Thread]
[A83] Re: nibbles / snake
> I'm going to make my own nibbles/snake clone. But I got
> a lot of questions for that:
>
> 1) where does the game remember where the snake is currently?
> 2) How should I clear the end of the snake?
> 3) Do I use a collision detection routine to check
> if the snake touches an apple?
> 4) How do I detect when the snake hits itself or the wall?
> 5) How can I make those levels like in nibbles by Bill
> Nagel, and how do I check if the snake hits those
> extra walls? (is it the same as 4)??)
>
> Don't give me immediately z80, but just the basic ideas,
> if you mind. I myself AM able to do some z80 asm, only
> these questions bother me. Perhaps there are more things
> I do not know, but those are for later...
I'd use a data table of all the coordinates (x and y coordinates). The
first pair in the table might be the apple. Next you have a section
containing all the coords to build the level. And then the snake (the
snake can grow, so you must not put data after it).
Rebuilding a screen goes like this then. You move the snake coords
upwards in memory and add a new coord in the beginning depending on
the direction of the snake. Next you clear the screen buffer, pick the
first coord pair in the table and draw it, second one, and so on.
(Notice that you have to keep track of how long the table is.) A
fastCopy and everything's in place.
To check if the snake hits something, you just pick the coords of the
snake's head, and compare that to all the other coords in the table
(so both level and snake). If it equals, game over. Of course, in case
of the apple, you just increase score, generate new apple, and
everything else that's necessary.
Good luck, you'll have your hands full with this one I believe.
Tijl Coosemans
Follow-Ups:
References: