Jump to content

  • Log In with Google      Sign In   
  • Create Account


Labouts

Member Since 10 Dec 2011
Offline Last Active May 01 2014 07:44 PM
-----

#4976242 Generating Large Maps Using Libnoise (Limits?)

Posted by Labouts on 03 September 2012 - 06:22 PM

I'm looking at the sample code's file "complexplanet.cpp". Here's some code around line 128
[source lang="cpp"] // Southernmost coordinate of elevation grid. const double SOUTH_COORD = -90; // Northernmost coordinate of elevation grid. const double NORTH_COORD = 90; // Westernmost coordinate of elevation grid. const double WEST_COORD = -180; // Easternmost coordinate of elevation grid. const double EAST_COORD = 180; // Width of elevation grid, in points. const int GRID_WIDTH = 4096; // Height of elevation grid, in points. const int GRID_HEIGHT = 2048;[/source]

Then around line 1843

[source lang="cpp"] planet.SetBounds (SOUTH_COORD, NORTH_COORD, WEST_COORD, EAST_COORD); planet.SetDestSize (GRID_WIDTH, GRID_HEIGHT);[/source]

Here is the 4096 by 2048 height map the site uses for the terrain sample pictures:
http://libnoise.sour...ages/planet.jpg

So it's only about twice as large as what you found as your maximum, the sample just looks like it needs a much larger map because of the way Terragen renders it. Still, it seems you don't have as much memory as they expect people running the sample to have. Your main options are:
1. Find a way to make due with fewer points.
2. Get more memory. Note, this option will make the minumum system requirements for your game higher.
3. Make multiple smaller height maps and save them to disk, probably after compressing. Then, make your program try to anticipate which ones will be needed soon so it can decompress and load them before they need to be show.


#4902842 Can someone explain the problem with this compilation error!

Posted by Labouts on 14 January 2012 - 08:43 PM

It compiles fine for me. Are you including "piece.h" before "board.h" in a other files? If so, try including "board.h" first and see what happens.


#4899785 XNA or build my own engine?

Posted by Labouts on 04 January 2012 - 06:48 PM

XNA is a framework, not an full game engine. It makes many game related tasks easier, providing a basic structure and some helpful classes, and handles some messy directx details for you. I'd suggest using XNA simply because it will make your development faster; it will let you start experimenting with game design sooner as opposed to spending your first efforts learning to deal with lower level graphics programming.

Yes, C# is used more in game programming than java; although, there have been some interesting java games recently (minecraft comes to mind). C++ is still the most common language for game programming, but using it adds unnecessary complexity if your game doesn't have heavy performance demands.

For beginning XNA tutorials, I would suggest this and this.
If you choose to not use XNA, you will want to start with either DirectX tutorials or OpenGl tutorials

Good Luck


#4895112 dangerous curves

Posted by Labouts on 18 December 2011 - 05:02 PM

If they are on a set pattern, trigonometric functions are useful. If their movement is not on a set course, such as if they are reacting to the player, then there are a few methods to achieve those smooth curves. The main way is to model their movement as vectors and change an object's movement using velocity and accelerating vectors.
eg: If an object's velocity is (3,0) and its acceleration is (-1,2) for 3 seconds, then it will smoothly change course from east to north while accelerating. In the case of a game like blazing lazers, this is like simulating thrust.


#4894329 What do programmers want/What motivates programmers?

Posted by Labouts on 15 December 2011 - 05:50 PM

One draw for me is that I've always loved the idea of magic. The image of mages devoting their mental energies toward learning the rules of magic and bending energy to their will with arcane incantations always thrilled me. Most importantly, I love the idea of being able to use raw willpower to affect the world if you know enough. Programming is the closest the real world has to magic. I use a magical language to control electricity in useful ways: communicating over great distances, extracting information from data and creating worlds that are ruled by my personally crafted laws.

In terms of game programming, what could be more motivating than knowing that you can be the God of your own world if you put in the effort to create it. Seeing your world behave how you intended is a fantastic feeling; the feeling of seeing your world behave in untended ways that you like is transcendent. Programming shortens the gap between your mind and the outside world, even dry math concepts can turned into fascinating displays and interesting behaviors.

Programming motivates me because I see my programs literally as my thoughts given power.


#4894312 Beginner Question About Game Design

Posted by Labouts on 15 December 2011 - 04:53 PM

Your question is more general than game design. I'd recommend reading Clean Code, a book by Robert Martin which covers several aspects of good program design and effective code layout which most other books ignore. In general, small files with small classes and small methods is ideal for making code easy to test, debug and extend. I recall that he specifically recommends in his java example staying under 500 lines per file and trying to keep them around 200 lines


#4894311 virtual function

Posted by Labouts on 15 December 2011 - 04:50 PM

If at all possible, try to ensure that your design doesn't require this. It muddles the logic, complicates debugging, and can cause some maintenance issues.


#4893834 Strange C++ Problem

Posted by Labouts on 14 December 2011 - 07:51 AM

This solution seems counter-intuitive. Perhaps you should try putting the subtraction logic in the subtraction operator and having the subtraction-assignment operator use the subtraction operator then assign the result. That would make this easier to debug and would make your logic easier to follow.

const big_integer big_integer::operator-(const big_integer& rhs) const
{
 	big_integer result;

 	// Subtraction logic

 	return result;
}

big_integer& big_integer::operator-=(const big_integer& rhs)
{
	*this = *this-rhs;

	return *this;
}



#4893784 How does delete[] know how many bytes to release?

Posted by Labouts on 14 December 2011 - 03:36 AM

Ruler is right: there are two main methods, one is storing the size at the head and the other is maintaining a hashtable which associates pointer P with size N. Which one is used depends on the compiler.
See this for more information.


#4892965 posting code

Posted by Labouts on 11 December 2011 - 08:21 PM

You post code by surrounding your code in [ code ] and [ /code ] without the spaces.
Like this

You insert images by clicking on the icon that looks like a photograph near the smiley face above the text editing box.


#4892820 Rotational speed

Posted by Labouts on 11 December 2011 - 10:37 AM

Ah. In that case, you treat the center of mass as a particle in 3D space. To quote Wikipedia's Particle in three dimensions subsection:

"The angular velocity in this case is generally thought of as a vector, or more precisely, a pseudovector. It now has not only a magnitude, but a direction as well. The magnitude is the angular speed, and the direction describes the axis of rotation."

in the case of [2,6,7]

sqrt(2^2+6^2+7^2) = 9.43 radians per second, which is very close to 3 rotations per second.

[2,6,7]/9.43 = [0.21, 0.63, 0.74]

So the object is doing about 3 rotations per second clockwise on the [0.21, 0.63, 0.74] axis.

edit: I forgot to comment on the direction of rotation.
The rotation is always clockwise. To get a counter-clockwise rotation about a given axis, make a rotation about the negative of that axis.
For example, 3 counterclockwise rotations per second about the [0.21, 0.63, 0.74] axis would be expressed as [-2,-6,-7].


PARTNERS