• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

staticVoid2

Members
  • Content count

    636
  • Joined

  • Last visited

Community Reputation

381 Neutral

About staticVoid2

  • Rank
    Advanced Member
  1. Hi, I'm currently stuck in a bit of a rut trying to solve a problem, this is something I've been working on for the past few weeks and I still can't seem to come up with a good solution. I have a system which is currently split into four main parts:     1. API                   (Subject)     2. Core System    (Real Subject)     3. Network Proxy  (Proxy)     4. User Interface And structured like so:         As you can see, this follows the Proxy pattern (https://en.wikipedia.org/wiki/Proxy_pattern) where I have a 'proxy' implementation of the API which allows the system to be run over a network; the proxy objects live on the client and communicate with the server via HTTP. The API consists of a couple of interface classes representing objects the developer can access and manipulate. These objects generally have a lot of accessor methods for various properties and some of them have a one-to-many relationship with other objects. As an example: // Subject/API class IObjectA { public:     virtual int getValue1() const = 0;     virtual int getValue2() const = 0;     virtual int getValue3() const = 0;     // ... lots more accessors     virtual void createObjectB() = 0;     // IObjectA should have a collection of IObjectB     virtual std::vector<IObjectB*> getObjectBs() const = 0; }; // Real Subject class ObjectA : public IObjectA { public:     virtual int getValue1() const override { return value1; }     virtual int getValue2() const override { return value2; }     virtual int getValue3() const override { return value3; }     virtual void createObjectB() override     {         objectBs.push_back(new ObjectB()); // ObjectB implements IObjectB     }     virtual std::vector<IObjectB*> getObjectBs() const override { return objectBs; } private:     int value1, value2, value3;     std::vector<ObjectB*> objectBs; }; // Proxy class ProxyObjectA : public IObjectA { public:     virtual int getValue1() const override     {         JSONObject obj = SendHTTPRequest("GET", "/objectA");         return obj["value1"].asInt();     }     virtual int getValue2() const override { /* Similar to above */ }     virtual int getValue3() const override { /* Similar to above */ }     virtual void createObjectB() override     {         // Create a new object on the server         SendHTTPRequest("POST", "/objectAs/objectBs", "" /*empty object*/);     }     virtual std::vector<IObjectB*> getObjectBs() const override     {         JSONObject obj = SendHTTPRequest("GET", "/objectA/objectBs");         std::vector<ObjectB*> objectBs;         for(JSONObject objB : obj["objects"])         {             objectBs.push_back(new ObjectB(objB));         }         return objectBs;     } }; The user interface currently interacts directly with the API, calling into the above accessor methods every ~0.5 seconds to refresh the view data. This is fine when the underlying implementation is 'ObjectA' however it slows the system down to a crawl when using the 'ProxyObjectA' implementation due to the server response times. Attempt 1: The first solution that came to mind was to incorporate some sort of callback system into the accessor methods, fundamentally changing the API so you would have calls that looked like: IObjectA* obj = ...; obj->getValue1([](int value1){ /* Do something */ }); This made it clear that the implementation could potentially take a long time but it also seemed like it might spiral into callback hell (from an API design point of view), especially with the number of accessor methods present, and after reading this article: http://www.drdobbs.com/parallel/prefer-futures-to-baked-in-async-apis/222301165 I decided that this was probably not the way to go. Attempt 2: So the next approach I took, following the advice in the article, was to simply revert back to what I had originally and allow the API implementations to take as long as they needed to retrieve the data their interface had promised. This drastically simplified the code and prevented synchronization issues when it came to creating objects (createObjectB) and accessing them (getObjectBs) (see below). It also just made a lot more sense, looking at the method implementations you could clearly see what these methods were doing (or at least what their main intention was). However, performance was still a real issue when it came to the UI so I had to make another attempt. Attempt 3: The next approach I tried was to spawn a separate thread which would constantly retrieve all the data it needed from the server every second or so for the duration of the application. So the 'ProxyObjectA' class now looked a bit like so: // Proxy class ProxyObjectA : public IObjectA { public:     virtual int getValue1() const override     {         std::scoped_lock lock(mutex);         return value1;     }     virtual int getValue2() const override { /* Similar to above */ }     virtual int getValue3() const override { /* Similar to above */ }     // This method still blocks...     virtual void createObjectB() override     {         // Create a new object on the server         SendHTTPRequest("POST", "/objectAs/objectBs", "" /*empty object*/);     }     virtual std::vector<IObjectB*> getObjectBs() const override     {         std::scoped_lock lock(mutex);         return objectBs;     }     // This methods gets called every second from a separate     // thread with new information from the server     void update(int value1, int value2, int value3, const std::vector<ObjectBs>& objectBs)     {         std::scoped_lock lock(mutex);         this->value1 = value1;         this->value2 = value2;         this->value3 = value3;         this->objectBs = objectBs;     } private:     // Cached values     int value1, value2, value3;     std::vector<ObjectB*> objectBs;     mutable std::mutex mutex; }; This worked fairly well, but I still had a few reservations about it: 1. For a start, having a separate thread constantly retrieve data from a server seems like a terrible solution, considering this would be running for the duration of the application and most of the time would not be getting accessed at all. 2. There could be cases where I would add a new 'B' object via the 'createObjectB' method and then a subsequent call to 'getObjectBs' would return an empty vector because it had not been updated from the server yet. 3. Constantly locking and unlocking mutexes also seemed like a terrible thing to do and there was still some noticeable flicker in the UI, presumably caused by this. 4. Values will generally be out of date, and this is not made apparent from the interface.   However, this was the only solution which provided some form of batching the data into as few requests as possible, the previous attempts would all have to send individual HTTP requests for every accessor method call. This is basically my problem in a nutshell, I've had three attempts at fixing this to no avail so I thought I would ask for some advice. I'm probably going about it the wrong way or there is some obvious solution staring me in the face but I can't seem to see it. It feels like a check-mate situation :( I would be grateful if anyone could point me in the right direction, especially if you know of any existing systems that are similar to this and have managed to solve these problems.   Thanks   
  2. This is the solution I currently have implemented; I have an interface for an object which exists on a server and I have a polling thread which polls the REST service and updates the objects data internally. Apart from having to synchronize the update with all of the accessor methods it seems to work ok. One thing I should have mentioned was that I have lots of accessor methods for this object - in the example I provided there was only one 'getValue' method so it would have been fairly easy to wrap this up in a std::async call or some other utility but I'm not sure how I would have gone about this when trying to access multiple properties very frequently.
  3.   I agree, one of the reasons I had added the interface was to simplify the calling code and abstract away the details of server communication and asynchronous requests, The idea being you could just call "obj->getValue()" without thinking twice about it. It looks like the asynchronous stuff is unavoidable though.   I think the polling/promise pattern might be what I'm looking for, however I might also consider just building some utility class that will wrap up the interface and provide asynchronous methods, e.g: InterfaceWrapper wrapper(obj); wrapper.getValue([](int value){ /* Do something here */ }); This would let the implementation focus on just retrieving the specific value and not concern itself with the asynchronous stuff.       Most of the interface methods return a generic error code which encompasses all potential errors (of all implementations). The error handling code is treated separately from the implementations that generate the error codes, so for example if it receives a 'server off-line' error code it can treat this as an independent error state and e.g. ask the user if they would like to send an error report etc.
  4. Hi,   I have a problem at the moment where I have an interface which has multiple implementations but the response times of the methods of each implementation can vary significantly. For e.g: class Interface { public: virtual int getValue() = 0; }; The first implementation (class A) simply returns a member variable and has a very quick response time: class A : public Interface { public: virtual int getValue() override { return this->value; } private: int value; }; However, the second implementation (class B) contacts a RESTful web service and the response time can be potentially quite long: class B : public Interface { public: virtual int getValue() override { // Send request to server // Wait for response // return value } }; My question is, in these cases where response times differ should it be the responsibility of the implementation to ensure response times are consistent or should the interface itself be wrapped up in some asynchronous call mechanism (i.e. call these methods from another thread)?   I can see pros and cons of both approaches; If the implementation had to ensure a fast response time then in the case of class B it might need to return some default/incorrect value the first time it is called (which might be acceptable). Calling the interface from a separate thread would solve this however it would fundamentally change the way you would need to interact with the interface which might get a bit messy.   Or are there are any existing design patterns or solutions for this problem which I am missing?   Thanks.
  5. Hi,   Does anyone know if it is possible to add custom resource types in MFC?   I'm looking to batch certain resources together, a few strings and perhaps a bitmap resource under one resource ID in MFC. Looking through msdn the only thing I could find was resource templates but I believe this is for something different entirely.   I'd be looking to have a function similar to e.g. LoadIcon() but which returns a custom data structure for this new resource type e.g. MyResource res; LoadMyResource(res, <resource_id>); Is this possible in MFC?   Thanks.
  6. Hi,   I came across an issue recently and was quite curious as to why it was happening - I managed to fix the problem but the reason for it occurring still alludes me.   Basically I'm using a singleton class whose instance is wrapped in a std::unique_ptr like so:   Header: #pragma once #include <boost/thread.hpp> #include <memory> class Singleton { public: ~Singleton(); static Singleton* Instance(); private: Singleton(); boost::thread m_thread; static std::unique_ptr<Singleton> m_sInstance; } .cpp #include "Singleton.h" std::unique_ptr<Singleton> Singleton::m_sInstance = nullptr; std::atmoic_bool gCond; void ThreadFunction() { while(gCond) { } cout << "Hello World" << endl; } Singleton::Singleton() { gCond = true; m_thread = boost::thread(ThreadFunction); } Singleton* Singleton::Instance() { if(m_sInstance == nullptr) { m_sInstance = std::unique_ptr<Singleton>(new Singleton()); } return m_sInstance.get(); } Singleton::~Singleton() { if(m_thread.joinable()) { gCond = false; cout << "joinable" << endl; m_thread.join(); cout << "joined" << endl; } } The singleton uses lazy initialization therefore the first call into the 'Instance' method will construct the singleton and subsequently start the thread. The problem occurs in the destructor where I attempt to join the thread. In my main application method I have the following: int main() { Singleton::Instance()->DoSomething(); return 0; } The output of the program is as follows:   joinable joined   The singleton destructor gets called correctly but when it attempt to join it does not actually finish executing the ThreadFunction method - this method does get called and is spinning until the gCond variable is set to true. Whats puzzling is that the m_thread object reports to be joinable but the subsequent call to join does not actually do anything. I've also checked the join method pre-condition:   this->get_id()!=boost::this_thread::get_id()   which is true.   When I modify the code to explicitly call a shutdown method at the end of main where the shutdown method does the same as the destructor: int main() { Singleton::Instance()->DoSomething(); Singleton::Instance()->Shutdown(); return 0; } It works fine and the program output is as expected:   joinable Hello World joined     I'm not entirely sure why the destructor is failing to join or in-fact how destructors of objects declared in global scope operate. I assumed this was to perhaps to do with a boost sub-system which is also using a global object destructor to uninitialize all its boost::thread objects. Another assumption was that the main method had already finished and therefore the thread had lost its context when the destructor was called and join failed.   I added in the explicit shutdown as a fix but it would interesting to know exactly why this is happening.   Cheers.  
  7. I was under the impression that PPL was not cross platform due to it being a Microsoft library?
  8. Hi   Does anyone know of any good cross-platform Task scheduling frameworks / libraries available in C++? I'm looking for something similar to the C# task scheduler in terms of functionality.   I've looked into the Parallel Patterns Library but seems to low level for what I need.   Thanks.
  9. Hi,   I have a class (A) which contains 'Listeners' or 'Observers' which need to be informed when certain things happen in class A. This currently involves iterating over all listeners and calling a certain notification method for example: for(Listener listener : listeners) { listener->InformOfSomething(1, 2, 3, 4); } I was wondering if there is any convenient way in c++11 to reduce this to a one-liner without having to create additional functions or use lambdas (or even remove the brackets ;)   The approach I'm looking for would be something similar to jQuery where functions act on collections of objects as opposed to single items. For e.g. maybe something as simple as this: $(listeners).InformOfSomething(1, 2, 3, 4); (please forgive the shameless copy of jQuery syntax)   Where the $ syntax acts in a similar way to range-based for loops and requires begin() and end() functions on the 'listeners' param which then iterates the collection and substitutes the item in the collection with first parameter of the proceeding function (or more specifically the 'this' pointer when using a class member function).   Anything like this in c++11 or any better way to do it?   Thanks.
  10. Hi,   I just thought I would post this incase anyone is interested.   In August of last year I released a game on Google play and after its somewhat failed success I made it free-to-play and have now decided to release the source code which can be found here:   http://sourceforge.net/projects/dreadsarmy/   The game only made something like £15 overall which was about 5 months of work (a few months also working full-time for a games company). I suppose this is partly my fault for not capitalising on the micro-transactions approach most companies are taking nowadays (i.e Clash of Clans) and also for not having a marketing division but hey.   Just thought this might be useful to some people starting in Android mobile development, the code is very simple, the majority of work was the artwork which was done in Blender.   Cheers.
  11.   I use to work in the games industry but now work for a general software company, I have full access to a PC at my work, limited to between Monday and Friday. I doubt they would let me work on side projects that weren't to do with work as ferrous mentioned, but I could be wrong on this.   That being said, I don't really want to take on any new projects based on the amount of time I spent of my last one and the lack of success it had.
  12. Ok, so I'm thinking of selling my PC soon in an attempt to simplify my life a bit.   I'm tired of stressing out over some game that I know I will never complete and I find development these days to be a very isolated experience and somewhat detrimental to my mental health. I'm in the process of uploading my projects (completed and uncompleted) to sourceforge under an open source license.   I just wanted to know if you guys think it is still possible to be good software developer without actually owning a home PC? Granted it is what I do for a living :(   Cheers.
  13. Hi,   I started writing a desktop application not that long ago and instead of using my traditional approach of simply coding everything in C++ and using a few external libraries I decided to write the application in javascript + HTML5.   At first I considered writing just the front-end UI in javascript but as I discovered more and more libraries such as Three.js I thought I might aswell just code the entire application in javascript and only create a few interfacing functions to the system, such as reading/writing files.   I was just wondering if by-and-large you would consider this to be a bad solution for a desktop application, I'm at the stage currently where I could easily start developing the application again in C++ and perhaps use OGRE or some other equivelent graphics library.   I know that web applications are all the rage nowadays buy I don't know if developing a 'web' application purely for desktop is a justified approach, considering the additional layer of abstraction and that javascript, even though an extremely powerful language, does lack a bit in certain areas.   I was just wondering what aproach you would take?   Thanks.
  14. I think the closest Software Design pattern to what you are describing is the Command Pattern
  15. Thanks