Jump to content

  • Log In with Google      Sign In   
  • Create Account

Felix Ungman

Member Since 19 Nov 2007
Offline Last Active Today, 07:50 AM

#5280923 Mobile multiplayer game

Posted by Felix Ungman on 12 March 2016 - 01:40 PM

There are two problems here. One is to synchronize wall clock time, either by using a centralized reference (say ntp), or to guessing from the round-trip time between the clients. The other is synchronizing simulation time, which is solved by using a lookahead. If player 1 presses a button at simulation time T, the change is scheduled to take place at time T+D where D is sufficiently large to be sure that this information has been transmitted to player 2.




#5252291 Linux c++ debugging

Posted by Felix Ungman on 14 September 2015 - 11:28 PM

I'm using CLion from JetBrains (the ReSharper folks), works great on all platforms, including Linux. Highly recommended for modern C++ development.




#5251106 C++11 lambda, modifying copied value

Posted by Felix Ungman on 07 September 2015 - 11:59 PM

Using std::function for lambdas is like using std::vector for arrays. I tend to use both heavily (except in cases where I don't).

 

The advice is to know what you are doing and to know what it will cost you (but that's true for everything in C++!!).




#5248912 C++ duck typing with optional members

Posted by Felix Ungman on 26 August 2015 - 12:08 AM

Nice!!!

 
Some ideas: Put the FindMember classes inside a namespace, e.g. FindMember::Foo instead of FindMember_Foo. Instead of macro TRY_GET_MEMBER, overload operator ->* on these FindMember classes. 
std::vector<DrawItem*>* zpass = view->*FindMember::zpass<std::vector<DrawItem*>();



#5225780 c++ shared_ptr usage

Posted by Felix Ungman on 27 April 2015 - 01:49 AM

I think in order to understand shared_ptr, you should first understand unique_ptr. To fully understand the unique_ptr you need to also understand move semantics (and e.g. how/why unique_ptr is very useful for factory methods). Then you can move on to cases where you need to access the same unique_ptr from different places, and need to convert the unique_ptr into a shared_ptr. And finally there's weak_ptr, that's useful in cases where you have circular references or cached objects. The point is, in order to understand unique_ptr you need to understand all three.




#5211412 What do you use for handling sounds?

Posted by Felix Ungman on 18 February 2015 - 06:20 AM

I've found http://www.libsdl.org/projects/SDL_mixer/ a small, cross platform and easy to use alternative to OpenAL.




#5210222 I this going to be ok as a Network message class

Posted by Felix Ungman on 12 February 2015 - 02:46 AM

You should take a look at https://developers.google.com/protocol-buffers/

 

It uses a domain-specific language to define your messages, and then pre-compiles it to C++ (or other languages). You'll end up with the corresponding message classes above, but it's much more convenient and readable, with less typing and less error-prone.




#5179815 How do you manage object pools in your engine/game?

Posted by Felix Ungman on 12 September 2014 - 03:00 AM

I like to keep things simple and use the new and delete operators most of the time and don't worry that much about allocation. I'm confident that the implementation of new/delete doesn't do anything terribly stupid and that I would have to work really hard to do something better performance-wise. If I need to track objects I put them into an std::vector or sometimes a std::map. There are some cases where I have groups of large numbers of very small objects, and for those I instead use the operator new[] and delete[].




#5178247 GOTO, why are you adverse to using it

Posted by Felix Ungman on 05 September 2014 - 01:26 AM

Oh, I use goto on a regular basis. I've used it twice in the last 10 years, which means I write about one goto statement every fifth year. I'm not adverse, but imho goto is lame, real programmers use comefrom.




#5177822 How Does a Noob Start Creating a Simulator?

Posted by Felix Ungman on 03 September 2014 - 04:18 AM

Install some IDE, there are many good free ones like http://www.jetbrains.com/pycharm/ and try to do something really simple, like http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

 
Implementing Game of Life will highlight some of the basic concepts of writing simulation systems, yet it's possible to implement in few hundreds line of code.



#5177365 Online Course: Understanding Video Games

Posted by Felix Ungman on 01 September 2014 - 12:29 AM

There's a course over at Coursera starting this week that seems worth checking out: https://www.coursera.org/course/uvg

 

An 11-lesson course teaching a comprehensive overview of analytical theory pertaining to video game media. Topics covered: play and game, emergence versus progression, game mechanics, story, interpretive theory, the culture of games, violence, sex and race in games, and finally, serious games. Estimated workload: 3-5 hrs/wk for non-credit; 7-10 hrs/wk for credit.

 
About the Course
 
Video games are a globally entrenched entertainment medium that entertains, informs and challenges us. These games are defined by, and define our modern culture. In this course, students will learn how to study games and engage in informed discussions about them. Ultimately, this course is about understanding the literacy of video games.
 
Understanding Video Games was created with the help of world renowned video game developer, BioWare Corp, located in Edmonton, Alberta.
 
The three main parts of the course are: 
 
1) developing the terminology that enables us to talk about video games; 
 
2) exploring how these terms are used in theoretical frameworks to interpret games, and; 
 
3) turning these theories toward cultural aspects of games in order to understand how the medium has impacted society. One of the most important insights students will gain from the course will be an understanding of the interplay between video game designers, players and the games themselves.

 

 

 




#5170132 Can somebody explain this code to me, please

Posted by Felix Ungman on 29 July 2014 - 12:06 PM

I don't know perl, but isn't it supposed to be a write-only language?




#5154331 Member variable as template paramter

Posted by Felix Ungman on 17 May 2014 - 04:11 PM

Ok, the example maybe didn't illustrate what I meant, a better one might be:  

class ButtonWidget
{
    std::function<void()> _onClick;

public:
    void SetOnClick(std::function<void()> action) { _onClick = action; }

private:
    void TrackClick()
    {
        // ...
        if (_onClick)
            _onClick();
        // ...
    }
};

Then you can fix the data you want to hold in the lambda:

for (int i = 0; i < n; ++i) {
    int buttonNumber = i;
    button[i]->SetOnClick([buttonNumber]() {
       ButtonWasClicked(buttonNumber);
    }
});

Code is simple but powerful. I don't know how it relates to your framework or how you would need to rewrite it (it seems you use signals both for events and for data bindings, right?), but I've found the technique very useful in my own gui code.




#5153492 Opinion needed: returning values without null checks everywhere

Posted by Felix Ungman on 14 May 2014 - 12:32 AM

Objective-C has an interesting take on this problem. If you have a nil object reference, calling a method is a no-op, and calling a function returns a default value (i.e. zero, false, or nil). Good coding practice is *not* checking the object for nil, but instead just send the message and checking the return value instead. Unfortunately there's no simple equivalent construction in C++.




#5145914 I have some new habits.

Posted by Felix Ungman on 10 April 2014 - 06:12 AM


I have a much easier time thinking of someone with a background with a function based (not functional lambda calculus) experience like C/Pascal will do a better job at designing software than someone with a (bad) OOD background. He or she would use the modules approach of Pascal and apply it to OOP and we would all be happier for it.

 

I'm sure a bad designer would produce crappy work no matter the methodology. Granted, OOP gives you a richer set of tools to introduce strange and unnecessary relationships, and in that case sticking to C/Pascal might give you some damage control.

 

I think the problem here is that when you are learning a new methodology, you write small toy-world pieces of code of very limited complexity. But in the real world, projects grow and requirements change and complexity seems to grow without bounds. With a team of inexperienced developers you tend to get a lot of redundancy (failing to see that different parts of a system share a common concept) and a lot of bad dependencies (such as realizing that another part of the system is doing something related to what you're coding so you do a quick-and-dirty rewiring). Time constraints and deadlines don't make things better.  You need an experienced designer willing to take the time to constantly re-evaluate the design as the system grows.

 


I am always trying to improve and to know more about OOD (a new improved way) is always interesting.

 
I highly recommend Evans Domain Driven Design. Beware that it's not a beginners book. Although it has a lot of patterns (OODish or whatever you want to call it), I think the main point is more the process or rather mindset when designing large software systems.





PARTNERS