Advertisement

well... to move a sprite VERY SMOOTHLY on a screen... you'll have to use floating....

Started by February 13, 2002 07:07 AM
7 comments, last by mickey 22 years, 10 months ago
point values and timeGetTime() etc..., ie posx += velocityx * tickdiff / 1000.0f um... is there any other way? style? technique? easier to understand? how does this line goes anyway? thanks!!! Edited by - mickey on February 13, 2002 8:17:35 AM
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
and uh.. one more thing? i''ve been really stuck in using int ye know... i never use those signed..unsigned...long..double... and especially ''float''... i really can''t see the use of them except decimals... but now i''ve seen one... which can you guys explain to me how you use floating values in games? like the one above? why float and not integer? thaaannkkk you sooo much!!!
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
Advertisement
oh and how come i need to put my input processing inside my game loop? why can''t it be in the window messages?
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
post 1: that''s how to do it. basically, each sprite has a velocity, and that "tickdiff/1000.0f" adjusts this velocity to the framerate, so they don''t move really fast on some computers and slow as hell on others. there might be other ways, i dunno... search the forums!
post 2: unsigned values cannot be negative (but you get a higher positive range)... i.e. signed char -> -127 to 128, unsigned char -> 0 to 255... i don''t know which is the default (if you just use "char"), i think it depends on the compiler... floats just hold decimal numbers (not integers)... the reason to use it here is accuracy, if you try to divide with integers it automatically rounds the number, and you will get a "jumpy" motion.
post 3: i dunno. do you use direct input?

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
krez, yup i do use direct input now, instead of those WM_KEYDOWN... etc., messages, how about you?
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
I thought pixel locations could only be integer co-ordinates, like (100,55) or (88,366). Are you telling me you can have an (x,y) location like (199.9,25.73)?
No, Canadians DON'T all live in igloos. They live in one BIG igloo!
Advertisement
well i don't know, i also used integer values before, but when i came across to moving sprites, i noticed they used floating point values, so here i am, using floating point values too,

and look at what kregz said about using float values,

Edited by - mickey on February 14, 2002 9:48:28 PM
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
pixel locations can only be integer values since you are modifing an array. though the extra precision is good for interpolating and if you wish sub pixel accuracy by using some anti-ailiasing techniques or filter (ie bilinear, etc) the output that you draw. you guys really shoul read some books and tutorials and really try to understand the basics of coding (ie like the types and what they do). this will help you in the long run, because using floating point values because someone else is, is just plain silly. you could use all fixed point integers and not deal with floating point values. now you got better accuarcy (ie fractional values of whole numbers) and using pure integer math (no overhead for floating point to int conversion). its all up to you, but you must first understand WHY vertain things are done.
hey... i am reading books! a lot actually... game programming is a very very complex subjects and a single book, two or even 10, can really cover all of it, it's just that i've never really encountered a book or tutorial explaining these things about when to use floating and when to use integers,

Edited by - mickey on February 15, 2002 9:36:56 AM
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,

This topic is closed to new replies.

Advertisement