Page 1 of 2

new project started!

Posted: July 22nd, 2012, 3:20 pm
by viruskiller
is a snake replica;
started it this morning ,worked about 6 h on it so far :D ,well most of it was thinking on how to do it :lol: .

anyway i choosed the linked list concept(with loop :D ) for the snake squares,made each square a class with it's own x,y coordinates and a pointer to next square(the color variables were for a different idea that would not make much use of the linked list idea).
so i got the snake going on the screen,colecting goal squares and increasing it's length.
the problem is when the head of the snake is right on the goal square and i change direction it skips the goal like it never passed over it :? ,and i made my code so that it actually attaches the goal square as the new head of the snake before even moving over it,dunno why is doing this..

also i know that i'm just creating new Sqr class objects with every snake update and never delete them :lol: ,that i intend to code later on(afterall is just a few bytes of memory leaking :) )
and also missing colision detection with the screen edge or the snake body,and it can turn 180degree's in one move:)

anyway i just uploaded it at this stage to get few ideas about how to make it eat goal and move without a pause like effect,i mean whenever the head is on the square next to the goal and it's heading towards the goal it should take the goal posiition and put it as the new head for the snake

so far is doing just that but only when i'm passing trough the goal,if i corner right on the goal spot it misses the goal and moves over:(
here's the source,has no comments so far,hope u can read it without them for now:D
Chili DirectX Framework V12.04.24 (SFX).zip
(48.41 KiB) Downloaded 332 times

Re: new project started!

Posted: July 22nd, 2012, 4:37 pm
by astr0
personaly i think that it is better that you write game over when snake hit sides of the screen than abort :)

Re: new project started!

Posted: July 22nd, 2012, 6:29 pm
by viruskiller
yeah it will have a game over screen and a restart game key:),but for now i'm just worried about the mechanics of moving the snake around;)

Re: new project started!

Posted: July 23rd, 2012, 6:19 pm
by Asimov
Hi viruskiller,

I never know if snake is a ripoff of Tron lightcycles or the other way around LOL.

Asimov

Re: new project started!

Posted: July 24th, 2012, 1:58 pm
by viruskiller
i can bet is the other way around :lol:

Re: new project started!

Posted: July 24th, 2012, 3:25 pm
by Asimov
Hi viruskiller,

Just had a funny thought. Is this going to be a growing project LOL

Asimov

Re: new project started!

Posted: July 24th, 2012, 5:00 pm
by LuX
Some kind of a tron-snake combination might be interesting. Like snake, but the body leaves the trail through out the whole game.

Re: new project started!

Posted: July 24th, 2012, 5:24 pm
by viruskiller
well if u put in my game a snakelength ++; line in the snake update function and delete it from Dir update function it will leave it's trail trough out the whole game:)) because i never delete the body objects that i create so they can be drawn:D,
anyway the problem is that the draw snake function draws from head to tail so if your snake is really long it's tail will be drawn on top of the upper body so will be like he's crawling under his body:D,although might be a cool idea to leave it like that and make it so game only ends when it hits he screen,and the goal would be to make the longest snake ever:P
that would involve some strategy like going in perfect circles and very well timed turns :lol:
feel free to modify my source and update it with this idea :)

Re: new project started!

Posted: July 24th, 2012, 6:14 pm
by Asimov
Hi viruskiller,

Would love to update it with 3D lightcycles LOL, but I have spent a couple of failed days trying to load a png from a resource file without success and I have been playing with Autodesk mudbox the last couple of days as well. Spent so long getting it to work on my computer I might as well use it heh heh.

Mudbox is good for adding damage to 3D objects made in 3ds max.
I do love building 3d stuff heh heh.

Asimov

Re: new project started!

Posted: July 24th, 2012, 8:39 pm
by viruskiller
holy schizz!! i spent like 3 h to code a loop to delete the unnecesary objects from the tail of the snake, got it working but whenever i colected a new goal the whole damn snake got deleted and was getting error from the drawing functions, i was like wtf i'm deliting the wrong object or what???

then in the end i rememberd of chili shoting himself in the foot with the linked list concept by forgetting the null pointer at the end:),

so when i was deleting last object i never set previous pointer to NULL ,that worked fine untill my snake length increased ,after that the last object was pointing to the first because the compiler choose to reuse that address when the snake got bigger thus needing more objects so the delete call was deleting the last object and whatever that one was pointing too.

so make sure u never call delete on a pointer to an object that has pointers to other stuff u might need,it will go trough all of them and delete them all.although that could be an advantage when u wana destroy a linked list:D,just have to call delete on first object:P