When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
67 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

!howto ask
Anyone can ask a question in our programming channels. Following the guide Writing The Perfect Question is recommended.
State your problem clearly and provide all necessary details:
Provide the relevant code in the message, and format it nicely with a code block*. If it's too much for one message, you can upload it:
There are multiple files
So do I just paste all?
!howto ask
Anyone can ask a question in our programming channels. Following the guide Writing The Perfect Question is recommended.
State your problem clearly and provide all necessary details:
Provide the relevant code in the message, and format it nicely with a code block*. If it's too much for one message, you can upload it:
read the last 3 lines of that^
The more code you send, the less likely anyone will help, unfortunatley
No one wants to read hundreds of lines
It's best if you can send just the relevant parts
float delta_time = 0.016666f;
LARGE_INTEGER frame_begin_time;
QueryPerformanceCounter(&frame_begin_time);
float performance_frequency;
{
LARGE_INTEGER perf;
QueryPerformanceFrequency(&perf);
performance_frequency = (float)perf.QuadPart;
}
simulate_game(&input, delta_time);
LARGE_INTEGER frame_end_time;
QueryPerformanceCounter(&frame_end_time);
delta_time = (float)(frame_end_time.QuadPart - frame_begin_time.QuadPart) / performance_frequency;
frame_begin_time = frame_end_time;
simulate_game(Input* input, float dt) {
clear_screen(0xff5500);
float speed = 5.f; // Units per second
if (is_down(BUTTON_UP)) player_pos_y += speed * dt;
if (is_down(BUTTON_DOWN)) player_pos_y -= speed * dt;
if (is_down(BUTTON_LEFT)) player_pos_x -= speed * dt;
if (is_down(BUTTON_RIGHT)) player_pos_x += speed * dt;
draw_rect(player_pos_x, player_pos_y, 0.5, 0.5, 0x00ff22);
I guess these are all of the important parts
Basically it calculates second per frame
From what the video told me
And then it just take delta_time and multiply with speed
!code
```cpp
int main() {}
```
int main() {}
internal void
simulate_game(Input* input, float dt) {
clear_screen(0xff5500);
float speed = 5.f; // Units per second
if (is_down(BUTTON_UP)) player_pos_y += speed * dt;
if (is_down(BUTTON_DOWN)) player_pos_y -= speed * dt;
if (is_down(BUTTON_LEFT)) player_pos_x -= speed * dt;
if (is_down(BUTTON_RIGHT)) player_pos_x += speed * dt;
draw_rect(player_pos_x, player_pos_y, 0.5, 0.5, 0x00ff22);
}
int main(){
float delta_time = 0.016666f;
LARGE_INTEGER frame_begin_time;
QueryPerformanceCounter(&frame_begin_time);
float performance_frequency;
{
LARGE_INTEGER perf;
QueryPerformanceFrequency(&perf);
performance_frequency = (float)perf.QuadPart;
}
simulate_game(&input, delta_time);
LARGE_INTEGER frame_end_time;
QueryPerformanceCounter(&frame_end_time);
delta_time = (float)(frame_end_time.QuadPart - frame_begin_time.QuadPart) / performance_frequency;
frame_begin_time = frame_end_time;
}
From the video I watched. Yes that's what they did
And then they used that time length and multiply with speed
Speed of what
Movement speed
Of the object that the user controls
They did that so the movement speed doesn't change when the window changes in size
so the speed of the square/rectangle your drawing changes when you resize the application window
So why cant you do this
i see your code calculating the length
It does that but I don't know why it doesn't apply
So it does calculate the length
And I multiply the length with movement speed
But the movement speed changes
Despite that
So you multiply speed with length to get this new speed value or whatever
What are you doing with this value
Where is that handled
is length * initial rect speed = new rect speed
or what does this value represent
Yes that is what I want to do
You can see that in simulate_game function
No
I only see you subtract initial frame time from final frame time
And divide it by “performance frequency”
i dont see you setting it to be the new speed of the rectangle
I guess it's time * speed = distance
Speed is already determined (5.f)
So what I want is for the time to change so that distance between first pos and next pos stays the same throughout despite the size of the window
However, time doesn't change or something not working which results in smaller window => distance longer I guess
Can I send video for you to see the problem?
I think it will be a bit easier if you can see the problem
Sure
send relevant timestamps too
At 50 second is where you can see my problem
The first part is the expected output
I'm currently learning this course on youtube
Hope this helps a bit
If you need more information, I will try to provide all everything
I will comeback after half an hour
Thankyou for taking your time looking into this
@swift coyote Has your question been resolved? If so, type !solved :)
@swift coyote
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
!solved