Computer Science Canada I Need Help For My School Project !! Urgent!!! |
Author: | kingkillar [ Wed Jan 05, 2011 11:25 am ] |
Post subject: | I Need Help For My School Project !! Urgent!!! |
I'm Doing this Turing Projct in my school. I need Help Making a Snake Game theat can eat "ball" and grow tail. the tails r suppose to represent ball. each time the snake eats the ball the ball should relocate and the snake shud grow another ball on its tail. I'm suppose to use array program, but i do not no how it workks . Plzzz Help me.. This is all i've got. %Set Screen View.Set ("offscreenonly") %Variables var x1, y1 : int := 0 var KEY : string (1) var x3 : flexible array 1 .. 9999999 of int var y3 : flexible array 1 .. 9999999 of int const R : int := 7 var x2 : int var y2 : int x2 := maxx div 2 y2 := maxy div 2 var a, b : int var i : int := 4 %new x3, 4 %new y3, 4 loop %drawfillbox (0, 0, maxx, maxy, 0) drawfilloval (x2, y2, R, R, red) delay (10) View.Update () drawfilloval (x2, y2, R, R, 0) %The Backround for x : 1 .. 4 y3 (x) := y2 x3 (x) := x2 - 10 i -= 1 end for for x : 2 .. 4 drawfilloval (x3 (x), y3 (x), 5, 5, 7) x3 (x) := x3 (x - 1) y3 (x) := y3 (x - 1) x3 (1) += 10 y3 (1) += 10 end for % Control Keys%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if hasch then getch (KEY) if KEY = "w" then y1 := 1 x1 := 0 elsif KEY = "a" then y1 := 0 x1 := -1 elsif KEY = "s" then y1 := -1 x1 := 0 elsif KEY = "d" then y1 := 0 x1 := 1 end if KEY := "" end if x2 := x2 + x1 y2 := y2 + y1 %The Wall %Left Line Draw.ThickLine (1, 1, 1, 400, 20, 13) %Right Line Draw.ThickLine (640, 1, 640, 400, 20, 13) %Top Line Draw.ThickLine (1, 400, 640, 400, 20, 13) %Bottom Line Draw.ThickLine (1, 1, 640, 1, 20, 13) delay (10) end loop |
Author: | Tony [ Wed Jan 05, 2011 11:33 am ] |
Post subject: | RE:I Need Help For My School Project !! Urgent!!! |
we have tutorials on arrays and other parts you might need linked to from The Turing Walkthrough |
Author: | kingkillar [ Wed Jan 05, 2011 11:51 am ] |
Post subject: | Re: RE:I Need Help For My School Project !! Urgent!!! |
but i do no know hot to use the array. I've look at tutorials but i need more help. I want to know if the snake were to eat a ball, and then..how do i relocate the position of the ball, and how do i make the snake add one more ball to its tale? i need help, if some can can give me a sample, or some code that is related to this snake game that'd be great!! It's such a hard game! But its Due real soon!! Here's What My Game is About: Snake Game This game is basically about a line (which represents the snake) will eat these balls (represents insects) and each time it eats them, it?ll get bigger. Minimum Requirements: The snake can collide with the wall. The snake can also collide with its own tail. These will be the controls for the snake game: ?W? is to go up ?S? is to go down ?A? is to go left ?D? is to go right Additions 1. Making levels from 1-5 2. Set your own speed 3. Choose your own level 4. Each level gain more speed 5. Each level the insect will be worth double the normal insects 6. Levels will contain mazes, if the snake hits it, then game over 7. Insects represents points, 1 insect = 5 points. 8. Make a nice background 9. Make the snake able to go through walls in a separate level, different from level 1-5. (E.g. go through right side and come from left, go through top and come from bottom) 10. Make a snake with 2 heads so that it can move with both the head or the tail 11. Make ?pin 10? is to go up, ?pin 12: is to go down, ?pin 13? is to go left, ?pin 15? is to go right, And I might make ?pin 11? is to restart. 12. Add Sound/background music Please I really need an Expert To help me, Because i totally don't get how to make this game ![]() |
Author: | Insectoid [ Wed Jan 05, 2011 11:56 am ] |
Post subject: | RE:I Need Help For My School Project !! Urgent!!! |
There's now way your teacher would assign something like this without providing all of the necessary tools. Pay more attention in class bud. |
Author: | Tony [ Wed Jan 05, 2011 12:03 pm ] |
Post subject: | Re: RE:I Need Help For My School Project !! Urgent!!! |
kingkillar @ Wed Jan 05, 2011 11:51 am wrote: but i do no know hot to use the array.
This is what tutorials are for. They come with code examples too! If you don't understand something, ask specific questions. The game is very simple, in a way that there are only two events to worry about: 1. the head of the snake is at the same location as another body part -- game over. 2. the head of the snake is at the same location as a fruit -- use Rand.Int to pick a new random location for the fruit, and grow the snake by one. If you are using arrays for the body parts of the snake, then you add one more element to that array. Super amazing hint for implementing snake: play an existing game and watch carefully as to how the snake moves. How many parts change position for the snake to move forward 1 space? |
Author: | kingkillar [ Wed Jan 05, 2011 1:22 pm ] |
Post subject: | Re: I Need Help For My School Project !! Urgent!!! |
thats what i kind of needed to know, the "Rand.Int" command but still i do not know how to make the tail follow the head each time i move it. For example: if i press "w" the head goes up but the tail does not, and if i try to make three ball move together only one ball moves with the head. That's the problem i'm having, i need to know how to use the Array program to control my tail and how to increase it and each time it eats the food, how to make the tail grow 1 more tail. I've been trying to do this over the last two weeks, but i still cannot get it in my head about how to do this. My teacher only tells me to do assignments, and when i ask for help.. he says to figure it out urself or search it out urself. I've done 20 assignments in the class by myself as well as the other srudent in this class. This is hard!! Please Help!! It's due this week ![]() ![]() And THANK YOU very much for telling me about the "Rand.Int" command, i've been trying to find a command for moving the food location. |
Author: | Tony [ Wed Jan 05, 2011 2:21 pm ] |
Post subject: | Re: I Need Help For My School Project !! Urgent!!! |
kingkillar @ Wed Jan 05, 2011 1:22 pm wrote: if i press "w" the head goes up but the tail does not
Where does the tail go? Here's a miniature snake I wrote back in 2004 -- http://compsci.ca/v3/viewtopic.php?p=52985#52985 It doesn't have fruits, but play around and just watch the tail. Turn up delay to a larger value to slow things down. Make it painfully slow. Play until you can answer the question: "when the head goes up, which way does the tail go?" |
Author: | kingkillar [ Thu Jan 06, 2011 7:29 am ] |
Post subject: | Re: I Need Help For My School Project !! Urgent!!! |
The tail follows, but only 1 part and the the other 2 ball dissapear,and wen i try to add more ball, it wont work ![]() These Are My 3 Major Problems: - Making The Tail Follow when the head moves - Making the tail grow 1 more ball(which represent 1 part of tail) at the end of its tail each time it eats the food - Making the food reappear in a different location, once i've eaten it, and making the one i ate dissapear those r like my main problems, only if i can figure these 3 things out, ill be able to do everything else in my project. So please if it's not much trouble for you, wud u mind giving me a sample that is related to all these three things, it don't have to be a snake game, but if it is related..please post back because i reallllly need it :/. PLEASE HELP! I have to hand it in soon. Thank You Very Much, and Sorry For Wasting Ur time! |
Author: | Tony [ Thu Jan 06, 2011 11:47 am ] |
Post subject: | RE:I Need Help For My School Project !! Urgent!!! |
You are not saying _why_ those are problems that you are having. Post your code. Not the entire code (that's often too much to read), just the relevant parts. |
Author: | kingkillar [ Fri Jan 07, 2011 8:52 am ] |
Post subject: | Re: I Need Help For My School Project !! Urgent!!! |
Posted: Wed Jan 05, 2011 11:25 am Post subject: I Need Help For My School Project !! Urgent!!! -------------------------------------------------------------------------------- Here.. I've juss changed it a little bit. It's kind of better now. But all i need now is how to control the snake and how to make it go smoothly without whipping its tail everywhere. It's kinda like the sample u gave me except can u plz make it a little simpler without all the boolean commands TY. %Set Screen View.Set ("offscreenonly") %Variables var x1, y1 : int := 0 var KEY : string (1) var x3 : flexible array 1 .. 9999999 of int var y3 : flexible array 1 .. 9999999 of int const R : int := 7 var x2, y2 : int var a, b : int var i : int := 4 x2 := maxx div 3 y2 := maxy div 3 for x : 1 .. 4 y3 (x) := y2 x3 (x) := x2 - 10 i -= 1 end for loop %drawfillbox (0, 0, maxx, maxy, 0) drawfilloval (x3 (1), y3 (1), R, R, red) delay (10) View.Update () drawfilloval (x3 (1), y3 (1), R, R, 0) %The Backround for x : 2 .. 4 drawfilloval (x3 (x), y3 (x), 5, 5, 7) x3 (x) := x3 (x - 1) y3 (x) := y3 (x - 1) end for delay (10) end loop |