« first day (345 days earlier)      last day (2499 days later) » 

12:18 AM
@milleniumbug Are you there?
 
12:29 AM
pastebin.com/zVMZsyS6 That's my code after fixing. If someone could look is it better, I would be grateful.
 
 
7 hours later…
7:15 AM
@Toreno96 I'm not sure if the inheritance is correct, validate should be a free function
also I've no idea what the Integer class aims to accomplish
 
 
1 hour later…
8:39 AM
Is there anyone here that knows game development good? I have a question about it.
 
don't ask to ask, just ask
 
Yeah, but since this is not "Game Development" room, I thought it would be problem to ask something about game development.
Okay, I am programming simple game in SDL. And I have render function, you pass textures to it and it renders. Anyway, the important part is, I render stuff every frame and if I do not put SDL_Delay(1) in render function, everything goes insanely fast. But, AFAIK it is really bad to use delay when it is not really really necessary. So, what is my problem? How can I solve this without delay?
 
nwp
@MuhamedCicak You are supposed to have code that calculates where objects are at a given time. You seem to make stuff move whenever a frame has passed which makes no sense. Instead make stuff move whenever some number of milliseconds passed. That way you can have high frame rate without delay and without your physics going crazy.
 
@nwp How am I supposed to say "when some number of milliseconds pass"?
@nwp In the code, I mean.
@nwp Only function for time that I know is SDL_Delay
@nwp Is there some library for doing that?
 
nwp
@MuhamedCicak yes, the standard library can do that
 
8:55 AM
the other option is to get the amount of time that has passed since the last time you updated your state and base your movements on that
the simplest way is if(time_elapsed < 16) return;
 
@nwp Which function is it, do you have link?
 
16 ms for 60 frames a second
 
@ratchetfreak And would I do time_elapsed++ every frame?
 
no you would keep a last_updated (only set after you pass the test)
and then long time_elapsed = now() - last_updated;
long time_elapsed = now() - last_updated;
if(time_elapsed < 16) return;
last_updated = now();
 
@ratchetfreak And what would be the code of "now" function?
 
nwp
8:59 AM
@MuhamedCicak a typical game loop might look something like this
 
@MuhamedCicak it's basically the SDL_GetTicks() function
I was a bit too lazy to look it up
 
@nwp Why is display_current_frame_to_screen function being called every frame. Shouldnt it be inside the while?
@ratchetfreak So that function (SDL_GetTicks) is equivalent to std::chrono::high_resolution_clock::now()?
 
nwp
@MuhamedCicak No. The point is to make the physical movement independent of the frame rate. You update physics until it is up to date in the while loop without drawing anything. Then, once the physics is up to date you draw it on the screen. There is no point drawing outdated state onto the screen.
 
@MuhamedCicak barring resolution and 0 point yeah
 
@nwp Does display_current_frame_to_screen render everything and output on the window?
 
nwp
9:09 AM
@MuhamedCicak yes
 
@nwp Im sorry, I have hard time understanding this... Lets say I have an object car. And calculate_next_physical_frame function would calculate its movement etc. about every 16th frame, right? If so, wouldnt there be an problem that if user presses for example left arrow, I would get 1 ms later car going left. Or is that even problem?
 
1 ms of lag is not noticable
 
nwp
@MuhamedCicak Why every 16th frame?
 
16 ms of lag is not noticable
 
@nwp Sorry, every 16th millisecond.
@ratchetfreak Then I guess I understand it :)
@ratchetfreak I thought it would cause a problem
Okay, I understood. Thank you guys! @nwp @ratchetfreak
 
9:14 AM
input lag is only a problem in twitch/reflex games
in most other games as long as it's under a quarter second people tend to not notice
 
Twitch/reflex games? How do you mean? Whats that?
 
fps shooters, meatboy, ...
where you need to be very precise and quick on the timing
 
Actually, I am not sure if this one is, but it is Flappy Bird.
It may be annoying if any kind of lag happens, as you need to be precise with jumps.
But, again, I do not think 16 ms would be a problem. Even in fps shooters, right?
 
but if you can fix the amount of lag precisely and there is enough anticipation then a longer lag time is acceptable
 
@ratchetfreak I dont understand that sentence :D
 
9:19 AM
for example in flappy bird the bird will follow a precise and predictable arc
you know when the bird needs to hop
if the input lag is longer then you will need to tap sooner
however it doesn't make it unplayable
in a fps shooter you need to be able to shoot as soon as you see an enemy coming around the corner and any delay will make it much harder to get the kill
 
nwp
this has a decent description of what lag is and what to do about it
 
@ratchetfreak What is the minimum amount of lag (in ms) that would disturb player playing fps shooter?
@nwp I will have a read. Thanks.
@nwp Lol, i thought it is text. It is video.
@nwp Then I guess I need to watch it, logically :D
 
10:00 AM
@nwp I have used what you have told. Now I have my objects going really slow. Shall I increase their velocity or reduce the time of the updating movement etc. (i.e. calling calculate_next_physical_frame)
 
nwp
@MuhamedCicak Increase velocity. If you increase the physical steps it will affect all object which might be ok for now but later on not so much.
 
@nwp Okay. Thank you for the help, I really appreciate it.
@nwp Oh, by the way, only thing I do not understand is, that my program now uses more CPU precentage than it did with delay. Is that common?
@nwp Actually, it is using a lot. 15% in task manager.
 
nwp
@MuhamedCicak Of course. Previously the program did nothing during the delay. Now it always does something, either calculating physics or drawing to the screen.
 
@nwp So, what can I do. Is it problem that it uses 15% of CPU. Because, it seems a bit more than it should use. I mean, this is game in C++ not Unity.
 
nwp
You could limit the FPS and say that every frame should only be drawn once and then you wait until it is time to calculate the next physical frame.
@MuhamedCicak You have an infinite loop. It will consume all available single threaded CPU resources no matter how fast the CPU or what libraries you use.
 
10:14 AM
@nwp I quite did not understood this previous message about limiting the FPS
 
@MuhamedCicak if you have 8 cores then that means it's pegging a thread (and actually taking 12.5)
 
@nwp Could you make an example in ideone of what you meant by that "limiting FPS" case?
 
nwp
@MuhamedCicak After you draw the frame with display_current_frame_to_screen you wait std::chrono::high_resolution_clock::now() - current_time + physical_frame_length milliseconds (assuming it is a positive number). That way you only draw frames when needed and otherwise sleep which should get your CPU usage down a lot.
 
@ratchetfreak 12.5%?
 
nwp
The power gamers who payed a fortune for their PC will hate you because you only give them 60FPS when they want to have at least 1000FPS.
 
10:19 AM
@nwp Wait, is that equivalent to moving calling of display_current_frame_to_screen function to while loop? I hope it is, because if not, I did not understand anything...
 
@MuhamedCicak 100/8, a thread can only run on a single core at a time and the OS will shift the thread around for various reasons (most likely heat distribution on the chip)
 
nwp
@MuhamedCicak It is different in the case where calculate_next_physical_frame takes more than 16ms because your version of moving display_current_frame_to_screen into the while would draw to the screen whereas my version of waiting wouldn't. My version skips frames when the CPU has a hickup (windows update or something) while your version slows down the game and then makes it run super fast to catch up.
 
@nwp Can you paste modified version of previous code you wrote (on ideone) to the version you are talking about? My English is not very perfect, as I dont talk English everyday, so I would much easily understand what you are talking about by seeing an example code.
 
Given std::deque<double>::const_iterator it, does *--it++ return value of *(it-1) while keeping it at the current position?
 
nwp
10:34 AM
@MuhamedCicak this is one way
@Mirac7 According to the operator precedence rules no, because ++ binds stronger than * so it is evaluated as *(--it++) which is pretty useless.
 
@nwp Hahaa, it takes now 0.2% I will have a read about that function (sleep_until). Oh, by the way, why do you need to write "while loop" there, couldnt it be "if statement" instead? Because, as I can see, it will anyways be done once (the while loop) as there is: current_time += physical_frame_length;
 
nwp
@MuhamedCicak It will be executed multiple times if calculate_next_physical_frame takes more than physical_frame_length.
 
@nwp Oh, I see. Again, thanks :)
 
nwp
cppreference.com is pretty good to look stuff up. In the long run you should get familiar with containers and algorithms from the STL.
 
@nwp, so *(--it++) == *it ?
Or *(it-1)
 
nwp
10:44 AM
@Mirac7 The first, unless I missed something.
Like trickery such as operator == not doing what one would expect it to do.
 
I'm wondering because, as I understand, a++ inside an expression means evaluate a, return it, and then increment it, so *--it++ if analogous should be, decrement it, evaluate it, return value currently pointed at, and afterwards increment it back
 
nwp
For builtin types such as pointers --it++ is just undefined behavior. For classes it is equivalent to operator*(operator++(operator--(it))).
Where the operators are just funny syntax for regular functions.
 
Doesn't std::deque keep keep data non-contiguous in memory, and its isn't just a pointer to a value?
It's weird that it doesn't conform to intuitive increment/decrment
 
nwp
@Mirac7 right
 
So *(--it++)==*((it--)++)?
 
10:54 AM
the operator ++ would have a dummy int arg (it mark it as post)
 
nwp
@Mirac7 Why is it not intuitive? You decremented, incremented and dereferenced. Seems pretty intuitive what the result would be.
 
I expect a = 0; b = a++; // b == 0, a == 1?
 
nwp
@Mirac7 basically, assuming no weird behavior of the operators
 
so *(--it++) == *((--it)++) == operator*(operator++(operator--(it), 0))
 
Then, analogously I expect a = *(--it++); be equivalent to it--; a=*it; it++;, as it++ should return it, and when evaluation has been completed be incremented, while ++it should first increment, then evaluate
 
nwp
10:58 AM
apparently something is going on there
would not recommend writing such code
 
{
    auto __tmp1 = operator--(it);
    auto __tmp2 = operator++(__tmp1, 0);
    a = operator*(__tmp2);
}
that's what a = *(--it++); would be evaluated as
note that operator++ and operator-- don't need to return the same type as it
most of the time they will but implementations are free to screw with that (and those should burn)
 
Weird behaviour, I'll just avoid evaluation with increment/decrement :D
Thanks for your explanations
 
11:50 AM
Which inheritance? From the boost::addable<>?
Why do you think validate should be a free function?
And Integer is just a toy class for experimenting with Boost.Operators (library which is new to me).
 
12:34 PM
@Mirac7 Doesn't matter, this is garbage code
Use *std::prev(it)
 
1:29 PM
is the best way of reading the arguments i send to a program a for() cycle and see each one individually? or are there anny better way?
like i have a for cycle starting in 1 and going to argc-1
and thats how i do it
but is there a better way? soemthing idk about?
 
4 messages moved from Lounge<C++>
 
it's fine TBH
 
yes, you can iterate over argv
 
do consider how you would handle arguments with a parameter like -o outputFile.txt
 
i have like this /i
^ input
/o
^ output
and so on
 
1:33 PM
depends on what else are you doing with this, you can use a command line parser library
 
hmm, ill check that out
one more thing
how do i tell a device for a path?
 
can you elaborate on that?
 
for example, if i send domething like this \\.\F: i know its a device, and something like this C:\Users\ thats a path, but is there something to tell them appart code wise? or do i just have to read the string
i mean, not string, char *, but you get it
 
what
\\.\stuff is an UNC path
 
UNC? what does that mean?
 
1:36 PM
and X:\stuff is your regular DOS style path
 
i use \\.\F: in the CreateFile function to handle a device
 
uniform naming convention: en.wikipedia.org/wiki/…
 
and i use C:\Users\text.txt to handle a file
 
hm, well the CreateFile function only works if the device "path" is like this \\.\letter:
if im making a device handle
 
1:39 PM
read this
 
i read the Path part
but am i doing it wrong?
 
yeah read it further
 
i mean it works if i used it like this \\.\letter:
\\.\COM1
This path refers to the first serial port (COM1).
^ so if i use like this \\.\F: is referes to the path of a device
no?
 
"Win32 Device Namespaces
The "\\.\" prefix will access the Win32 device namespace instead of the Win32 file namespace. "
i was correct
annyway
the thing is, it is kinda annyoing for the user to type \\.\F: instead of just F:
i have a input handle and output handle
one is a normal path and the other a UNC
if i take the trouble of the user of inputing the \\.\ behing the UNC path, how can i, inside the code, tell the UNC path from the normal path?
for example...
/i F:
 
1:46 PM
one has \\ in front and the other doesn't
 
ohhhh
yes i forgot about that
nice, ill look that, ty
 
well, \\.\stuff is for devices, \\?\stuff is for files
and if it doesn't have \\ in the beginning, it's not UNC path
 
 
4 hours later…
5:47 PM
Question:
 
Answer:
 
How did this guy commit multiple solutions to the same commit branch? (e.g. chapter03 commit has the solutions to exercises 7-11). How was he able to do that; to post multiple different exercises to the same commit branch? I hope that makes sense and I didnt mix the vocabulary up. I know how to commit things, but not do multiple programs within the same commit branch.
lol @milleniumbug ily
The only way I can think of is him waiting to commit with all the solutions. Once he has all the solutions he submits them all to the commit?
 
what? these are just different directories
 
So for example: In chapter03, he has solutions to exercises 7-11. Did he post those all at the same time or at different times? IF he did do it at different times, how did he doit?
Im using github desktop to commit things, btw
 
Let's say you have an empty repo, now push a commit that adds an exercise 7, push another commit that adds an exercise 8, and now your repository has two exercises
 
6:02 PM
Hmmmm
Maybe im not understanding enough
let me get this straight with the github terms
A rep would be stroustrup_ppp
the commits would be the chapter03, chapter04, chapter05, etc
 
@faceless no
 
D:
 
see the two links above
 
yeah
 
these are links to the specific commits
 
6:06 PM
hhmmm okay
how do you commit things to github?
 
Cool, ill read this
thank you :)
 
^^ that's a general introduction to what's the point of version control
 
Im a noob, so I use github desktop
I want to be able to fit all of these project into one folder
but right now, theyre all separate
 
and here's an official tutorial for git git-scm.com/book/en/v2
 
6:09 PM
oh my gosh, thank you
I spent about 8 hours in the beginning of june figuring out how to commit things to github
using youtube and google and I never even found this...
this will help a lot
 
I tend to avoid youtube tutorials because reading is faster
 
Yeah, I'm pretty visual, I usally do youtube > read tutorials> wiki > repeat
 
6:32 PM
@faceless ahaha same, same...I've tried to learn git/github on so many occasions...hopefully the official tutorial will be useful! :)
 
@faceless here's more git-scm.com/doc /cc @sweetmusicality
 
Thanks @milleniumbug :D
 

« first day (345 days earlier)      last day (2499 days later) »