Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / The gameclock revised.

Author
Message
Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 24th May 2003 01:35 Edited at: 24th May 2003 01:37
Even though my gameclock worked fine before. I wanted to shorten it. In my experimentation I got this far. The problem is when the clock reaches 1:59 instead of 2:00 it goes back to 1:00. Any help would be cool.


*** Maxillian Software ***
Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 24th May 2003 03:17
I did some more work on the gameclock. I fixed the advance to next hour prob. Now I have a new prob. When the clock hits 00:00 it stays there. I notice a flicker from the clock when it goes to 00:01 but then it flicks back to 00:00. Ill eventually figure this out but go ahead and post if you wish.


*** Maxillian Software ***
Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 24th May 2003 03:50
I know Ive been posting quite a bit. But if I can help anyone else I hope i will. I set up a gosub routine called clockcycle. It will update the clock instance once every 6 seconds instead of every millisecond. Taking a huge load off the cpu. Still figuring out the 00:00 prob.


*** Maxillian Software ***
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th May 2003 07:40
May I reccomend some global arrays and a function?

this method will make it easier to update the time should u need to within other functions, An array declared at the top will pass throught a function in a global sense.

Sometimes things might change the time in your game IE time jumping portals so this will cover any problems you have there.





indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th May 2003 07:41
oops I didnt clean up neatly and undim WT_day(1)

just add that component at the end where the others are.

Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 24th May 2003 12:14 Edited at: 24th May 2003 12:15
Hmm a few global arrays and a function. I see about trying to use them. Im not familiar with arrays and functions yet but hey Ill take them on if itll help. Gonna have to learn them sooner or later anyway. Thanks indi

*** Maxillian Software ***
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th May 2003 12:32
no problem just ask if u have questions regarding those commands.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th May 2003 14:13
You really need be using global variables for this instead of using arrays.

Variables are very slightly faster than arrays, but more importantly, don't use anywhere near as much memory as arrays, and don't need to be cleaned up after use.

Here's the code with the small number of changes made:

Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 24th May 2003 16:08
Slightly faster, not as much mem, no clean up. Sound like good reasons to me. Thanks.

*** Maxillian Software ***
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th May 2003 17:57
I made the arrays because,

the method works across DBC and DBP in case you were still on classic.

allows more then one time to be tracked within the same array if you added more.

allows you to save the array data when the game needs to be saved easily.

you can still do all this now with the new methods, I have no idea what your requirements were so I left factors in for multiple time tracking.

sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 25th May 2003 00:56
hey maxillian did you try my code i posted the other day? that should work fine

BTW,
if i was you id use more recognisable variables, it's going to be hell when you get sidetracked with something else then need to remember what they all mean again (trust me, i learnt the hard way)

Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 25th May 2003 14:55
Yeah im gonna try using words instead of single or double variables. That way Im sure to not reuse one. Yup your code works fine.

*** Maxillian Software ***
Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 25th May 2003 18:44 Edited at: 25th May 2003 19:02
Well i fixed my 00:00 problem. It had to do with the sequence. I had to relocate the line "if ttclock=2400 then ttclock=0". Its not staying at 00:00 anymore. Here's the code.


Well now when it goes past 00:59 it goes to 00:60 instead of 01:00
but I fixed that by adding "if ttclock=60 then ttclock=100" it would have been a even longer line to do it the other way. Here's the new code.


I know its not the best code but it works and I shortened it alot.
I think Ill post it in the code snippets cause it also controls a
graphical 24 hour clock at the upper right of your screen as well.

*** Maxillian Software ***
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 26th May 2003 02:32
here is another way you could represent time as well using a type and an array together.

Sounds like you have chosen your method already tho



indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 26th May 2003 02:33
Maxx illian
21
Years of Service
User Offline
Joined: 12th May 2003
Location: United States
Posted: 26th May 2003 03:12
Well the method i used works for now. But there's plenty of time to come up with something better. As I experiment with arrays and functions I'll might work something else out. Thanks Indi

*** Maxillian Software ***
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 26th May 2003 03:15
no worries max by the way welcome to DB!

Login to post a reply

Server time is: 2024-09-20 09:36:46
Your offset time is: 2024-09-20 09:36:46