then you''d need to change the value you''re incrementing on the xplane
i''m assuming your code looks something like this:
if(keys[VK_LEFT])
xpos--;
if(keys[VK_RIGHT])
xpos++;
well, just change that to something like:
if(keys[VK_LEFT])
xpos-=10;
if(keys[VK_RIGHT])
xpos+=10;
or change the value to whatever you want it to be, 10 might be too small or too big an increment, depending on how small the polygon is and how far back on the z-plane it is....
bloodright.150m.com //For the latest on all of the IVGDA projects!
Delays, and wait times...
quote:
Original post by skittleZ
What are some methods of creating pauses, and wait times? I tried to use the c++ system("PAUSE") but when I run an open gl program with that a cmd window pops up and just sits there, so im guessing you cant use it....
oh, and I just want to make sure that you understand why this is happening:
when you are making a game, it has to be in a constant loop, therefor, if you do a command that stops the loop, nothing can be executed (IE, nothing will be drawn).
bloodright.150m.com //For the latest on all of the IVGDA projects!
Thats what my code looks like right now.
if (keys[VK_LEFT])// Is left key Being Pressed?
{
xposy-=1.25;
}
if (keys[VK_RIGHT])// Is right key being pressed?
{
xposy+=1.25;
}
//The results im getting out of this is a square that moves smoothly and slowly when I move it left or right (with a low value) And a square that moves quickly, yet still smooth accross the screen(with a high value)
//I tried implementing the counter that you showed me earlier for constant dropping, but this hasnt seemed to work yet. any suggestions?
if (keys[VK_LEFT])// Is left key Being Pressed?
{
count2++;
if(count>10)
{
xposy-=1.25;
}
}
if (keys[VK_RIGHT])// Is right key being pressed?
{
count2++;
if(count>10)
{
xposy+=1.25;
}
if (keys[VK_LEFT])// Is left key Being Pressed?
{
xposy-=1.25;
}
if (keys[VK_RIGHT])// Is right key being pressed?
{
xposy+=1.25;
}
//The results im getting out of this is a square that moves smoothly and slowly when I move it left or right (with a low value) And a square that moves quickly, yet still smooth accross the screen(with a high value)
//I tried implementing the counter that you showed me earlier for constant dropping, but this hasnt seemed to work yet. any suggestions?
if (keys[VK_LEFT])// Is left key Being Pressed?
{
count2++;
if(count>10)
{
xposy-=1.25;
}
}
if (keys[VK_RIGHT])// Is right key being pressed?
{
count2++;
if(count>10)
{
xposy+=1.25;
}
Yay i figured out something finally lol, I used a for loop in my if statement for pressing left or right, so now it looks like this
if (keys[VK_LEFT]) // Is left key Being Pressed?
{
xposy-=1.70;
for(int i=0; i<50; i++)
{
keys[VK_LEFT]=FALSE;
}
}
So the left key is false for the time of 50 which takes away that "smooth movement" =P Thnx a bunch guys, now its bed time.
if (keys[VK_LEFT]) // Is left key Being Pressed?
{
xposy-=1.70;
for(int i=0; i<50; i++)
{
keys[VK_LEFT]=FALSE;
}
}
So the left key is false for the time of 50 which takes away that "smooth movement" =P Thnx a bunch guys, now its bed time.
hmm, ok, first off, making a for loop that counts to 50 and sets the keypress to false each time does the same thing that changing the keypress false once would be...
but, I think I know what you mean, and, if you are using my way of making it fall at a timed rate, then it''ll work a lot better, because with the timer it is halting all user interaction for that whole time....therefor making it choppy
so, if you ARE using my way of doing it, then you''d just have to change the amount that the xpos is being added/subtracted, (you used 1.7, so if that''s really slow, try raising it to something like 5.0 and that should make it go faster...)
but, I think I know what you mean, and, if you are using my way of making it fall at a timed rate, then it''ll work a lot better, because with the timer it is halting all user interaction for that whole time....therefor making it choppy
so, if you ARE using my way of doing it, then you''d just have to change the amount that the xpos is being added/subtracted, (you used 1.7, so if that''s really slow, try raising it to something like 5.0 and that should make it go faster...)
oh yeah, your right about the for loop thing heh, and yeah im using your way of timed dropping, so I got both tasks done now. =P Thnx again.
jverkoey you are quite wrong , using time based graphics you can achieve the pauses that skittleZ I think is looking for ..
//be put before main loop
starttime=getcurrenttime();
delay=10
.....
//in main loop
if(getcurrenttime() > (starttime+delay))
drawdelayedgraphics();
this is a basic example ;
getcurrenttime() can be achieved through timeGetTime() for basic precision timing
this way the pause is the same on all platforms the program might run
//be put before main loop
starttime=getcurrenttime();
delay=10
.....
//in main loop
if(getcurrenttime() > (starttime+delay))
drawdelayedgraphics();
this is a basic example ;
getcurrenttime() can be achieved through timeGetTime() for basic precision timing
this way the pause is the same on all platforms the program might run
---sorry for not using proper english , I'm from latin roots
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement