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.

Dark GDK / Timer Tutorial

Author
Message
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 19th Jun 2009 01:22
Here is a little tutorial for creating a timer with time.h for all the n00blies.



Your Welcome! ^.^ and this is very simple everyone should be able to understand quite easily.

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 19th Jun 2009 02:19 Edited at: 19th Jun 2009 02:20
A suggestion that I want to make. If you wish to help someone, make sure you don't insult them first and then help them. No need to call the beginners, who will become more powerful, noobs. You also spelled "your" wrong. It is "you're". Geez.
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 19th Jun 2009 02:23
Quote: "make sure you don't insult them first "


Nah, call them noobs

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 19th Jun 2009 02:28
Then maybe I should call you a noob for your lack of knowledge on human respect.
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 19th Jun 2009 03:41 Edited at: 19th Jun 2009 03:47
Wow WH8 are you kidding me? Thats rediculous what you just said there, maybe because of that I wont release any more tutorials.

EDIT: would you rather me have said "for all the people that dont know as much as i" means the same thing as noob rofl

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 19th Jun 2009 03:45
You can release more tutorials, but just watch your tongue.

I think you are ridiculous. Just to let you know. This ridiculous thing can go both ways.
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 19th Jun 2009 03:48 Edited at: 19th Jun 2009 03:53
alright mocho man!

EDIT: you would have a valid point if i said something like "stubid noobs" but no i said n00blies thats not a mean thing its not even derragotory.

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 19th Jun 2009 03:56 Edited at: 19th Jun 2009 03:59
Wanted to have the last word eh? Look whose talking? Right.

EDIT: You are using a word that has an unnecessary negative meaning to describe someone and/or something. That is insulting.
pancakeguy
15
Years of Service
User Offline
Joined: 9th Jun 2009
Location: Great White North
Posted: 19th Jun 2009 03:57
This argument is stupid, In the eyes of God were all b00ns...
and here's a picture of my feelings about this topic.

Well here i go again on my own, the only road I've ever known.

Attachments

Login to view attachments
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 19th Jun 2009 03:59
out of the mouths of babes! xD

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 19th Jun 2009 04:00 Edited at: 19th Jun 2009 04:01
I hope you aren't shoving beliefs into God. What makes you think God thinks little of us? I know what you are thinking: "What makes you think He doesn't?". What makes you think He does?
WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 19th Jun 2009 04:04 Edited at: 19th Jun 2009 04:04
I am going to stop arguing. You can continue to think I am the one who is crazy and insult me if you wish. I may or may not respond to your insult. It will depend how insulted I am by it.
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 19th Jun 2009 04:18
This is a pretty good example of how a mis-communication can screw a thread up.
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 19th Jun 2009 21:18 Edited at: 19th Jun 2009 21:34
It's a good example of someone who cant be grateful for a free tutorial

Quote: "
Then maybe I should call you a noob for your lack of knowledge on human respect. "


Maybe I should call you a noob for your lack of humor, sense of judgment and thankfulness

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 19th Jun 2009 23:01 Edited at: 19th Jun 2009 23:04
You have a good sense of judgement and humour? I can insult you just as well as you can insult me.

Quote: "It's a good example of someone who cant be grateful for a free tutorial"


A tutorial is fine. You have no need to offend someone in your tutorial.

Quote: "Maybe I should call you a noob for your lack of humor, sense of judgment and thankfulness"


Your humour involves offending others. I didn't find any of your "jokes" funny in my threads. Your "jokes", by the way, show your selfishness. You are full of yourself.
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 19th Jun 2009 23:43
OK! DUDE! WH8 I wasnt affending anyone! Do you see a name before or after noob? No. Does'nt look like I was affending anyone. If I remember correctly it's against the AUP to say mean things to people, I don't see a moderator speaking up to set me straight!

By the way, this has gotten way out of hand and I would like for a moderator to lock the thread. Thank You! =D

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 20th Jun 2009 03:40
Quote: "You have no need to offend someone in your tutorial."


If you get offended by the word noob, I don't think you will get very far in life

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 20th Jun 2009 06:55 Edited at: 20th Jun 2009 07:12
I know there are those people in this world that are full of themselves. You are one of them. Telling me that I won't get very far in life is just a weak way of trying to defend yourself. You are full of yourself to me no matter what you say. Now quit trying to make yourself seem like an innocent, perfect being. You are not innocent and neither are you perfect. You are a selfish idiot. No more can you say will change that. Now stop pissing me off. If you want me to continue to insult you, just make more insults. If you are bored and find insulting me interesting, go and find something else better to do. Now leave me alone please. Your behaviour is just showing that you are selfish. I understand very well that the word noob is meaningless to some people. It is not meaningless to me. You sometimes might call your friends names. Your friends probably won't have a negative response to your name calling. If you used the name calling on the president, the queen, etc, you bet they will be insulted. The issue right now is that you are being selfish by saying that because you and these other people take the word noob as being meaningless that I and those who don't take it meaningless have to as well. You know very well of human nature that it doesn't work that way. I guess you can say the same thing to me. I shouldn't stop you guys from calling each other noobs because the word is meaningless to you guys. The thing is that the word is insulting to some people, because it is, you therefore have to be careful of saying it. Once again, just because you and others feel that the word is meaningless, it doesn't mean that those who don't feel that way should feel the same way you do. I can reverse your insult to you. How do you expect to get very far in life if you get insulted when someone doesn't agree with you? You can say this to me too. Now quit insulting me! I wish to stop arguing. You can treat this action as being dirty, cowardish, etc. I want to stop. I just want everyone to understand that just because you think it is ok, doesn't mean it becomes an universal and absolute law. You have to be careful of what you say out loud. This goes to me too!
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 20th Jun 2009 15:39 Edited at: 20th Jun 2009 15:40
If anyone is selfish it is you WH8, kklouzal will no longer release tutorials for the whole community because of you. Because you just couldn't ignore a little comment which wasn't even directly aimed at you.

So yes as you said: You have to be careful of what you say out loud.

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 20th Jun 2009 18:41 Edited at: 20th Jun 2009 18:50
You really do not get it. I am one of the people who read what he said. He is addressing to anyone who would read his words. There are many people in this world AlexI. Just because you and your little group of people do not find being called a noob insulting doesn't mean the other millions do not! I don't understand what is so hard to understand about this!

You are calling me selfish. You really haven't even thought about your own actions! You are clueless! I understand that there are people out there who don't like being called noob. I am protecting those people. You are just thinking about yourself and those who are experienced enough to be not considered a noob by you guys. Selfish! It is like the rich insulting the poor. I am protecting the poor; you are defending your rich! Ha!

How long do you want to keep going at it AlexI? 1 week? 1 month? 1 year? 10 years? 100 years? Just quit it!
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 20th Jun 2009 19:03
Interesting, I should use this to implement timer-based movement in my game ^^.

What happens when the number of seconds exceeds the amount that can be stored in an int? Or do I not understand how that works >.> I know I wasn't able to store some of the values for my game in an int because of size constraints.

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 20th Jun 2009 19:04 Edited at: 20th Jun 2009 19:14
Noob is an insult, but most people wont start crying over it. Especially when the person is giving something to you for free.

Quote: "I am protecting those people."


Who? Give me some names? You the are only who complains about this.

Quote: "You are calling me selfish. You really haven't even thought about your own actions"


Yes, you prevented future tutorials from being given to the community by this user.

Quote: "What happens when the number of seconds exceeds the amount that can be stored in an int?"


You might get an overflow error or something. You could always use a long int instead

Quote: "I should use this to implement timer-based movement in my game"


It might be easier to use the dbTimer() function as you get milliseconds and don't have to include time.h

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 20th Jun 2009 19:28 Edited at: 20th Jun 2009 19:38
You really are crazy AlexI! Forget it! I can't convince people like you to get it! People like you lack the mental ability to get things like this! It is really that simple but you don't get it!

Why do I have to give you names? You know very well that billions of people exist in the world. You know very well that due to the law of probability, even something you think will never happen will happen or is happening behind your back right now! Due to the fact that so many people exist in this world, it is a lot more exaggerated than you think!

I don't understand why the guy can't make any more tutorials! He can make them! I don't know what you are saying! Is he physically restricted from making tutorials by the moderators?
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 20th Jun 2009 19:39 Edited at: 21st Jun 2009 05:02
Quote: "I don't understand why the guy can't make any more tutorials! He can make them! I don't know what you are saying! Is he physically restricted from making tutorials by the moderators or are you just saying those words on purpose to piss me off? "

Quote: "Wow WH8 are you kidding me? Thats rediculous what you just said there, maybe because of that I wont release any more tutorials."

You cant read either

Quote: "Why do I have to give you names?"


At least one other person agrees with me on this thread. You are by yourself at the moment.

Quote: "You know very well that billions of people exist in the world. You know very well that due to the law of probability, even something you think will never happen will happen or is happening behind your back right now! Due to the fact that so many people exist in this world, it is a lot more exaggerated than you think!"


What was the rubbish above about?

Quote: "You really are crazy AlexI! Forget it! I can't convince people like you to get it!"


I guess there must be many other's you have annoyed

WH8
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 20th Jun 2009 19:45 Edited at: 20th Jun 2009 19:51
What the heck are you talking about? The guy can make tutorials if he wished. You said that I prevented him from making tutorials. He can continue to make them if he wishes. He chose with his own free will to not! You are just acting dumb!

AlexI, you are much less intelligent than I thought. You asked me to give you names. Why can't you visualize the many people who are insulted? You will ask me now to prove that there are many people who are insulted. I proved it using the law of probability, but you didn't recognize the proof. You called it rubbish! Why do I have to teach you this?! Geez!

Forget it though. You are crazy!
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 20th Jun 2009 19:50
Quote: "
It might be easier to use the dbTimer() function as you get milliseconds and don't have to include time.h
"


I actually ended up using clock_t, which returns the cpu cycles since the launch of the program, and it is mostly accurate to the time. 1000 ticks of clock_t are equal to 1 second. However it seems to vary system to system, on Linux it represents the 'wall clock', meaning that if the program sleeps for a while, it will not perceive any time passing.



Quote: "You might get an overflow error or something. You could always use a long int instead"


I looked it up and apparently in the year 2038, all 32-bit systems that utilize time_t will crash, in a kind of Y2K inspired event. Basically the timer will reach the max value and reset to the minimum value, some negative number, and a bunch of machines will think that it is now 1904.

There are also time_t parties xD.

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 20th Jun 2009 20:03 Edited at: 20th Jun 2009 20:05
@Phosphoer

Quote: "I actually ended up using clock_t, which returns the cpu cycles since the launch of the program"


dbTimer may call the same function:

Quote: "dbTimer:
This command will get the internal system time, which continually increments at a thousand times a second. The system time is returned in milliseconds, where 1000 units represent 1 second. "



@WH8

Quote: "He chose with his own free will to not! You are just acting dumb!"


And he chooses to do so because you are being an idiot

Quote: "You will ask me now to prove that there are many people who are insulted. I proved it using the law of probability, but you didn't recognize the proof."


And how did you prove it using the law of probability?

Maybe you want me to do the calculation for you.

Number of people think you are wrong = 2 (AlexI,kklouzal)
Number of people think you are right = 1 (WH8)

Population: 6,706,993,152 (July 2008 est.)

People for you = 2,235,664,384
People against you = 4,471,328,768

So actually you need to recognize the proof

kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 21st Jun 2009 04:05 Edited at: 21st Jun 2009 04:06
WH8 sounds like he's on drugs. (no offence WH8 you just sound like your on drugs)

I did not realise that GDK had a dbTimer function...

Thanks for the backup AlexI, I gave up a long time ago. (see first comment )

Why hasn' my post been locked >.<

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 21st Jun 2009 05:05 Edited at: 21st Jun 2009 05:05
Quote: "Thanks for the backup AlexI"


No problem

Quote: "Why hasn' my post been locked >.<"


There's no mods just for the GDK forum

kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 21st Jun 2009 05:12 Edited at: 21st Jun 2009 05:55
=O No mods? I could be a moderator =/ I'm highly experienced in manging a forum i've ran handfulls of my own.

EDIT: I don't particularlly want to be a mod
EDIT:EDIT: Then again, now that I think about it, all the n00bs would bow down before me! lol

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 21st Jun 2009 07:08 Edited at: 21st Jun 2009 07:10
Here is my little Hi-Res CPU timer class, I use it all the time in my apps to time various pieces of code, it can help to narrow bottlenecks in your code.

Usage :
Declare a variable of type CStopWatch..
eg. CStopWatch myTimer;

then at the start of the code you want to time, call :
myTimer.startTimer();

at the end of the code being timed, call :
myTimer.stopTimer();

to acces the value stored, which will need to be done once each time its called, or it will be overwritten, you could either display it straight to screen as a number, or you could store it in an array of some kind and write it out to a file to study. Either way, it amount of time passed from startTimer() to stopTimer() is accessed by calling :
double timePassed = myTimer.getElapsedTime();

The returned value is in seconds, accurate to microseconds. So will usually be quite below zero.

Lastly, the timer is completely seperate from DarkGDK, linking into windows directly and independantly of the GDK, and can be run and used in apps that dont include DarkGDK's header. The advantage is that the value being returned is the total time the code takes to execute. The advantage of using a timer other than GDK's dbTimer(); is that having not coded GDK's timer, we have no way of knowing exactly how it works, where it is called in each of the GDK's internal loops, how much work is done before or after its calls etc.

This code was originally written by David Bolton and was obtained from :
http://cplus.about.com/
There are a heap of resources for CPP on that site.

Header file "hr_time.h" :





Code file "hr_tim.cpp" :


If it ain't broke.... DONT FIX IT !!!
Phosphoer
16
Years of Service
User Offline
Joined: 8th Dec 2007
Location: Seattle
Posted: 21st Jun 2009 07:23
Glad we could get this thread turned around

That looks really handy Mista, I might just give it a try ^^.

Login to post a reply

Server time is: 2024-10-01 06:02:45
Your offset time is: 2024-10-01 06:02:45