Jump to content

  • Log In with Google      Sign In   
  • Create Account

TheComet

Member Since 02 Oct 2013
Offline Last Active Today, 08:09 AM

#5110764 wxhtml MyApp::OnInit()

Posted by TheComet on 20 November 2013 - 08:58 AM

You need to instantiate a "MyApp" object in order to call method functions:

int main()
{
    MyApp theApp;
    theApp.OnInit(); // <-- like this

    return 0;
}

But since you're deriving your app from WxApp, I'm going to assume the function OnInit is called automatically for you, so it's a bad idea to call it yourself. That's the whole idea of deriving from a base App class, so the library you're using has control over when to execute what in your program.

 

What are you trying to do?




#5110501 need an algorithm for following a path (curved line)?

Posted by TheComet on 19 November 2013 - 10:44 AM

What you're looking for is an appropriate interpolation algorithm, if the path you wish to follow can be represented mathematically.

 

The Bezier Curve is a good place to start. Maybe you could even use cubic interpolation.

 

If the path cannot be represented mathematically, then I suggest trying to approximate it as best as possible using the interpolation algorithms mentioned above, or create waypoints along the paths for your characters to follow. You could even use interpolation between waypoints to make transitioning ultra smooth.




#5110450 How translate a polygon on Earth?

Posted by TheComet on 19 November 2013 - 07:01 AM

So basically?

 

2alSC.png

 

I think you'll have to give us a little more information on what you're trying to do. Are you talking about spherical trigonometry? http://en.wikipedia.org/wiki/Spherical_trigonometry




#5109420 Your favorite Game Engine

Posted by TheComet on 15 November 2013 - 05:58 AM

I think the reason why you didn't immediately find an answer to your question is the fact that the answer isn't obvious to begin with.

 

There is no superior game engine. There is no game engine that is "the best", and there isn't a "favorite" game engine either.

 

A developer will select a game engine specific to his or her needs. For instance, if I wanted to write the next MMOFPS, I would most likely go with UDK, because that game engine is centered around first person game play. On the other hand, if I wanted to make an RPG, Unity might be a better choice.

 

Or maybe those engines aren't specialized enough for my new 3D RTS space simulator game, in which case I might choose Ogre3D for my graphics engine and write the game using C++.

 

The answer is: "it depends".

 

With that said, I suppose you could compare game engines that work on the same fields. For instance, SDL vs SFML for 2D graphics, or Ogre3D vs Irrlicht for 3D graphics. In these cases, it can come down to the biased opinion of the developer; I love Ogre3D and would choose it over Irrlicht. If I had to back this up with some form of justification, my arguments would be that development on Irrlicht has stopped, where Ogre3D is currently being brought up to speed to work with new generation graphics (Ogre 2.0), so the obvious choice would be Ogre.

 

Obviously there are engines that are terribly designed, but even they have their advantage when used correctly.

 

You'll be best off dividing the engines into their field of specialty, and comparing them on that basis.




#5109403 Using a Notepad in Industry to keep track of modified code

Posted by TheComet on 15 November 2013 - 04:47 AM

What about Mercurial?

 

...And it begins.

 

Git vs. Mercurial: Please Relax (Git is MacGyver and Mercurial is James Bond)

The Differences Between Mercurial and Git

Git is Wesley Snipes, Mercurial is Denzel Washington

 

My honest opinion on Mercurial: To me it feels like Mercurial is just unnecessary. It does everything git does, only slower, and it's missing a few features. Plus the name "Mercurial" is unfortunate. Not catchy and doesn't "feel" good. That's just my opinion. I'm not denying Mercurial is a good VCS; quite the contrary, it does what it's designed to do and it does it well.

 

If you tell me to use Mercurial over Git, though, the reason I wouldn't switch is not because I prefer git, but because the time it would take to learn how to use Mercurial would outweigh the supposed benefit you claim it has.

 

I'll quote the first article. The bottom line is:

 

  1. Evaluate your workflow and decide which tool suits you best.
  2. Learn how to use your chosen tool as well as you possibly can.
  3. Help newbies to make the transition.
  4. Shut up about the tools you use and write some code.

 

 




#5108739 How to do starcraft 2 pathfinding?

Posted by TheComet on 12 November 2013 - 11:50 AM

@ankhd - Grids are memory expensive and don't deliver accurate results when compared to a navigation mesh.

 

 

 

What exactly are the nodes of A* on navmesh?

 

Let me shed some more light on this question.

 

The nodes of A* on a navigation mesh are the vertices of the navigation mesh. When searching with A*, you assume the navigation mesh is a waypoint graph, because due to the convexity of each polygon, you know that each node is directly connected to every other node within the polygon, so there's absolutely no difference between a search on a navigation mesh and a search on a waypoint graph.

 

This article explains it very well.

http://udn.epicgames.com/Three/NavigationMeshReference.html

 

The only difference between a navigation mesh and a waypoint graph is the vertices of a navigation mesh hold information about an area rather than a single passable point. After the path has been found, the next step is to apply a funnel algorithm to simplify the found nodes into a more direct path.

http://digestingduck.blogspot.de/2010/03/simple-stupid-funnel-algorithm.html

 

I recommend reading through the documentation of the two libraries recastnavigation and detour. They are documented on CritterAI's website: http://www.critterai.org




#5107133 Such code. Wow. So Shibe. Very doge.

Posted by TheComet on 05 November 2013 - 05:28 AM

wow

such compile

doge/10

very code

shibe doge wow

 

Did you run it on this?

tumblr_mvpvubQQj51syccr0o1_500.png




#5103819 How to write a undertemined size array to a txt file?

Posted by TheComet on 23 October 2013 - 12:24 PM


but how do i assign those values into my variables? and how do i do it if it's, for example, an array?

That's basically what my code is demonstrating. It's reading an arbitrary amount of data from a text file and pushing them into an std::vector<T> (remember, that's an "array").

 

Maybe I'm not quite understanding what you're asking. Could you elaborate more? What arrays are you using now? Are you using std::vector<T>? Please post your declaration of playerItem[] again so we're on the same page.

 

Can you also provide the code you're using to write to the file?




#5103816 How can I gain a deeper understanding of C/C++?

Posted by TheComet on 23 October 2013 - 12:18 PM

Ouch, after going through all of those slides I've suddenly become depressed about my knowledge.




#5103783 How to write a undertemined size array to a txt file?

Posted by TheComet on 23 October 2013 - 10:48 AM

The first thing you should do is think about how you want to structure your save file. XML might be a bit of an overkill for a text RPG, especially if the programmer is new to the language. I suggest doing an "INI" approach, where you tag different sections of your file using square brackets. Example:

[playernames]
John McCarter
The Dark One
Margret Baxter

[weapons]
The Skull crusher
Frilly Underwear (Pink)
Baguette

The tags are there so you can detect them later in the code. Your approach is pretty solid so far, but you have to expand it to something like this:

#include <iostream>
#include <string>
#include <vector>
#include <fstream>

int main()
{

    std::vector<std::string> playerNames;
    std::vector<std::string> weapons;

    std::string line;
    int state = 0; // state 1 is playerNames, state 2 is weapons, and so on

    std::ifstream myfile("data/checkpoint01.txt");
    if(myfile.is_open()){
        while(myfile.good()){

            std::getline(myfile,line);

            // switch states
            if( line[0] == '[' ){
                if( line.compare("[playernames]") == 0 ) state = 1;
                if( line.compare("[weapons]") == 0 ) state = 2;

                // skip to next line
                std::getline(myfile,line);
            }

            switch(state){

                // player names
                case 1 :
                    if( line.size() > 0 ) playerNames.push_back( line );
                    break;

                // weapons
                case 2 :
                    if( line.size() > 0 ) weapons.push_back( line );
                    break;

                default: break;
            }

        }
        myfile.close();
    }else
        std::cout << "error opening file" << std::endl;

    // now print data to the screen
    std::cout << "player names:" << std::endl;
    for( std::vector<std::string>::iterator it = playerNames.begin(); it != playerNames.end(); ++it )
        std::cout << *it << std::endl;

    std::cout << std::endl << "weapons:" << std::endl;
    for( std::vector<std::string>::iterator it = weapons.begin(); it != weapons.end(); ++it )
        std::cout << *it << std::endl;

    return 0;
}

Note to the more experienced: I know you could refactor this into a class with read/write methods, and should make separate classes for players, weapons etc. etc. and should probably define constants for states instead of numbers, but that's not the point.




#5103504 How to write a undertemined size array to a txt file?

Posted by TheComet on 22 October 2013 - 02:59 PM

He's saying to use std::vector<T> instead of C arrays. Here, check this out:
#include <iostream>
#include <string>
#include <vector>

int main()
{

    // this is a dynamic array
    std::vector<std::string> enemyNames;
    
    // add as many names to the array as needed
    enemyNames.push_back( "Cubert Cumberdale" );
    enemyNames.push_back( "The Dark Lord" );
    enemyNames.push_back( "ponies" );

    // this will loop through all elements in the array
    for( std::size_t i = 0; i != enemyNames.size(); ++i )
    {

        // you could change this to write to a file
        std::cout << enemyNames[i] << std::endl;
    }

    return 0;
}




#5103407 Unmaintainable code

Posted by TheComet on 22 October 2013 - 10:10 AM

This section is also very awesome: http://hg.icculus.org/icculus/lugaru/file/97b303e79826/Source/Terrain.cpp#l132

void Terrain::Update​Transparency(in​t whichx, int whichy){ /*...*/ }
void Terrain::Update​Transparencyoth​er(int whichx, int whichy){ /*...*/ }
void Terrain::Update​Transparencyoth​erother(int whichx, int whichy){ /*...*/ }

"otherother"

714-epic-facepalm.jpg




#5103243 Unmaintainable code

Posted by TheComet on 21 October 2013 - 03:53 PM

TRWTF is

using namespace std;



#5103241 How can I avoid exposing thirdparty types in my API classes?

Posted by TheComet on 21 October 2013 - 03:44 PM


I was reading "Effective C++ 2nd Edition" and in "Item 34: Minimize compilation dependencies between files" it says a good way to reduce dependencies is to have 2 physical classes (to name them someway) for each logical class, one to expose the public part of the class, and another with the private part of the class, having the public class a pointer to an object of the private class as a member.

Quite correct, that's the PIMPL Idiom (pointer to implementation). It's the best way to hide your implementation and reduce dependencies.




#5103066 Animation theading

Posted by TheComet on 21 October 2013 - 03:23 AM

What graphics library are you using?

 

I would recommend implementing GPU accelerated animation rather than messing around with CPU threading. This way, the transformations of animation frames are offloaded to the GPU using vertex programs and immensly increase performance.

 

Ogre3D supports this, for instance: http://www.ogre3d.org/docs/manual/manual_76.html






PARTNERS