Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Skideria Games - VB6 Programming tutorial


JustinSD
 Share

Recommended Posts

1) if this thread is in the incorrect place, please move

2) i will do at least 1 daily update (probably not)

64-Bit timer (replacement for GetTickCount) | Original Author: Spodi of http://netgore.com

>! in any module of your choosing (preferably where your declarations are located)
```
'Used for the 64-bit timer
Private GetSystemTimeOffset As Currency
Private Declare Sub GetSystemTime Lib "kernel32.dll" Alias "GetSystemTimeAsFileTime" (ByRef lpSystemTimeAsFileTime As Currency)
Public Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long
>! ```
somewhere at your entry point routine (probably sub main)
```
>!     'Set the high-resolution timer
    timeBeginPeriod 1

    'This MUST be called before any timeGetTime calls because it states what the
    'values of timeGetTime will be.
    InitTimeGetTime
>! ```
>! Place in a module with general code of the program
```
>! Public Sub InitTimeGetTime()
'*****************************************************************
'Gets the offset time for the timer so we can start at 0 instead of
'the returned system time, allowing us to not have a time roll-over until
'the program is running for 25 days
'*****************************************************************
>!     'Get the initial time
    GetSystemTime GetSystemTimeOffset
>! End Sub
>! Public Function timeGetTime() As Long
'*****************************************************************
'Grabs the time from the 64-bit system timer and returns it in 32-bit
'after calculating it with the offset - allows us to have the
'"no roll-over" advantage of 64-bit timers with the RAM usage of 32-bit
'though we limit things slightly, so the rollover still happens, but after 25 days
'*****************************************************************
Dim CurrentTime As Currency
>!     'Grab the current time (we have to pass a variable ByRef instead of a function return like the other timers)
    GetSystemTime CurrentTime

    'Calculate the difference between the 64-bit times, return as a 32-bit time
    timeGetTime = CurrentTime - GetSystemTimeOffset
>! End Function
>! ```
Link to comment
Share on other sites

Note that TimeGetTime is MORE accurate than GetTickCount, so this will cause a few oddities with the values of your old time system. Or it can rather, animations might suddenly animate a bit faster and whatnot..
Link to comment
Share on other sites

@Stein:

> Note that TimeGetTime is MORE accurate than GetTickCount, so this will cause a few oddities with the values of your old time system. Or it can rather, animations might suddenly animate a bit faster and whatnot..

Skideria games discourages improperly coded graphic engines that would be affected by higher performance timers.

Which obviously leads to…

Frame based motion vs Time based motion.

An example time based motion coding would be what you see in ms4/eo2

Original Author: tiggilyboo of eclipse
```

        Case MOVING_WALKING: MovementSpeed = ((ElapsedTime / 1000) * (RUN_SPEED * SIZE_X))
        Case MOVING_RUNNING: MovementSpeed = ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

```+ associated variables, just search through the code
if you'd like, compare the same code in older versions of eclipse to see the frame based variation
Link to comment
Share on other sites

eek, quit posting in my thread, or i wont post any more codes

this was done by request.  leave the "notes" or whatever to me.  if i wish to leave information out, then that means i want the user to find out on their own
Link to comment
Share on other sites

@jcsnider:

> No. These are not newbie tutorials. These are code snippets. That I guess will attempt to improve eclipse for those who use them :/…

It has the most impact on CS:DE from what I've been told, It boosted the FPS client side about 5 times for some people. I personally haven't found much use for it in EO, aside from the fact that GetTickCount will break a after your computer has been on for a long amount of time, and it will eventually reset and start over, resulting in it breaking every loop based function we have in EO.
Link to comment
Share on other sites

@Just:

> It has the most impact on CS:DE from what I've been told, It boosted the FPS client side about 5 times for some people. I personally haven't found much use for it in EO, aside from the fact that GetTickCount will break a after your computer has been on for a long amount of time, and it will eventually reset and start over, resulting in it breaking every loop based function we have in EO.

You can fix that by simply doing a differential check and running the timers off an unsigned data type. The rollback won't damage anything then.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...