Click here to Skip to main content
15,891,657 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Incrementing a Variable Pin
cgb1437-Aug-08 10:25
cgb1437-Aug-08 10:25 
AnswerRe: Incrementing a Variable Pin
T.RATHA KRISHNAN7-Aug-08 3:33
T.RATHA KRISHNAN7-Aug-08 3:33 
GeneralRe: Incrementing a Variable Pin
Perspx7-Aug-08 3:37
Perspx7-Aug-08 3:37 
GeneralRe: Incrementing a Variable Pin
T.RATHA KRISHNAN7-Aug-08 3:40
T.RATHA KRISHNAN7-Aug-08 3:40 
GeneralRe: Incrementing a Variable Pin
Perspx7-Aug-08 3:46
Perspx7-Aug-08 3:46 
GeneralRe: Incrementing a Variable Pin
cgb1437-Aug-08 10:18
cgb1437-Aug-08 10:18 
GeneralRe: Incrementing a Variable Pin
Perspx7-Aug-08 10:22
Perspx7-Aug-08 10:22 
AnswerRe: Incrementing a Variable Pin
Nelek7-Aug-08 22:44
protectorNelek7-Aug-08 22:44 
I hope to understand your problem right.

Let's suppose your "Object" is a square, if you want to move it from A to B as "animation" with different speeds... One way to do could be:

1) You calculate the differences in coordinates between A and B. Let's suppose an horizontal line where A is (0, 150) and B (500, 150). So for that example the distance is going to be 500 "pixels" or units of your screen coordinates.

2) You set your different speeds. Let's suppose 10 pixels / sec, 50 pixels / sec and 100 pixels / sec

3) Speed = distance / time == distance = speed * time == time = distance / speed Let's choose this last one, time depending on the other 2.

4) You make a function to increment in one pixel the coordinate of your square
void MoveSquare () { square.x = square.x + 1; }


for such a line you don't need a function, but if you want to do more things or move it in more directions you can ride better with it.

5) When you have to move the square you just need to calculate the time needed with the end_pos and the speed (500 / 10 = 50 sec; 500 / 50 = 10 secs; 500 / 100 = 5 sec)

6) You have to call the MoveSquare 500 times to move it till end_pos, then
1st case -> 50 sec / 500 calls = 0.1 sec / call
2nd case -> 10 sec / 500 calls = 0.05 sec / call
3rd case -> 5 sec / 500 calls = 0.01 sec / call

7) Create a timer with that refresh rates 100, 50, 10 ms and call MoveSquare into it

8) when end_pos is reached, kill the timer


Is something like that what you were searching?

Regards.
--------
M.D.V. Wink | ;)

If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.

Question[Win CE/Pocket PC]How to load an gif image on to a Button Pin
madyastha7-Aug-08 2:32
madyastha7-Aug-08 2:32 
AnswerRe: [Win CE/Pocket PC]How to load an gif image on to a Button Pin
David Crow7-Aug-08 2:53
David Crow7-Aug-08 2:53 
GeneralRe: [Win CE/Pocket PC]How to load an gif image on to a Button Pin
madyastha7-Aug-08 3:34
madyastha7-Aug-08 3:34 
QuestionRe: [Win CE/Pocket PC]How to load an gif image on to a Button Pin
David Crow7-Aug-08 3:41
David Crow7-Aug-08 3:41 
AnswerRe: [Win CE/Pocket PC]How to load an gif image on to a Button Pin
madyastha7-Aug-08 18:41
madyastha7-Aug-08 18:41 
GeneralRe: [Win CE/Pocket PC]How to load an gif image on to a Button Pin
madyastha7-Aug-08 22:41
madyastha7-Aug-08 22:41 
Questionmaking DWORD registry enteries Pin
VCProgrammer7-Aug-08 2:30
VCProgrammer7-Aug-08 2:30 
AnswerRe: making DWORD registry enteries Pin
SandipG 7-Aug-08 2:37
SandipG 7-Aug-08 2:37 
GeneralRe: making DWORD registry enteries Pin
VCProgrammer7-Aug-08 2:41
VCProgrammer7-Aug-08 2:41 
GeneralRe: making DWORD registry enteries Pin
SandipG 7-Aug-08 2:50
SandipG 7-Aug-08 2:50 
GeneralRe: making DWORD registry enteries Pin
VCProgrammer7-Aug-08 2:56
VCProgrammer7-Aug-08 2:56 
GeneralRe: making DWORD registry enteries Pin
David Crow7-Aug-08 3:02
David Crow7-Aug-08 3:02 
AnswerRe: making DWORD registry enteries Pin
Hamid_RT7-Aug-08 23:24
Hamid_RT7-Aug-08 23:24 
QuestionThread Pin
shakumar_227-Aug-08 2:08
shakumar_227-Aug-08 2:08 
AnswerRe: Thread Pin
Cedric Moonen7-Aug-08 2:24
Cedric Moonen7-Aug-08 2:24 
GeneralRe: Thread Pin
shakumar_227-Aug-08 2:36
shakumar_227-Aug-08 2:36 
GeneralRe: Thread Pin
Cedric Moonen7-Aug-08 2:41
Cedric Moonen7-Aug-08 2:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.