Jump to content

  • Log In with Google      Sign In   
  • Create Account

Tapped

Member Since 29 Jan 2011
Offline Last Active Today, 03:38 PM
-----

Posts I've Made

In Topic: What is a good C++ Framework?

13 June 2013 - 01:26 AM

You need to ask yourself, what is your motivation, and what do you want to learn or produce from it,
With the answers of these questions, you can find a framework that suits your needs.

For instance, if you want to learn how to use a pretty high level framework, use SFML. However SFML can also be used for low-level OpenGL programming too.

 

If you want to be individual and invent the wheel again, then create everything yourself using Windows API and OpenGL/Directx contexts to setup some nice graphics.
When it comes to the decision between OpenGl and Directx, you need to compare your experience level with your program specifications. Today, Directx is so simple to implement using Visual Studio 2012, and the Windows SDK. It even exists a template for it. So you don't need to use time to setup, but can code right away. Unfortunately, it will only work on windows. Use OpenGL if you want to support a lot of platforms, but keep in mind that OpenGL is harder to learn, especially in the beginning. Also, if you are not experienced with cross-platform coding, you will pretty fast find it a nightmare from time to time, since compilers work differently. So your code may look as a mess, because of all the compiler specific stuff. However it is a good thing to learn how to structure code for more than one platform. And remember the best way to learn is by your faults. 

 

But again, what do you want? If you want to learn as much as possible, then you better invent the wheel again. And if you want to make a game, and you got a team of artists, then stick to UDK, Unity3D, Torque3D, C4 etc.


In Topic: C++/SDL Game Design Guidance

04 June 2013 - 03:00 AM

Why not use the existing tile system as a grid?
Here is a snippet that maybe useful:

void DrawTilesWithinFrustum(Vec2f worldPos, int windowWidth, int windowHeight)
{
    Vec2f minIndex = worldPos / Vec2f(TILE_SIZE_X, TILE_SIZE_Y);
    Vec2f maxIndex = (worldPos + Vec2f((float)windowWidth, (float)windowHeight)) / Vec2f(TILE_SIZE_X, TILE_SIZE_Y);
    
    // We want to be sure that we draw the tiles that are slightly in the frustum.
    maxIndex.x += 1;
    maxIndex.y += 1;

    int numColumns = (maxIndex.x - minIndex.x) + 1;
    int numRows = (maxIndex.y - minIndex.y) + 1;

    for(int row = 0;row < numRows;++row)
    {
    	for(int column = 0;column < numColumns;++column)
    	{
    		int index = (unsigned int)(minIndex.x + row) + (unsigned int)(minIndex.y + column) * TILE_SIZE_X;
    		Tiles[index]->Draw();
    	}
    }
}

worldPos is the position of the camera. This approach would run a lot faster than bruteforcing each tile. It will only loop through the tiles that you want to draw. 

Beware that this code snippet is not tested, so it may include type errors etc.

 

Good luck.


In Topic: Space Partitioning on Sphere

02 June 2013 - 09:05 AM

Hmm, why not use the same grid system that is used to represent Earth coordinates. In other words use spherical coordinates.

 

Spherical coordinates can easily be worked out from Cartesian coordinates as long as you know the radius and position of the sphere in question. 

So you create the boundaries virtually by specifying [θ, φ] extent of each grid cell, as you may be used to when working with normal grids.

Then you can calculate indices for the cells by coordinates, which is done as following:

int GetLocationIndex(const Vec2f &sphericalPoint) 
{ 
 Vec2f indices2D = sphericalPoint / extent; 
 return (unsigned int)(indices2D.x) + extent.x*(unsigned int)(indices2D.y); 
}

The x coordinates of the vectors, are Theta, and the y coordinates are Phi.

 

Note, i have not tried this, so it is only an approach that may work.
However good luck smile.png


In Topic: what the mechanics behind this ?

02 June 2013 - 07:53 AM

I would have solved this problem with simple classic physics. Look at your problem as a composite system. Your character got a force which makes it move. Futhermore the character would have a force, which makes it jump. It may also have a drag force, and lastly a gravity force.

 

By using D'Alembert's principle, you would calculate the final force, which is acting on the object. It implies that, if we have a set of forces acting on an object, we can replace all those forces with a single force, which is done by just summing the forces together. 

 

So I would have calculated the forces, the acceleration, the velocity and the position of you character, by using vector math. Then i would just do a simple bounding box test between the character and the obstacle, to check if the character is inside.

Here is a link for a simple tutorial, which explains what i have mentioned. 
http://ianqvist.blogspot.no/2009/09/2d-physics-engine-tutorial-part-3.html


In Topic: How to prevent cheating in html5 game?

31 May 2013 - 05:48 AM

The fact is that you can't do networking 100% safely.

However you can do some tricks to make it more safe.

 

The most secure way, which is also used by desktop games, is too let the server simulate. So the client only handles inputs and rendering. Unfortunately, this technique would require a lot of CPU power from the server, so that you can handle the amount of clients.

 

The second approach is to have some factors which are hard to find/hack, and which also determines if you have succeeded or not. Like in your example it is the position when the heart hits the princess. So you send the position of the heart, and lets the server validate it. This can easily be hacked, so to make this even better, you may create a random coordinate space to use when sending the position, and only use the local space to render the scene.

So, in other words you can't be safe, but you can try to prevent the most obvious attacks.

 


PARTNERS