Jump to content

  • Log In with Google      Sign In   
  • Create Account

HappyCoder

Member Since 28 Apr 2007
Offline Last Active May 27 2016 09:54 AM

Posts I've Made

In Topic: Blocking movement on collision

27 May 2016 - 08:46 AM

You have two options here.

If you have determined that two shapes do overlap, determine the smallest amount you need to push one of the shapes to correct the overlap. This however, can result in objects passing through each other if they move fast enough.
See separating axis theorem

The second option is to do a raycast aka swept collision detection. You find out how far in a given direction any obstacle is in front of the player and use that distance to determine if the player can move before moving them. Is actual practice, you usually do sphere casting or capsule casting. Its like ray casting except the ray has thickness. In essense it just determines how far a sphere or capsule shape can move before hitting something. Spheres and capsules, apart from being easier to do collision detection with, also have the benefit of not getting stuck on sharp corners. They just slide over them without a problem.
Here is a simple example for a sphere/plane swept collision. http://www.gamasutra.com/view/feature/131790/simple_intersection_tests_for_games.php

In Topic: effective solution to find 6 plane of frustum?

21 May 2016 - 10:27 AM

You can transform a plane by multiplying by a matrix like this.
 
                        |a|
inverse(transpose(M)) * |b|
                        |c|
                        |d|
Where ax + by + cz + d = 0 defines a plane

In normalized coordinates the 6 planes in opengl are
[1 0 0 1] [-1 0 0 1]
[0 1 0 1] [0 -1 0 1]
[0 0 1 1] [0 0 -1 1]
where [a b c d] defines a plane

For directx, the last two planes are
[0 0 0 1] [0 0 -1 1]
Since we want to transform a plane from normalized space to world space we simply take the transpose of the view projection matrix and
mutliply each of those six planes by that matrix
 
 transpose(view * projection) * p
You notice that we don't take the inverse of the matrix since it is already the inverse of the matrix we actually want to transform it by.
(view * projection goes from world to normalized space, we want to go from normalized space to world space)

The result of multiplying each plane will give a 4 dimensional vector. where x, y, z, w of the vector can be copied over directly to the
plane a, b, c, d respectively.

Notice that the 6 original planes have a lot of 1s and 0s. This means there is a lot of wasted work so when you simplify the multiply, just
end up with adding or subtracting two value from the matrix to get each plane. The simplified extraction can be found in this paper.
http://gamedevs.org/uploads/fast-extraction-viewing-frustum-planes-from-world-view-projection-matrix.pdf

In Topic: Neural network for ultimate tic tac toe

16 May 2016 - 10:57 AM

Neural networks good for taking complicated mathematical equations and building an approximation for it. You do this by supplying some inputs, see what outputs they give in some complicated system, then training the network with the given inputs and outputs. Eventually you can use the neural network to make rough approximations of what the complicated system will do given some inputs.

Turn based board games with no random chance can usually have an AI similar to chess. So I would look into existing chess AI implementations that use neural networks and see what you can glean from that.

This link looks promising
http://erikbern.com/2014/11/29/deep-learning-for-chess/

In Topic: Polymorphism in C

13 May 2016 - 11:32 AM

I answered my own question on type safety, sort of.

here is the updated implements


#define implements(CLASS, INTERFACE, ...) \
    INTERFACE ## _implementation CLASS ## _implementation_of_ ## INTERFACE = { __VA_ARGS__ }; \
    INTERFACE CLASS ## To ## INTERFACE(CLASS* this) { INTERFACE result; result.target = this; result.implementation = &CLASS ## _implementation_of_ ## INTERFACE; return result; }

and this is how its used


implements(SmallStack, IStack, 
    .push = &SmallStack_push,
    .pop = &SmallStack_pop,
    .peek = &SmallStack_peek,
    .size = &SmallStack_size
);

You can still leave out methods though, but this is already way more readable. I also had to change SmallStack_push to accept a void pointer instead of a specific type, but after a cast it works out.

In Topic: Looking to create a game similar to the pit, but...

12 May 2016 - 12:52 PM

By the lack of 3D perspective I would guess that is 2D. Without seeing some animation in the game its hard to know for sure. That being the case that artwork was likely done in Photoshop or Illustrator.

I normally use gimp and inkscape for my 2D games. Those are essentially the open source versions of Photoshop and Illustrator.

XCode is just an IDE, so you can make 2D or 3D games. You may want to look into game engines for iOS. Game maker is a pretty good 2D game engine that isn't too much work to learn. Unity is a 3D game engine that can target iOS, however, I would not recommend it to a complete beginner unless you already have some coding experience.

PARTNERS