We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › AIDS Charity Game: trail problem [moved]
Page Index Toggle Pages: 1
AIDS Charity Game: trail problem [moved] (Read 884 times)
AIDS Charity Game: trail problem [moved]
Jul 9th, 2008, 1:39pm
 
ps: the post is long, but please help me.

Hi,

I work for a AIDS Charity ( avert.org ). I am also a artist that use processing in some works. So when we talked about doing a game, I though "processing".

Basically, we are developing a game where you are controlling a snake-thing. You have to collect letter and/or items and avoid baddies. We want a nice movement and a brain-training-like type of game.
The development is doing well but we have a problem with the snake. I can't manage to control the length of the snake.

Here is how I am doing it for the moment and a possible solution:

Problem:
I've got a class ( bone ) which is a vertex. The first end of the first line is attached to the mouse. When the mouse move, each extremities of the object take the position of the object in front. It all relies on how fast the mouse move and how fast the computer "record" the mouse pos.
The problem is that the faster you move, the longer is the snake. Which is cool for the gameplay in a way. But on slower machines the snake become incredibility long.

What I am trying to do to fix this is, I think, not really efficient:
I declare a "length". I divide all section ( bones ) of the snake by this length. Store all those new positions. Draw the snake on x number of "length".

Other questions:
1/ It's really slow on firefox-osx, but smooth on all other platform/os combination ( Xp, osx, IE6, IE7, Safari, Firefox 2 and 3 ). Any clue?
2/ which is best a snake made with just a loop or with objects.

We would all appreciate some help on this. I know it's not a quick question but if you have any ideas on how to fix this or how to have the same movement.

Here is a version of the game ( not even alpha version ) . This really just the work on the fundamentals of the game. No sound, no design ( a little ), no interface, etc...

http://www.avert.org/p5/  
Re: AIDS Charity Game: trail problem
Reply #1 - Jul 14th, 2008, 12:50pm
 
any help or thoughts?
Re: AIDS Charity Game: trail problem
Reply #2 - Jul 14th, 2008, 10:15pm
 
Quote:
The problem is that the faster you move, the longer is the snake. Which is cool for the gameplay in a way. But on slower machines the snake become incredibility long.

I like this feature too. What you could do, to preserve the gameplay but prevent the snake from becoming too long, is :

- setting a maximum length, in pixels, at the beginning,
- when you draw the snake or update its coords, calculating each bone's length - using dist() - and summing them.
- if the sum reaches maximum length, stop 'extending' the tail, which means moving all other vertexes to the last drawable one.

I hope you understand what I mean.
Re: AIDS Charity Game: trail problem
Reply #3 - Jul 15th, 2008, 10:20am
 
hi,

Thanks for your answer antiplastik. We tried this solution at the beginning but then you end up with a snake with 3 bones or something when you move really fast. Which make the snake look abit cheap.

But I had completely forgotten about this solution. We tested it a the beginning when we were only working on the snake. Now that we have baddies and items, it might be ok as the baddies won't let you move the mouse that quickly.

Thanks again, if any ideas are still welcome Smiley
Re: AIDS Charity Game: trail problem
Reply #4 - Jul 15th, 2008, 12:17pm
 
Hi TM, you can use the curve() function to draw a smooth curve through your points. Of course that will only work if you are drawing your snake with simple lines. If you are using a more complex drawing method (e.g. using segment sprites) then you can create new points along your snake path curve using curvePoint() and create yourself new segments which are closer together for when the mouse moves fast... hope that was a clear explanation!
Re: AIDS Charity Game: trail problem
Reply #5 - Jul 15th, 2008, 12:43pm
 
Would it be possible for you to explain a bit more? It look interesting?
I am going to have a look at curve() and curvePoint() but a little example wouldn't hurt Wink

Your suggestion is more to make the snake look better and smoother. Not making it fix length, isn't it?

I am really happy that people are starting to help me! THANKS!!!!
Re: AIDS Charity Game: trail problem
Reply #6 - Jul 15th, 2008, 1:00pm
 
I don't see how to use curve() here. It's just like using a vertex as It would a bit complicate for me to define how to curve the curve ( positioning the anchors).

Is curvePoint() is like using lerp() in a way?

UPDATE:

I changed it using curveVertex() instead of vertex(). It curves the snake for me, wich id very cool. But it sometime jitter wich a lot less cool...

UPDATE 2:
Fixed the jitter thing with curveTightness(). But still have to find a way to work out the strokeWeight wich doesn't work in the same way with curveVertex()
Re: AIDS Charity Game: trail problem
Reply #7 - Jul 15th, 2008, 5:27pm
 
HI TM, yes my suggestion of using curve() was to fix the jaggedness you were mentioning when using antiplastik's solution- it doesn't actually control the length. I'll post the code sample in the other thread were all the code is
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1216033701

and probably best to only focus on one thread from now on...
Re: AIDS Charity Game: trail problem
Reply #8 - Jul 15th, 2008, 5:58pm
 
Yes, let's write only in the other subject:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action =display;num=1216033701
Page Index Toggle Pages: 1