# djtesh

Members

27

428 Neutral

• Rank
Member
1. ## Rotated Rectangle Collision Phsyics for Tank Game

You need to replace the collision handling to use physics solvers instead of "stop all movement". Most collision detection code is just that - detection.   Here's what certain engines do:   Physics is handled on a separate thread / module. In order to obtain desirable results, movement solving is done over several iterations PER frame.   Since you're building using C++, I'd recommend looking into the free Chipmunk Physics C++ library. Alternatively you can write quasi-physics by following your own rules as mentioned.   I'm rusty in physics but you should be able to calculate angle of incidence (into the wall or another tank) based on movement vector of both objects. Since the wall is static it will work itself out. When two objects collide, a third party (collision handler with body A and body B) will decide the results. If both objects were tanks, you'll be happy that both can conserve momentum and "bounce" or "slide" correctly based on the same application of physics.   If you want to step it up - and your tanks are not all the same size, you can take weight and momentum into account.

3. ## How do I convert an array to an accelerated texture?

The way you are doing this right now, you are creating the pixels in System Memory (RAM). In most modern computers, the graphics card loads the textures into its own memory. Thus, you'll have to copy your buffer from one memory to another every frame in order to get your desired effect, which is very inefficient, but good enough for a one-off use.   A better approach, then, is to not create the array in System Memory but to do things directly on the graphics device. There are two approaches that I know of for this:   1. Use shaders. Use the vertex shader to draw a rectangle the size of the screen. Use the pixel shader to draw your random colors.   OR   2. Use OpenCL. OpenCL runs C / C++ programs on the GPU. You can integrate OpenCL into your graphics pipeline as well. There are tutorials out there for this - I'm not too familiar with how to do this myself.
4. ## design question: data driven: best methods?

Although your question is not very specific, here are 3 popular methods that won't let you down:   1. JSON, with a parsing library available in most languages. JSON is easier to read and edit, smaller than XML and works with RESTful APIs and internet technologies all over the world now.   2. XML. XML is also easily consumed and parsed in most languages. It is older and somewhat clunkier, but it is still being used in many commercial game engines as a general data format.   3. Design a database using SQLite. This is a file based database format that can be easily consumed in C++ and most other languages. If you know SQL and relational database concepts, this is a powerful way to store and query your game data.   My opinion is that writing custom text file parsers is a waste of time compared to these options, unless you have to do something so extraordinary with it that it makes it impossible to use all of these methods.

6. ## How can I create an installer for my game?

As far as I remember, the Visual Studio Installer project can be configured to include the installation of other components like the runtime library as part of the install. It won't embed the whole thing but rather download and install the latest from Microsoft's servers during the install process.   Look it up. If not, there's Inno setup. It is a powerful, script driven system that definitely handles pre-requisite installs.

8. ## I need help with some maths

Seems like you are not normalizing correctly.   You want to move "r" units from "p" in a direction that points towards "t". Directions are always normalized (unit vectors), so that they make sense when moving any amount of units along them (even fractions).   Check that and try again.
9. ## Unity Unity or C++?

I agree with Nypyren's reply.   Also wanted to add that award winning games and studios are also using Unity for complete games. Think Monument Valley and Hearthstone.   Time is a resource. The quicker you can prototype your game ideas, the more likely you are to spend the time to polish them. C++ is great for truly learning how programming works at a deeper level, but you should decide what is more important - your programming ability or the product / game.

11. ## Keeping code from prying eyes

I think there are two basic approaches you can use consistently to achieve this.   Approach 1. If you are ok with using extern variables, then you can simply declare them in the header file and define their value once in some cpp file. These are usually better for debugging than defines.   Approach 2. If you must have your macros/defines as preprocessor directives, you can create two sets of header files. A set of "Private" header files that are only used during your library compilation but not available to external SDK users. This is tricky and requires more work but it works.
12. ## Percentage Health (100%) vs. Numbered Health (100/100)? Which ones better?

Consider from the player's perspective, given your own game's design. What's the most beneficial thing to show and what's redundant? Also, which combination leads to the most "fun"? Sometimes, the absence of information can heighten the tension.   Think for a little while and I'm sure you'll get arrive at the answer. If you still aren't sure, let some people play it both ways and tell you.   There's no universal truth to such UI and game design.
13. ## unity monthly subscription question?

Sorry but the Unity3D subscription membership is for a minimum of 12 months.