TimeScale by a Newbie.
Blitz3D Forums/Blitz3D Beginners Area/TimeScale by a Newbie.
| ||
AppTitle "Cubies Inc" Global ScreenWidth = 180 Global ScreenHeight = 180 Graphics ScreenHeight,ScreenWidth,32,2 ClsColor 250,250,250 SetBuffer BackBuffer() Time = 500 TimeLine = 1 Timer = MilliSecs() While Not KeyDown(1) ; ESC Cls ; TimeLine Scale System ;-------------------------- ; Increment TimeLine If MilliSecs() > Timer + Time Then Timer = MilliSecs() TimeLine = TimeLine + 1 End If ; Reset TimeLine Scale If TimeLine > 60 Then TimeLine = 1 Color 5,5,5 Text 15,15,TimeLine Flip Wend Any recommendations or suggestions? |
| ||
; Reset TimeLine Scale If TimeLine > 59 Then TimeLine = 1 I think this is a good suggestion if you don't want it to be 61 seconds per second. ^^ What are you trying to achieve exacly? |
| ||
No, that will make it take only 59 steps. But what is the problem? |
| ||
Oh.. yeah, and it has to reset to 0... if this is a real timeline that is ^^ Digital clocks range from 0-59 seconds in a minute.. unless something has changed? |
| ||
It just controls the speed sprites move, and triggers of functions and detriggers of functions. I was thinking of showing all the pieces of coding from my video games to see if anyone else out there can do the same thing better or differantly. It's all about making better games. |
| ||
Without changing things too much,AppTitle "Cubies Inc" Global ScreenWidth = 180 Global ScreenHeight = 180 Graphics ScreenHeight,ScreenWidth,32,2 SetBuffer BackBuffer() ClsColor 250,250,250 Color 5,5,5 ; no need for this in the main loop Time = 500 TimeLine = 0 Timer = MilliSecs() While Not KeyDown(1) ; ESC Cls ; TimeLine Scale System ;-------------------------- ; Increment TimeLine If MilliSecs() > Timer + Time Then Timer = MilliSecs() TimeLine = (TimeLine + 1) Mod 60 End If Text 15,15,TimeLine Flip Wend |
| ||
Oh, if anyone else alters/improves the code, could you just leave a little note attacted, stating how you've altered/improved the source code. Many thanks in advance. |
| ||
To be honest with code as simple as this there will be many different ways of achieving the same goal. Most of the time it comes down to personal preference rather than any significant performance increase. Better to spend your time completing something than constantly fine tuning bits of code that work perfectly well anyway. |
| ||
I understand that there are differant ways of achieving the same goal, I've done this to find out how other coders would go about it. This topic isn't about who can write the best code, but who can improve on it (personaly) the best way. I don't have deadlines and market research holding back my video games releases. So time to me isn't an issue, to me I'd rather spend ages on the little things, isn't it the little things in video games that have the biggest impact on the player. Code wise, music wise, or visually. PS: I didn't start this topic and others simular (coming soon) about whats the best code, but more a libary of how coders would code the same goal. To allow others coders to read it and get an understanding on how other coders would code. In the long run triggering of insperations and ideas. |