Computer Science Canada snake game - the body (part 2) |
Author: | xHoly-Divinity [ Wed Jan 05, 2005 3:32 pm ] | ||
Post subject: | snake game - the body (part 2) | ||
In my code, the snake's body does not fully disappear when he moves. I was wondering if anyone can give me a hand. Thank you.
|
Author: | Neo [ Wed Jan 05, 2005 4:50 pm ] |
Post subject: | |
I looked briefly at your code, and from what I can see, you are using a white line that trails the green line to erase the trail. It works fine if you go in a straight line but your problem is when turning. When your turning, say you are moveing east and then turn north, the white line that was supposed to erase the green line horizontally doesnt get to finish erasing because you turned and so the horizintal white line dissapears and you start drawing a vertical white line to erase the trail vertically. You follow? To fix it let the white line run a little bit longer, after you make a change in direction, so that it will erase the bit of green that was left behind after the turn. |
Author: | xHoly-Divinity [ Wed Jan 05, 2005 4:59 pm ] |
Post subject: | |
This can work, however, once I successfully manage to fix it, I want to extend the length of the snake, so every time the amount of time the white line would have to run would be longer. Is there not an easier way? I would really appreciate it if someone could just fill in the lines they think I'm missing (you will be credited of course!). Thank you |
Author: | Neo [ Wed Jan 05, 2005 5:09 pm ] |
Post subject: | |
Well your method of drawing the snake is not very effective. I think you need a new technique. I've never made a snake game but if i were to do so, I think I would make the snake out of a series of squares and put their coords in an array. Every time a snake eats a food add a square to the end of the snake. Or something similar. |
Author: | Cervantes [ Wed Jan 05, 2005 5:19 pm ] |
Post subject: | |
You're code is.. less than ideal. For a snake game, you will probably want to use arrays to store the position of each segment of the snake, and have a variable to store the current direction of the snake. I suggest you read up on arrays once or twice to get the handle of them, if you aren't good with them already, and then recode your program and ask questions along the way. EDIT: wow, four posts while I was typing that. ![]() |
Author: | xHoly-Divinity [ Wed Jan 05, 2005 6:16 pm ] |
Post subject: | |
I was hoping that perhaps I could keep the same code... however, if it is absolutely impossible to do it using my code, then i will have to change it.... |
Author: | Cervantes [ Wed Jan 05, 2005 6:22 pm ] |
Post subject: | |
I highly suggest you do. Using whatdotcolour with Snake is a nono. Only Andy is allowed to do that ![]() |
Author: | xHoly-Divinity [ Wed Jan 05, 2005 6:40 pm ] | ||
Post subject: | |||
I've fixed that problem (sort of). If you press lets say up, then after 5 secs you press left then it works fine. However, if you move to another direction before the thing is finished erasing, then there is a problem (if you don't understand what i'm talking about, test the game and i'm sure you will identify it). So, as you can see, I have made an attempt at fixing the problem and have successfuly done so to a certain extent (which comes to prove that the code can work). Please, if you could elaborate on what I have so far to make it flawless then I would forever be in your debt. Thank you.
|
Author: | Cervantes [ Wed Jan 05, 2005 7:22 pm ] |
Post subject: | |
I'm telling you, learning to use arrays will make your life easier. I find people are often afraid of learning new things. It's common, but not really understandable. Delve in! There will be plenty of assistance for you when you have your questions ![]() |
Author: | xHoly-Divinity [ Wed Jan 05, 2005 7:54 pm ] |
Post subject: | |
THat's not the problem, it's that I really dun want to write a brand new code ![]() |
: |