I'm writing a game for Android using OpenGL ES 3.0, but can't figure out how to calculate a proper bounding box for my objects.
The "main menu" consists of a couple of three-dimensional cubes. To find out what cube the user presses, I calculate a ray and check if any of the cubes intersect the ray using their bounding box (a sphere, represented by the cubes' positions and radiuses).
However, now I want to switch from cubes to three-dimensional rectangles. Since I can't use a sphere to properly represent the rectangle, I need a new way to calculate the intersection of the ray and the (potential) rectangle.
To add to my problem even more, the rectangles are rotating, making the width varying, so I can't use a static bounding box either.
What I'm thinking of doing is transforming the vertices on the CPU every time the user touches the screen. Then when I have the same vertices as OpenGL is drawing, I calculate the triangles and their corresponding normals and test each and every triangle to see if anyone intersects the ray.
Am I thinking properly, or is there an even simpler solution? I know that this intersection testing is heavy on the resources, but since I only have three rectangles on screen at the same time, I just have to check 36 triangles whenever the user touches the screen.
I've programmed a couple of tiled 2D RPGs already, using SDL. I'm also familiar with some "advanced" math, like transformation matrices and what not.
On to the problem, then!
I want to create an isometric 2D RPG game, but I have no idea where to start. I'm familiar with the concept as such, but I have no experience whatsoever with the implementation. For instance, SDL has a function called SDL_BlitSurface() that blits rectangles, that I've used to copy the texture onto the map. How I'd do the same with an isometric tile, however, I cannot fathom.
So, where do I begin? I've searched for both tutorials and actual code, but found nothing that left me any wiser.
I'm currently writing my first proper 2D game (integrated in a custom built engine) using C++ and SDL. I have a question about how to script certain events though. The engine itself is state based.
My game state is made up like this:
class PlayState : State
In turn, the map is primarily a manager of tiles (Tile*** tiles; which get initiated in accordance with the map file).
Now to the problem! When I step on, let's say tile , I would like the game to change to a certain state (declared either in the map file or in some script). What's the best way to do this?
PlayState holds a pointer to the engine, and it would be possible for it to pass a ChangeStateEvent to it, but then I have clutter the map file with both info about what event to send and possibly a parameter to the same (i.e. ChangeStateEvent, Cutcene(cutscene nr 725)). Instead I was thinking about having some kind of script trigger every time I step onto a new tile and check if the tile is a trigger tile. If so, the script will handle everything necessary to view the cutscene.
So, what do you suggest? Is scripting the way to go, or am I completely off?
I own all of the code myself (and the game art is all Creative Commons licensed), and wouldn't mind sharing it if necessary (it'll most likely cause a headache for the more advanced game devs though).