Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Time.DelaySinceLast and snake
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xevious




PostPosted: Wed Jan 18, 2006 10:12 pm   Post subject: Time.DelaySinceLast and snake

I'm trying to make a snake game where the value of each "apple" decreases at a steady rate regardless of what difficulty you're on.

I'm having trouble getting around the delay from different difficulties, and I'm pretty sure that Time.DelaySinceLast is the command I'm looking for.

Can my original delay remain as just "delay"?
Do I need multiple calls to Time.DelaySinceLast in a single iteration?
I'm really confused about how Time.DelaySinceLast works...

Could somebody please try to explain it to me a little?
Sponsor
Sponsor
Sponsor
sponsor
jrblast




PostPosted: Wed Jan 18, 2006 10:31 pm   Post subject: (No subject)

You could make a new variable, called for example "penalty" then every time the loop executes it increases by 1, then deduct that from the points...( or probably divide it a bit first...
xevious




PostPosted: Wed Jan 18, 2006 11:00 pm   Post subject: (No subject)

jrblast wrote:
You could make a new variable, called for example "penalty" then every time the loop executes it increases by 1, then deduct that from the points...( or probably divide it a bit first...


That's basically what I was doing, but that's not really the problem

I'll try to clarify

If I just have that variable, it's value increases at a slower speed if the delay I'm using for my snake is slower, or increases faster if the delay I'm using for my snake is faster.

So basically I want it to go the same speed regardless of what difficulty the person is playing on, thus giving them a reason to play at a higher speed, since they'll be able to get more points.

I found the scoring in Gandalf's snake to be almost exactly what I'm trying to do...if that helps.
xevious




PostPosted: Thu Jan 19, 2006 6:58 pm   Post subject: (No subject)

Sorry for double posting, but I don't really want this topic to go to the bottom, as my problem still exists.
cool dude




PostPosted: Thu Jan 19, 2006 7:06 pm   Post subject: (No subject)

k i'm not sure if this is wat your looking for but why r u using the same speed variable as for the other thing your trying to do which u should clarify a bit better. make two speed variables one for the snake and the other for the other thing(clarify please). i'm not sure thats wat your asking for so if u still have trouble please post your code so i can be of more help
xevious




PostPosted: Thu Jan 19, 2006 7:28 pm   Post subject: (No subject)

The one delay is for the snake, and the other would be for a point counter, which steadily decreases in value until the snake eats the apple.

The main problem is making it so that that point counter decreases at the same speed regardless of the snake's delay.

So I guess I'm looking for some way to have a counter going seperate from the main program, so that the delay in the main program doesn't affect it.

I believe Time.DelaySinceLast could help, but I'm not really sure how to use it, or how it's different from just "delay"
[Gandalf]




PostPosted: Thu Jan 19, 2006 9:19 pm   Post subject: (No subject)

xevious wrote:
I found the scoring in Gandalf's snake to be almost exactly what I'm trying to do.

Just don't copy me. Smile

You'll definately want to use Time.DelaySinceLast() and only have one delay. The difference between Time.DelaySinceLast() and delay() (which is also the same thing as Time.Delay()) is that the first will give you the same delay on all computers, regardless of the amount of time it takes to execute the loop. Look it up using F9 if you need more information on it.

Now, the main point... What you'll need to use is a timer, not a counter. The score will be based on how long it took you to eat an apple. The function you will need to accomplish this is Time.Elapsed, which returns the amount of time (in milliseconds) since the program started up. Try to figure it out on your own, if you need more specific help, post.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: