Computer Science Canada

Snake help please

Author:  jrblast [ Thu Dec 01, 2005 7:27 pm ]
Post subject:  Snake help please

Well, im making a snake game, i dont have computer sciences, but my friends do (class was full, so i didnt get it Crying or Very sad ) but, i started playing with turing last week, (so dont expect my code to be good) and now im trying to make a snake game, so far...not too bad...except i cant figure out how to give the dot a tail, now i dont expect (or want) someone to finish the game for me, i just want a basic explanation of how i might make a tail, the source is 150 lines so far (well, about) so ill attach it so you dont have to scroll a billion lines to post...lol

o, and so far i have a tail, but its just a straight one

Author:  [Gandalf] [ Thu Dec 01, 2005 9:36 pm ]
Post subject: 

Oi... indent your code. Look up flexible arrays, and make your snake game grid-based. Store the last location (on the grid if you are using one of each 'part' of the snake in the flexible array, and add an element when you 'eat' something.

Also, when properly used, you should only have one View.Update in your program. Your use of it in this case is strange, g2g

The code is exceptional for 1 week of experience, great job!

Author:  jrblast [ Thu Dec 01, 2005 9:43 pm ]
Post subject: 

[Gandalf] wrote:
Oi... indent your code. Look up flexible arrays, and make your snake game grid-based. Store the last location (on the grid if you are using one of each 'part' of the snake in the flexible array, and add an element when you 'eat' something.

Also, when properly used, you should only have one View.Update in your program. Your use of it in this case is strange, g2g

The code is exceptional for 1 week of experience, great job!


Embarassed yah, i just learnt the View.Update function when i read it in another post, and as for the exceptional thing, well, i did know a bit (basic var get put and draw commands) of the program, plus i have a teensy bit of experience in php...i hate php, syntax is too complicated for me

ok, ill try that, thanks, but, i may have found another way, ill try that first...but ill look up the flexible array anyways, perhaps it might prove useful another time Very Happy or even better than my way Razz but, i wanna at least try the way i just htought of first...ill post back like tommorow

Author:  jrblast [ Thu Dec 01, 2005 10:13 pm ]
Post subject: 

:S i dont understand the flexible array hting, with the bonds and the blah blah blah, lol, perhaps in time i will Razz

o, and anyone know why you cant edit posts??? i dont like having to double post...and possibly tripple Sad

Author:  AzureFire [ Thu Dec 01, 2005 11:17 pm ]
Post subject: 

Here's my advice. Going from Turing to a REAL programming language is freaking hard. And since you didn't get the compsci course learn the basics of turing then move on to something less restricting, like C or C++. But that's just my opinion.

Author:  jrblast [ Fri Dec 02, 2005 11:11 am ]
Post subject: 

AzureFire wrote:
Here's my advice. Going from Turing to a REAL programming language is freaking hard. And since you didn't get the compsci course learn the basics of turing then move on to something less restricting, like C or C++. But that's just my opinion.


well i do eventualy want to, but i like turing for now, its nice and simpele Razz, besides, i wanna make at least one program that uses the internet, and perhaps works with a php script i would attempt to design for it, kinda like bit torrent and trackers, except, not for dling stuff

Author:  Mr. T [ Fri Dec 02, 2005 8:38 pm ]
Post subject:  Alex's Opinion

Here's sample code showing how a flexible array works. Try figuring out the components that make it function.
code:

var info : flexible array 1 .. 0 of int
var x, y, button, left : int
put "Click the mouse to update the array."
delay (1000)
cls
loop
    Mouse.ButtonChoose ("multibutton")
    Mouse.Where (x, y, button)
    left := button mod 10      % left = 0 or 1
    if left = 1 then
        new info, upper (info) + 1
        put upper (info)
    end if
    delay (100)
end loop

Good Luck.

Author:  Cervantes [ Sat Dec 03, 2005 8:18 am ]
Post subject: 

AzureFire wrote:
Here's my advice. Going from Turing to a REAL programming language is freaking hard. And since you didn't get the compsci course learn the basics of turing then move on to something less restricting, like C or C++. But that's just my opinion.

There are plenty of other languages out there than Java and C++. I suggest learning Ruby after Turing. Link!

Author:  MysticVegeta [ Sat Dec 03, 2005 12:53 pm ]
Post subject: 

I would have to say, Ruby is pretty good. First looked confusing to me, but when you get the hang of it, there are so useful predefined functions availabe, reducing the requirement of a loop. Very Happy

Author:  jrblast [ Sat Dec 03, 2005 8:18 pm ]
Post subject: 

ok, well ill go on to ruby after turing i guess, hopefully by next semester Razz though id like to stop at some point and finish learning php lmao, i hate: that syntax Evil or Very Mad or Very Mad thanks for the code Pwned

Well, i think ill give up on this for now perhaps in a week ill pick it up again, ty everyone

Author:  jrblast [ Sun Dec 04, 2005 1:10 am ]
Post subject: 

pardon the second double post, but

IM DONE!!! (i know i said i wouldnt continue till like next week, but i just didnt have the will power lol) suddenly i figured it out lmao!!! i decided well ill just give it a tail of a set length of 1 then that will be that, wont be snake but w/e, so i made tailx and taily get the values of x and y at the end of the loop, then i put in in a flexible array (thanks to pwned for that script which led to my understanding of it) and IM DONE!!!

Author:  [Gandalf] [ Sun Dec 04, 2005 1:44 pm ]
Post subject: 

Indeed... Why not post it?

You don't like PHP's syntax? Well, from what I have seen, it looks a lot like C++/Java syntax which a lot of languages stem out from. It's not the only option, but it would be good to get used to Wink.

Author:  jrblast [ Sun Dec 04, 2005 6:02 pm ]
Post subject: 

[Gandalf] wrote:
Indeed... Why not post it?

You don't like PHP's syntax? Well, from what I have seen, it looks a lot like C++/Java syntax which a lot of languages stem out from. It's not the only option, but it would be good to get used to Wink.


i will get used to the syntax because i need to, but for now :@:@:@:@:@:@:@:@:@ lol, o, and anyone know a way to use the Play.Sound function but without pausing the script? anyways, ty again especialy pwned and gandalf

Author:  [Gandalf] [ Sun Dec 04, 2005 6:29 pm ]
Post subject: 

I've always done it so that if I want two different sounds playing at the same time, I have them in different formats - works for Turing. For example, you can have a background mp3 running while playing a wav of an explosion.

Author:  jrblast [ Sun Dec 04, 2005 8:01 pm ]
Post subject: 

erm, im talking specificaly about the Music.Play and Music.Sound commands, the ones that play musical notes and headache frequencies...Is there a way to play that without pausing the program?

btw, heres the new source, still gonna upgrade it a bit etc...

Author:  ZeroPaladn [ Mon Dec 05, 2005 10:08 am ]
Post subject: 

lolz i tried playing at speed 1 and i died right on the spot. anyways, this game if freaking fun! (score 43 btw :p) good job with so little turing experience. i cant even make pong (the collision detection annoys me, and i have no patience) and ive taken 2 comp sci classes and been with turing for 3 years...

Author:  jrblast [ Wed Dec 07, 2005 6:54 pm ]
Post subject: 

ZeroPaladn wrote:
lolz i tried playing at speed 1 and i died right on the spot. anyways, this game if freaking fun! (score 43 btw :p) good job with so little turing experience. i cant even make pong (the collision detection annoys me, and i have no patience) and ive taken 2 comp sci classes and been with turing for 3 years...


i think theres a collision detection guide on this forum, could be helpful to check it ou? besides, pong wouldnt be easy because of the angles and stuff, bleh! i couldnt make it either...i think, maybe i can get some ideas by looking at the asteroid game that comes with turing Razz (turing folder/examples/fun/asteroid game , something like that)


: