@mike_g : You've made my day pal! thank you so much :)
@matsp : Could you please explain your point in layman's view? I'm not getting much
Printable View
@mike_g : You've made my day pal! thank you so much :)
@matsp : Could you please explain your point in layman's view? I'm not getting much
It runs in Turbo C with the changes I made above - very minor. I love the way you've done this Mike, but the spokes stick 1/4 of the way outside the wheel, *4 instead of 10 fixes that, but then some spokes are too short (an aspect ratio problem maybe?), and the spokes appear "spazzy" and bunched up together around the 6 o'clock and 12 o'clock, position. Even with much longer delay times, I couldn't see spokes ever appearing at the 9 o'clock or 3 o'clock, positions.
I do love how compact it is. Much more practical than mine, if I could get it to behave itself! :D
The function "clock()" is not defined to return milliseconds. It is defined to return "a count of clock-ticks" - how big a clock-tick is depends on the implementation - you can find out how many clock-ticks per second"CLOCKS_PER_SEC", but the code from Mike_g is relying specifically on the tick-size being compatible with the function delay, which takes milleseconds as input.
In this case, it's no big deal - the code will probably run only in DOS (because it uses Turbo C specific code, including the "delay" function itself) - but in general, it's a good idea to NOT rely on how large the unit of a clock-tick is - it could be a microsecond (1000000 ticks per second) or it could be 10 ms (100 ticks per second), or something else (147138 ticks per second, perhaps?) - it all depends on for example what timing hardware there is on the machine - it may have a timer that runs at 1/10 of a 1.47138MHz crystal - then that's what you get!
Of course, if you feed delay with a number that is 1000 times larger than you want, then you get a very long delay, and if you feed delay with a number much smaller than the correct value, then you don't get a long enough delay.
--
Mats
Adak: I guess I thought the radius was 10 pixels when it was the diameter. Like I said I couldent test it to see what it came out like. I imagine the main reason it looks so bad is because the wheels are so tiny, it should look better on bigger wheels. I think the pixels sticking out problem has to do with the way that the circle is drawn. Its likely that graphics.h draws Bresenham circles because its a fast and accurate algorithm. However the curvature ends up slightly different to a circle drawn using sin and cos.
matsp: I usually use SDL_GetTicks(), maybe graphics.h has a method for getting the time in millisecs too? and yeah clock() seems to suck.
Erm.. Actually ignore that stuff I was babbling about to do with circles. The answer was painfully obvious; the circle needs to have an odd diameter. Otherwise on one half the spokes will end up one pixel too long, or short.
@Mats
Thanks for the explanation dude :)