• 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.


  • Content count

  • Joined

  • Last visited

Community Reputation

354 Neutral

About Misery

  • Rank

Personal Information

  • Location
  1. It does the same in my case. Win 10 VS2015 using TDM-GCC causes crash as well.
  2. It is supposed to be an image filter for smartphone. I am not worry about overflow or underflow as I am able to control it.
  3. Hello,   I would like to store four c++ chars in one int (or other int data types compatibile with each other in such way) and perform basic operations on them in such way that the operation would be done for all of the elements at once (to speed up computations). Like in the example below: union{  uint8_t i8[4];  uint32_t i64; } A,B,C;     A.i8[0]=10;     A.i8[1]=14;     A.i8[2]=2;     A.i8[3]=5;     B.i8[0]=8;     B.i8[1]=4;     B.i8[2]=2;     B.i8[3]=2;     cout<<"A = "<<short(A.i8[0])<<" "<<short(A.i8[1])<<" "<<short(A.i8[2])<<" "<<short(A.i8[3])<<endl;     cout<<"B = "<<short(B.i8[0])<<" "<<short(B.i8[1])<<" "<<short(B.i8[2])<<" "<<short(B.i8[3])<<endl;     C.i64=A.i64+B.i64;     cout<<"A+B="<<short(C.i8[0])<<" "<<short(C.i8[1])<<" "<<short(C.i8[2])<<" "<<short(C.i8[3])<<endl;     C.i64=A.i64-B.i64;     cout<<"A-B="<<short(C.i8[0])<<" "<<short(C.i8[1])<<" "<<short(C.i8[2])<<" "<<short(C.i8[3])<<endl;     C.i64=A.i64*B.i64;     cout<<"A*B="<<short(C.i8[0])<<" "<<short(C.i8[1])<<" "<<short(C.i8[2])<<" "<<short(C.i8[3])<<endl;     C.i64=A.i64/B.i64;     cout<<"A/B="<<short(C.i8[0])<<" "<<short(C.i8[1])<<" "<<short(C.i8[2])<<" "<<short(C.i8[3])<<endl; The addition and subtraction works just fine, however I don't really have any idea to how to perform multiplication and division in such way. I was planning to use SSE, however it turned out that the target platform might not have ability to use SSE functionality. How to force C++ to multiply and divide properly four chars one by one like it happens in SSE?
  4. Hi there,   I am working on an adventure TPP game in which the game character is a hacker. It is the minor feature of the game, however the player from time to time will have to break some codes, hacks some computers etc. I would very much like to deliver a bit of reality in that aspect like using command line, searching patterns in memory dumps, installing keyloggers and so on (Just to make player feel like me when I was a kid at school shutting down all PCs via net to my class-mates during IT classes). However I cannot assume that person playing this game will have any experience in hacking, bash, programming, scripting or any OS administration. So I would like to ask for any tips that would help me to make this enough easy for player but still interesting and giving the sense of really hacking into a computer.   For now I have designed it in such way that the game character is a hacker and he has the knowledge on how to do hacking stuff. So the player only does quite simple tasks like installing keylogger and watches the rest being done by the character. For example: you are supposed to break into some wi-fi spot. You get the menu with options which are explained by the game character. When choosing one, then you have update in your notepad what you need to do to achieve the goal. Any suggestions on how to improve that part?    
  5.   Thanks for your advise. I agree with you absolutely. However my approach allows to conversions only if such converions are explicitly defined by user or by the language standard. Therefore I find it nice approach. And in the case of lack of conversion function it prompts pretty error message instead of huge message. Therefore I care much about implementing it that way.
  6. I am implementing expression templates for Vector3<> template class in C++. Actually I have it working very well, but only when arguments of the same type are involved. Lets say Vector3<double> and Vector3<double> or double scalar and Vector3<double>, etc. In the case of for example multiplying Vector3<double> and Vector3<float> compiler prompts error, as it these are two different objects and it is unable to perform float to double conversion by itself.  To solve this issue I had two ideas: 1. Define all necessary classes and operators in terms of possible interactions float and double, float and int etc. Which is very very wrong approach 2. Create templates using auto and decltype   I managed to achieve somewhat a success. I can create a Vector3<anything1> and perform operations on it with other Vector3<anything2>. So it is a clean and nice solution, as it does not require to define all possible conversions. However when I try to perform an operation between any scalar and Vector3<anything> I get errors.   Different operators (in the code below it would be Vector3<DATA_TYPE_L>*Vector3<DATA_TYPE_R> and scalar DATA_TYPE_L*Vector3<DATA_TYPE_R>) interfere. Separately both operators work fine. However when both are present compiler always chooses scalar*Vector3<> operator, and of course fails to deduce arguments when Vector3<>*Vector3 operator should be used. I managed to solve this situation only by providing additional class Scalar<DATA_TYPE> which embraces the scalar value. However then I have to call some function creating Scalar class explicitly out of let's say double. This is something I would like to avoid.   So I thought of two solutions: 1. Make the operator create Scalar class transparently out of float or double etc. so no explicit usage of function creating Scalar would be needed 2. Redesign the code so operators wouldn't interfere However I did not manage to achieve any of those. Any help would be very appreciated. The Code below works fine in VS2015. Remove comments to get mentioned error. typedef  int SIZE_INT; template <class DATA_TYPE, class Expression> class Vector3Expression { public:     auto operator[](SIZE_INT i) const { return static_cast<Expression const &>(*this)[i]; }     operator Expression&() { return static_cast<      Expression&>(*this); }     operator Expression const&() const { return static_cast<const Expression&>(*this); } }; template <class DATA_TYPE> class Vector3 :public Vector3Expression<DATA_TYPE, Vector3<DATA_TYPE> > { public:     DATA_TYPE Data[3];     Vector3() {}     Vector3(const Vector3& that)     {         Data[0] = that.Data[0];         Data[1] = that.Data[1];         Data[2] = that.Data[2];     }     Vector3(Vector3&& that)     {         std::move(that.Data, 3, Data);     }     template <class OTHER_DATA_TYPE, class Expression>     Vector3(Vector3Expression<OTHER_DATA_TYPE, Expression> const& VE)     {         Expression const& ve = VE;         Data[0] = ve[0];         Data[1] = ve[1];         Data[2] = ve[2];     }     //access operators     DATA_TYPE&  operator[](SIZE_INT i) { return Data[i]; }     DATA_TYPE  operator[](SIZE_INT i) const { return Data[i]; }     DATA_TYPE&  operator()(SIZE_INT i) { return Data[i]; }     DATA_TYPE  operator()(SIZE_INT i) const { return Data[i]; }     //operators     Vector3<DATA_TYPE>& operator=(Vector3<DATA_TYPE> &&that)     {         if (&that != this)         {             std::swap(Data[0], that.Data[0]);             std::swap(Data[1], that.Data[1]);             std::swap(Data[2], that.Data[2]);         }         return *this;     }     Vector3<DATA_TYPE>& operator=(const Vector3<DATA_TYPE> &that)     {         if (&that != this)         {             Data[0] = that.Data[0];             Data[1] = that.Data[1];             Data[2] = that.Data[2];         }         return *this;     }     SIZE_INT  Length() const {         return SIZE_INT(3);     }     };     template <class DATA_TYPE_LHS, class DATA_TYPE_RHS, class Lhs, class Operator, class Rhs>     class Vector3Vector3Operation : public Vector3Expression<decltype(Operator::Apply(DATA_TYPE_LHS(), DATA_TYPE_RHS())), Vector3Vector3Operation<DATA_TYPE_LHS, DATA_TYPE_RHS, Lhs, Operator, Rhs> >     {     private:         Lhs const& vL;         Rhs const& vR;     public:         Vector3Vector3Operation(Vector3Expression<DATA_TYPE_LHS, Lhs> const & lhs, Vector3Expression<DATA_TYPE_RHS, Rhs> const & rhs) : vL(lhs), vR(rhs) {}         auto operator[](SIZE_INT i) const { return Operator::Apply(vL[i], vR[i]); }     };     template <class DATA_TYPE_LHS, class DATA_TYPE_RHS, class Operator, class Vec>     class ScalarVector3Operation : public Vector3Expression<decltype(Operator::Apply(DATA_TYPE_LHS(), DATA_TYPE_RHS())), ScalarVector3Operation<DATA_TYPE_LHS, DATA_TYPE_RHS, Operator, Vec> >     {     private:         const DATA_TYPE_LHS S;         Vec const& V;     public:         ScalarVector3Operation(const DATA_TYPE_LHS s, Vector3Expression<DATA_TYPE_RHS, Vec> const& v) : V(v), S(s) {}         auto operator[](SIZE_INT i) const { return Operator::Apply(S, V[i]); }     };     namespace meta {         template<class DATA_TYPEL, class DATA_TYPER = DATA_TYPEL>         struct Multiply         {             inline static auto Apply(DATA_TYPEL a, DATA_TYPER b)->decltype(a*b) { return a*b; }         };     }     template <class DATA_TYPEL, class DATA_TYPER, class LExpression, class RExpression>     Vector3Vector3Operation<DATA_TYPEL, DATA_TYPER, LExpression, meta::Multiply<DATA_TYPEL, DATA_TYPER>, RExpression> const         operator*(Vector3Expression<DATA_TYPEL, LExpression> const& u, Vector3Expression<DATA_TYPER, RExpression> const& v)     {         return Vector3Vector3Operation<DATA_TYPEL, DATA_TYPER, LExpression, meta::Multiply<DATA_TYPEL, DATA_TYPER>, RExpression>(u, v);     }     /* //operator causing trouble     template <class DATA_TYPE_LHS, class DATA_TYPE_RHS, class RExpression>     ScalarVector3Operation<DATA_TYPE_LHS, DATA_TYPE_RHS, meta::Multiply<DATA_TYPE_LHS, DATA_TYPE_RHS>, RExpression> const     operator*(const DATA_TYPE_LHS s, Vector3Expression<DATA_TYPE_RHS, RExpression> const& v)     {     return ScalarVector3Operation<DATA_TYPE_LHS, DATA_TYPE_RHS, meta::Multiply<DATA_TYPE_LHS, DATA_TYPE_RHS>, RExpression>(s.value, v);     }     */     int main()     {         Vector3<double> d, x, u;         Vector3<float> f;         double s = 0.25;         d[0] = 1; d[1] = 2; d[2] = 3;         x = d;         f[0] = 3; f[1] = 2; f[2] = 1;         u = d*f;         std::cout << u[0] << " " << u[1] << " " << u[2] << std::endl;         u = d*x;         std::cout << u[0] << " " << u[1] << " " << u[2] << std::endl;         //u = s*d*x; //does not work         std::cout << u[0] << " " << u[1] << " " << u[2] << std::endl;         getchar();         return 0;     }
  7. Is it worth to implement expression templates for classes representing two or three dimensional vector? Expression templates improve performance, however I'm not sure if it is reasonable to implement such functionality when dealing with such simple class.
  8. @Aardvajk you are using a method instead of the class field. My question is just a spin-off of this question.
  9. @Madhed I forgot to add that it shouldn't add any memory overhead like it is with using references. I am just curious - no special need for it. I am still learning C++.
  10. Let's say there is a class foo that has a variable of another class, call it C. Is is possible to access C members by a field of foo? EDIT: I forgot to mention that it should be without any additional memory or significant performance loss (like with using references - mem loss). class C {   public:   float t; }; class foo {   public:    C c;    float x; //this should access c.t } f; float T=f.x; //returns foo.c.t  f.x=5f; The similar example was given by Alvaro, however it regards an access between two fields of one class: struct vector3 {     float x, y, z;     float& operator[](int index) {         assert(index >= 0 && index < 3);         return this->*members[index];     }     float operator[](int index) const {         assert(index >= 0 && index < 3);         return this->*members[index];     }     static float vector3::* const members[3]; }; float vector3::* const vector3::members[3] = { &vector3::x, &vector3::y, &vector3::z};
  11. Recently I started to use unity3d for my hobby game project and I really liked a Vector3 (and similar) classes (in C#). At the moment at work I am implementing a simple (but for large simulations) SPH solver. What I would like to achieve is a similar Vector3 class in C++ in the means of access to elements both by v.x, v.y, v.z and v[0], v[1], v[2]. In general to obtain this is very simple, but none of the solutions that came to my mind is free of flaws.   Solution 1: using references &x, &y, &z, problem: such class has three additional variables which occupy the memory. In the case of large simulation it is problematic: template <class T>   class Vector3   {     public:         T &x,&y,&z;         T v[3];         Vector3(): x(v[0]), y(v[1]), z(v[2])         {           v[0]=0; v[1]=1;  v[2]=2;         }         T& operator[](int i)         {             return v[i];         }   }; The access is very elegant: v[i] as well as v.x, v.y and v.z And this is what I woluld like to obtain - this elegant access. However the additional memory overhead is unacceptable.   Solution 2: using class fileds x,y,z and access operator with if statement: problem performance of [] operator template <class T>   class Vector3   {     public:         T x,y,z;         Vector3(): x(0), y(1), z(2)         { }         T& operator[](int i)         {             if (i==0) return x; else if (i==1) return y; else if (i==2) reurn z; else { //throw access error }         }   }; This solution is elegant as well, but the operator [] will be very slow.   Solution 3: Using the class functions x(), y(), z() template <class T>   class Vector3   {     public:         T v[3];         Vector3()         {           v[0]=0; v[1]=1; v[2]=2;         }         T& operator[](int i)         {             return v[i];         } T& x() { return v[0]; } T& y() { return v[1]; } T& z() { return v[2]; }   }; This solution is ideal in means of efficiency and memory overhead, but, does not allow elegant access to members, requires for example v.x() instead of v.x.   The question is: is there a way to obtain this elegant access with no efficiency and memory loss?    
  12. Thanks a lot. Now I know where were the issues :]