Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drunk_Snake Game PLEASE HELP!!
#1
Hello everyone! I'm trying to implement a funny version of the snake game posted on youtube by brandonioproduction , and I'm kind of stucked. The idea is to make the snake wobble after eating some fruits ( that in the end will be changed to beers <!-- sWink --><img src="{SMILIES_PATH}/icon_e_wink.gif" alt="Wink" title="Wink" /><!-- sWink --> )
so by the move() when the snake is going direction.NORTH for example , the coordinates are (head.x , head.y -1) so it goes straight up.
I have to implement something that changes the head.x like this:

case Direction.NORTH:
newPoint = new Point(head.x -1, head.y - 1);
then
newPoint = new Point(head.x +1, head.y - 1);
then
newPoint = new Point(head.x -1, head.y - 1);
then
newPoint = new Point(head.x +1, head.y - 1);

so you get the idea here. The snake would zigzag in x axis when moving vertically. and of course also would zigzag in the y axis when going horizontally.

Any Ideas are very welcome !!
cheers!
#2
the link for the source is here: <!-- l --><a class="postlink-local" href="http://bpforums.info/download/file.php?id=195">download/file.php?id=195</a><!-- l -->
#3
What you could do is simply have a global variable to keep track of the portion of the zigzag (whether we are going in the positive or negative direction). For example, at the top of the code..
[code2=java]private int xDir = 1;[/code2]

And then, every time the snake moves, we simply change this variable, for example...
[code2=java]case Direction.NORTH:
newPoint = new Point(head.x + xDir, head.y - 1);
xDir *= -1;
break;[/code2]

This would create a wobble effect that works every turn. In order to make this for the y-axis, you would simply need a yDir global variable!
My Blog | My Setup | My Videos | Have a wonderful day.


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to export Snake Game as a Runnable JAR file? bedigursimran 0 6,814 11-19-2013, 10:01 PM
Last Post: bedigursimran
  the snake game don't like me. Aaron Rogers118 3 14,037 08-22-2013, 10:10 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)