|
My program draws fireworks, no sleep and they whiiiz by abit fast,
Ille look into the multimedia timers!
thanks
/Johannes
|
|
|
|
|
Work out how much time has passed since your last frame, then you can scale up your animation to update accordingly
|
|
|
|
|
Um?
it uses SetPixel for everything..
/Johannes
|
|
|
|
|
You need to correctly use loops, timers and counters.
It sounds like you are doing all of your drawing directly to the screen, and you have an uncontrolled loop, you should instead be trying draw to an offscreen bitmap. Set a timer, on each timer event bitblt the bitmap to the screen.
|
|
|
|
|
WalderMort wrote: ...you should instead be trying draw to an offscreen bitmap.
Hey, wait a sec. Didn't you state not too long ago that double buffering "is for little girls" or
something like that?
Cheers!
|
|
|
|
|
oh.. err... mm...
NO, that was Voldemort, my evil twin
|
|
|
|
|
Mark Salsbery wrote: double buffering "is for little girls"
|
|
|
|
|
well the loop is kinda controlled, but i came up with a way to fix it, i do the sleep(1); less often, every fourth time..
but now i have another problem, i created a second thread, and both main and the second thread generate exactly the same random numbers using rand()%1000, how can i get a more random random??
lol :P
/Johannes
|
|
|
|
|
You have to seed the random number generator with a random number. Use GetTickCounts or something like that. Otherwise, they always start out the same, so that you can actually 'test' the generator.
|
|
|
|
|
hu??? how?? wht? GetTickCounts?
:/
/Johannes
|
|
|
|
|
the common method is to seed the random number generator with the number of seconds elapsed since 1970 or something, can't remember exactly. Anyway use the time() function which returns this number and pass it directly into the srand() function.
srand( (unsigned)time( NULL ) );
|
|
|
|
|
Before using rand() in either thread, call this, straight from MSDN:
srand( (unsigned)time( NULL ) );
You should NOT be getting same random value sequences from each thread, then.
I just sometimes do this:
srand( LOWORD( GetTickCount() ) );
|
|
|
|
|
Just to make sure we are on the same wavelength here, you do know that all the sleep(1) call is doing is releasing CPU cycles to other processes. If you look at your app in the task manager it will still be hitting the 80-90% which is a bad thing really. You really shouldn't be using a loop for such a lengthy process.
Drawing a single scene of your animation takes a split second, you only need to draw that to the screen about 30 times a second ( less if the animation doesn't change often ). You should work out how often you need to draw a new scene and set a timer for that value. Handle the WM_TIMER to draw the scene but do not draw it to the screne. Instead, create a counter. So for example if you draw a scene 100 times a second, each time increase your counter, when the counter is 30/100 bitblt to the screen then reset the counter.
You may also find that using SetPixel() is incredibly slow. It may be a better idea to use a DIB and manipulate the pixels directly. Also to further increase your speed, create an offscreen bitmap to the same resolution as the screen.
|
|
|
|
|
How rename files and folders in a tree control?
Jus by editing labels in tree control....
-- modified at 10:45 Thursday 30th November, 2006
|
|
|
|
|
|
Haiku!
|
|
|
|
|
When you receive the TVN_ENDLABELEDIT notification, make a call to rename() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
HI ,
How can i scan all the windows which are opened ,i.e which are in the taskbar,
and how can i list those urls?
|
|
|
|
|
|
Pls refer to here- http://www.codeproject.com/staticctrl/LEDScreen.asp
How To Use
Using the class is very simple.
1. Create project.
2. Link library msimg32.lib to project.
3. Add LEDScreen source files to project.
4. Place on a dialog any bitmap image (picture static). This is optional.
5. Place on a dialog (owner bitmap if exists) CStatic. With ClassWizard, create variable m_screen for this CStatic.
6. In your dialog declaration, rename CStatic m_screen to CLEDScreen m_screen. Like this:
I am a Visual C++ 6.0 beginner user. I don't understand what is the 2th step:Link library msimg32.lib to project.
How to do exactly to link the library??
|
|
|
|
|
why don't you ask directly the article's message board[^] down the article ?
|
|
|
|
|
I afraid the article's writer will not read my question...that's why I choose to post here.
I will appreciate any help from you.
|
|
|
|
|
you have less chances that he can read your questionb here than in his article's board...
every question in an article's message baord sends automatically an email to the author of the article.
so please, ask your question over there. Thank you
|
|
|
|
|
This means that you need to link the library code with your code.
In order to do this open your project properties page. (Sorry, I don't remember how to do this in VC6) Once in this dialog open the link section and look for a field that says "additional dependencies". Add the name of the library there.
You may also need to add a path to the location of the lib. In VC6 this options is buried in the tools->options menu. Look for an option/tab that says directories.
Hope that helps.
btw - I believe this *IS* the correct forum to ask your question, as it is a general C++/link question and not something specific to the article.
|
|
|
|
|
Hi folks!
I have a MDI application with a CFormView and a CListCtrl (exactly the CListCtrlEx from (http://www.codeproject.com/listctrl/reusablelistcontrol.asp)) inside it. If I resize the window after initialisation, the CListCtrl keeps it's size/position. I tried near everything to size the CListCtrl to the Window size. Does anybody know a solution?
Thanks!
Regards
Patrick Breucking
modified 15-Apr-22 21:01pm.
|
|
|
|