I want to make a 2D game in C ++ using Irrlicht . In this game you will control a tiny ship in a cave. This cave will be created automatically (the game will have random levels) and will look like this:
Suppose I already have polygon points inside a cave (white part). How should I display this figure on the screen and use it to detect collisions? From what I read on different sites, I have to use the triangulation algorithm to make the grid walls of the cave (the black part) using the polygon inside the cave (white part). Then I can also use these grids to detect collisions. Is this really the best way to do this? Do you know if Irrlicht has built-in functions that can help me with this?
Any advice would be appreciated.
, 3D-, . , 3D- , , , , . , , , , . . .
, Irrlicht - , , , . ( , , .) , , , .
- ( ) .
,
if map_points[sprite.x sprite.y] is black then collision detected
, , .
, " " ,.
To check if a point is inside or outside your polygon, you can simply count the transitions. You know that (0,0) is outside your polygon. Now draw a line from there to the test point (X, Y). If this line intersects an odd number of edges of the polygon (for example, 1), it is inside the polygon. If the line crosses an even number of edges (for example, 0 or 2), the point (X, Y) goes beyond the polygon. It is useful to run this algorithm on paper once to convince yourself.
Source: https://habr.com/ru/post/1734527/More articles:How to access the main window when a child window exits a process in C # - c #How to elegantly split word pairs from a string in Perl? - perlConsistent behavior of float code with GCC - optimizationHow to write a simple mail server in java? - javaHow does this compile? C # - c #Hide all select elements in a div using jquery? - jqueryDoes the connection at the level of functions in VC ++ have any negative effect? - c ++Administrator rights and rights Jetty6 - windows-xpandroid: how to save data in my arrayadapter / listview file when orientation changes? - androidaddShutdownHook and setUncaughtExceptionHandler not working properly in java - javaAll Articles