Note first, Dev is just a front end for gcc, so questions about the compiler are best phrased that way.
(1) Look into rand and srand. If you want to get any fancier, I use GSL, the Gnu Scientific Library.
There have been a number of discussions on the board about this, search on srand and you should find something.
(2) There are really no "default" libraries. There are libraries and routines you can link. I am not however the expert in this area. (Given enough time and beer I can probably think of an area that I am expert in). I'm sure the heavyweights will weigh in in a bit on this...
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-02-10
1) That may not be very random since time itself is not random! The world is full of poor pseudo random number algorithms, but if you insist you could try setting the random number seed using the current clock() value, and then simply using rand() repeatedly.
srand( clock() ) ;
then subsequently,
rnum = rand() ;
2) Win32 API! You could download clgdi DevPack if you want simple console mode graphics.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
About graphics:
I don't know what is level of your knowlege but downloading and reading big document "Charls Petzold: Programming Windows" is the best for start.
Hiroaki
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) How do i make random numbers based on time?
2) What are the default graphics libraries, and what include files do i need to access them?
Any examples you can pose with true code (not just explanations) would be much appreciated.
Thanks
-em
Note first, Dev is just a front end for gcc, so questions about the compiler are best phrased that way.
(1) Look into rand and srand. If you want to get any fancier, I use GSL, the Gnu Scientific Library.
There have been a number of discussions on the board about this, search on srand and you should find something.
(2) There are really no "default" libraries. There are libraries and routines you can link. I am not however the expert in this area. (Given enough time and beer I can probably think of an area that I am expert in). I'm sure the heavyweights will weigh in in a bit on this...
Wayne
1) That may not be very random since time itself is not random! The world is full of poor pseudo random number algorithms, but if you insist you could try setting the random number seed using the current clock() value, and then simply using rand() repeatedly.
srand( clock() ) ;
then subsequently,
rnum = rand() ;
2) Win32 API! You could download clgdi DevPack if you want simple console mode graphics.
Try srand(time(NULL)); for initializing the random number generator with a proper seed.
upcase
time() returns a time_t structure, srand() requires an integer.
clock() returns a type clock_t, which is an integer. It is typedef'ed to allow for different representations on different platforms.
Strictly speaking I should have written:
srand( (int)clock() ) ;
Is is really impossible to use AnimateWindow with MingW 2.0 (w32api 2.2) ?
Or should I be deffining something I am not?
Anyone using it?
Thanks
What does that have to do with the thread topic?
Wayne
About graphics:
I don't know what is level of your knowlege but downloading and reading big document "Charls Petzold: Programming Windows" is the best for start.
Hiroaki