Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

1909 Excellent

1 Follower

About rnlf_in_space

  • Rank

Personal Information

  • Role
  • Interests


  • Twitter
  • Github

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. rnlf_in_space

    Array arithmetic

    Could be a way to gauge how careful your coworkers do their reviews.
  2. rnlf_in_space

    How to organize constants? (c++)

    suliman, because it doesn't protect you from type errors. enum WeaponClass { Axe, Sword }; enum Action { Move, SkipTurn }; if(unit.action == Axe) // perfectly fine, but still not what you want And in the end you'll want to prefix the names, because now they are not scoped anymore, imagine this: enum WeaponClass { Axe, Sword, }; enum ImpactSound { Axe, // error, Axe already defined Sword // error, Sword already defined }; The classic way to fix that would be to prefix the enumerators: enum WeaponClass { WeaponAxe, WeaponSword, }; enum ImpactSound { ImpactSoundAxe, ImpactSoundSword }; And that's already almost the scoped/typed enum variant.
  3. rnlf_in_space

    How to organize constants? (c++)

    For one, it's called constexpr in a single word. Second, it the advantage of using a typed enum is type safety. Using integers for everything makes the code less easy to understand and easier to confuse different things: constexpr int WEAPON_AXE = 1; constexpr int WEAPON_SWORD = 2; constexpr int ACTION_MOVE = 3; if(unit.action == WEAPON_AXE) { // allowed by the compiler, but clearly not what you want. // something like this will happen sooner or later. Maybe not in an if statement, but // I've seen it happen dozens of times when passing method arguments. // And when it happens, it can be a pain to debug. } enum class WeaponClass { Axe, Sword }; enum class Action { Move, SkipTurn }; if(unit.action == WeaponClass:Axe) // compiler error If you really want to express a number (like mr_tawan's example in the beginning), then a constexpr is a good way to do it. You'll have to make it a static constexpr though, if you want to define it in a header file, or else you will get into trouble when linking.
  4. rnlf_in_space

    How to organize constants? (c++)

    In modern C++, the normal way to do that would be a strongly typed enum like so: enum class WeaponClass { Sword, Axe }; if(weapon.class == WeaponClass::Axe) { ... }
  5. rnlf_in_space

    loop only every 10th or so

    Of course you get flickering when you draw something only every 10th frame. What you probably want to do is store the last computed FPS into a variable and only do the computation every 10th frame, but still draw on every frame.
  6. rnlf_in_space

    How was lighting handled in early 3D games?

    Don't forget that Duke Nukem 3D was released 3 years after DOOM. Half a year before id released Quake. Of course Build engine games looked better at that time.
  7. rnlf_in_space

    Always align memory in array class ?

    Alignment is important for many things. Most CPUs cannot access unaligned memory. If you want to save on the padding, try rearranging stuff inside of your elements or consider going from Array of Structures to a Structure of Arrays, i.e. instead of having struct MyStruct { uint32_t foo; uint16_t bar; }; MyStruct array[100]; // 200 bytes wasted To something like struct MyData { uint32_t foo[100]; uint16_t bar[100]; }; MyData data; // Nothing wasted.
  8. rnlf_in_space

    STB Image

    I am using STBI and I never had a problem. Not sure what kind of trouble you had, but for it's been a smooth ride so far.
  9. rnlf_in_space

    Problem with sleep

    @Luhan M., it will probably take weeks before you notice any difference. A single night is not going to change anything. Continuity is the key to good sleep.
  10. rnlf_in_space

    Problem with sleep

    I had problems sleeping, too. In hindsight, they may have started when I got my first smart phone. I started watching YouTube and whatnot late in the evening while already in bed but recently I am forcing myself to not look at my phone at least an hour before I plan to sleep. Instead I'm reading books (those things made from paper) for an hour. I've only been doing that for three weeks, but I believe it already improved the situation. I tend to fall asleep faster and then wake up a few minutes before my alarm, just like it used to be in highschool.
  11. rnlf_in_space

    Too Many Roads With No Map

    When you're just starting to learn programming and want to do so while making games, why not give LÖVE a try. It's a very powerful but relatively basic and easy to learn 2D game engine. It just takes a few minutes to understand the basics and get an image on screen and a few more to make the image move. It used Lua as its user programming language, which is a very small language that will allow you to focus on the basic principles of programming. But don't think it's a beginner language, it is tremendously powerful when used skillfully.
  12. rnlf_in_space

    Leaving a company at a critical moment

    During the interview for the job I have now, I told the interviewer that I felt it was my obligation to help my previous (then current) company finish an important project and asked them to let me start 2 months later. I expected that to be a problem for them, but quite the contrary: After the interview, they told me they had talked about that and found it meant I was a loyal person and that they felt assured that if I ever left the new company, I'd give them enough time to find a replacement, too. Have you tried talking to the new company about the issue? Maybe they are more open to it than you think.
  13. rnlf_in_space

    Convert functions to linux (gcc)

    I think you may want to use CLOCK_MONOTONIC_RAW instead of CLOCK_MONOTONIC. It doesn't make a huge difference, and mostlikely never causes any notiveable problems, but CLOCK_MONOTONIC may run slower or faster than "real" time, when the clock gets adjusted. Basically, a correctly implemented tool to set system time on a UNIX system will not just set the new time, but rather slow down or speed up the system clock to gradually go to the new time. This is so that there are no jumps in the system time, which will throw off a bunch of things on a UNIX system. CLOCK_MONOTONIC is subject to these adjustments, so you might experience a time where your game does not actually measure one second of realtime as one second, but rather as 1.1s or something like that. CLOCK_MONOTONIC_RAW is never sped up or slowed down.
  14. rnlf_in_space

    Convert functions to linux (gcc)

    There's clock_gettime in Linux. It gives you the time with nano-second resolution (but lower precision, usually), but clock_getres can be used to find the actual precision. You may want to use the clock named CLOCK_MONOTONIC_RAW to get the actual real time that has passed.
  15. rnlf_in_space

    Bit manipulation returning wrong data

    I'm not sure why you even want to go through all the trouble of packing your data like this. Just return a struct { int mouse_x; int mouse_y; } and you're done.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!