Question Snake game score calculation

beeyzakbult

New member
Joined
Dec 18, 2020
Messages
1
Programming Experience
3-5
Merhaba. Yılan oyunu yapıyorum ve puanı hesaplama kısmını yapamıyorum. Mesela yılan ilk yemi 10 sn de yediyse 100/10=10 puan, ikinci yemi 5 sn de yediyse 100/5=20 puan kazanacak. Ama iki yemi yerken ki süreleri ayrı ayrı hesaplatamıyorum. Nasıl yapabilirim?
 
We can only accept questions in English on this site. If you aren't able to write English yourself, you can use an online translator:
Hello. I'm making a snake game, and I can't do the part about calculating the score. For example, if the snake ate the first de 10 s, it will gain 100/10=10 points, and if the second one is eaten in 5 s, it will gain 100/5=20 points. But I can't calculate the time it took to eat the two ate separately. How can I do that?
 
You can use a Stopwatch object to measure time. Start the Stopwatch and then get the Elapsed time when you want to make the first measurement. You can assign that value to a variable. You could let it keep running and take another measurement later and subtract the first from the second, or you could Reset it and get the second time directly from Elapsed again.
 
The other thing to consider is that the snake goes forward at a fix pace; x spaces per second. (At least this is the way the original game was made.) If the number of spaces of the the snake has moved forward is within x * n spaces, then you don't really need the stopwatch.
 
Back
Top Bottom