Jump to content

  • Log In with Google      Sign In   
  • Create Account

Khatharr

Member Since 24 Apr 2010
Offline Last Active Private

#5221763 Advanced unit steering (e.g minion movement in moba games)

Posted by Khatharr on 06 April 2015 - 09:03 PM

http://gamedevelopment.tutsplus.com/tutorials/understanding-steering-behaviors-collision-avoidance--gamedev-7777




#5221760 Two Questions - Willing to Trade experience on Tools and Business Side, for M...

Posted by Khatharr on 06 April 2015 - 08:56 PM

There's a series of getting-started tutorials on the official Android site.

 

https://developer.android.com/training/index.html

 

If you're using Eclipse then that's your starting point. If you want to use something like Unity I think you just build for Android from within a Unity project.




#5220844 c++ count lines in txt file and then read these lines without reopening a file

Posted by Khatharr on 01 April 2015 - 09:35 PM

std::vector<std::string> getLinesFromFile(const std::string& fname) {
  std::ifstream file(fname);
  if(!file) {throw std::runtime_error("getLinesFromFile() - Failed to open file.");}

  std::stringstream data;
  data << file.rdbuf();
  file.close();

  std::vector<std::string> lines;
  while(data) {
    lines.emplace_back();
    std::getline(data, lines.back());
  }
  lines.pop_back();

  return lines;
}



#5220809 c++ count lines in txt file and then read these lines without reopening a file

Posted by Khatharr on 01 April 2015 - 04:02 PM

std::ifstream is RAII.

 

But you should throw if the file has an error.

 

Anyway, wasn't this whole thing about performance? Why are you reading one line at a time from the disk?




#5220808 Anyone got any ideas where 4k a sec is coming from?

Posted by Khatharr on 01 April 2015 - 03:51 PM

If you're worried about leakage then download vld and test the program. Task manager is NOT an appropriate tool for measuring memory usage.




#5220340 How to generate biomes?

Posted by Khatharr on 30 March 2015 - 06:08 PM

I'm not really clear on what problem you're having here. You describe what you're doing, but then you just say that you can't use Perlin noise. Why not?

 

If it's just that you don't want to wait for long map generation times, then maybe you could do the top-level noise, and then do the progressively lower levels of noise only as needed? Do one Perlin iteration for the whole map, then break it into segments. Do a Perlin iteration for the segment the player is in, then break it into smaller segments, etc. down to the level of detail that you want. Keep the final results stored and mark unprocessed areas so that you don't have to repeat the work later. If you put a little thought into how you break up the segments then you should be able to amortize the work pretty effectively.




#5219893 How can I create a text based adventure game?

Posted by Khatharr on 28 March 2015 - 06:21 PM

A thread for the ages...




#5219777 Collision detection with triangles as the basis of all computer graphics…?

Posted by Khatharr on 27 March 2015 - 11:28 PM

I'm not sure what a "normal" is.

Is it possible to illustrate a very simple example of this concept?

 

A normal is a vector which is orthogonal (at a right angle) to another vector or plane. In a 2D space you can get a right-side normal as follows:

 

vector = {x, y}

normal = {-y, x}

 

Normals are used in a variety of calculations, especially collision and lighting. The reasons become clear when you study dot products and cross products, which can be found within the materials linked by jacmoe.




#5219776 VS2010: fatal error C1083: Cannot open source file

Posted by Khatharr on 27 March 2015 - 11:20 PM

Did they un**** intellisense in 2015?




#5219775 Global Consts

Posted by Khatharr on 27 March 2015 - 11:16 PM

Yeaaaaaaaaaaaah...

 

Anyway, if a constant relates to a specific class, make it a static const in the class. That's always handy because it's available directly within its own context and available publicly the same way it would be through a namespace:

class Foo {
public:
  static const int BAR = 42;
}

Foo::BAR; //is 42

Also, setting aside readability, avoiding magic numbers means that if you have to change the value at some point then you don't have to do the easter-egg hunt for all the relevant replacement positions. Even for trivial cases this can make sense:

const int ARY_SZ = 10;
int ary[ARY_SZ];
for(int i = 0; i < ARY_SZ; i++) {
  baz(ary[i]);
}

If you change the size of the array then you only have to change it in one place. In more complex code this can save a lot of heartache.




#5217998 C++ do while error

Posted by Khatharr on 20 March 2015 - 10:48 PM

It's not OOP's fault either, though. That's like picking up your car and carrying it to work and then complaining that cars are inefficient.

 

If someone tries to use OOP because of peer pressure rather than because it's the right tool for the job then the problem is with their peers and the response to those peers, not with OOP itself.




#5217216 How to Acess a singleton from everywhere?

Posted by Khatharr on 17 March 2015 - 06:01 PM

Ah, right. YOU SEE HOW THE POISON SPREADS?




#5216993 How to Acess a singleton from everywhere?

Posted by Khatharr on 16 March 2015 - 08:25 PM

So much static, so little reason for it...

 

Anyway, concerning ankhd's question: Maybe try something like this:

struct Foo {
  Foo() : var(10) {
    //nop
  }
  
  int var;
  SomeObjetNotStatic object;
};

main() {
  Foo foo;

  //then use from now on
  foo::object->doStuff();
}



#5216811 How to check application version with HTTP GET?

Posted by Khatharr on 16 March 2015 - 03:38 AM

Just use plain old TCP, write a client and server, and send some bytes back and forth.

 

Oh, I thought we deprecated TCP in favor of REST because of Parkinson's Law.

 

Seriously though, you could even just use UDP for something like this since the payload is more or less constant and is less than a packet in length.

 

OP says he's already got a web server running though, so his idea isn't really a bad one, since it doesn't really incur any additional overhead to speak of and it can easily be updated dynamically. That being the case, another +1 for libcurl here.




#5216805 Need help changing the date of a game

Posted by Khatharr on 16 March 2015 - 02:52 AM

The only real way to do this is to buy this neat program called "FIFA 15"

 

It's a trap! They'll just do the same thing again next year!






PARTNERS