Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Nov 2010
Offline Last Active Yesterday, 02:40 AM

#4969671 Getting Cube You Are Looking At (Voxel Engine).

Posted by on 14 August 2012 - 07:15 PM

You need to use a technique called ray casting. From the position of the player's eye (centre of the viewport) and your camera's direction vector you create a ray and then test that against your geometry to determine where it intersects.

#4966586 "Seeding" Multiplayer Games?

Posted by on 06 August 2012 - 01:21 AM

The difference between torrents and multiplayer games is that in the case of a torrent, the data doesn't change, so the seed data can be passed around as quick or slow as it likes. A multi-player game by definition is being affected by its players, so the game state is constantly changing. There's just no simple way for that game state to be passed around in a peer to peer fashion that is either timely or accurate.

#4965075 Obscuring the game code

Posted by on 31 July 2012 - 09:56 PM

Minecraft was inspired by another project called Infiniminer which was abandoned by it's creator about a month after release due to losing control of his own source code.

Quoted from RockPaperShotgun:
“I stopped working on Infiniminer when the source code was leaked. It was totally my fault, as that’s what I get for releasing an un-obfuscated .NET assembly, but it nevertheless enabled hackers to create hacked clients and players upset with my balancing decisions to fork and write their own clients and servers.”

So it's worth doing some really basic obfuscation and making sure you don't release debug builds. Also, listening to your community and getting them involved will eliminate the need for them to build their own stuff based off your work.

#4963812 Achieving oldschool platformer physics

Posted by on 27 July 2012 - 06:33 PM

Essentially what you're asking is: How do you make a game act as though it doesn't use a physics engine.

Easy. Don't use a physics engine. Adjust the velocity/position of the objects directly, don't factor in acceleration or mass or friction or any of the other physics related parameters.

I realize that, but I really don't want to start handling collisions, so I am wondering if you can force Box2D to be less "physicy" Posted Image

Fair enough, though it may be easier to write a simple sprite-based 2d collision detection system than trying to wrangle Box2D to work less like a proper physics engine.

#4963810 Preventing Chaos in your game code

Posted by on 27 July 2012 - 06:26 PM

First things first. Does it work? If not, get it working. Then think about refactoring.

A good metric for determining if refactoring is required is if the code makes sense to you at a glance a few weeks or months later. You can often overlook obvious design flaws when the code is fresh in your mind.

IMHO, it's better to code an imperfect solution and then improve it later (if you have time) than spending hours agonising over producing the perfect design first time. I know this because I'm guilty of it all the time.

#4961550 How to simulate pressure with particles?

Posted by on 20 July 2012 - 07:47 PM

Pressure can be seen as the sum total of all the particles colliding with the container's walls over a period of time. If you're looking to go the realistic route you could give all your particles an initial kinetic energy based on the temperature of the fluid you're simulating, and if you use elastic collisions you should find that as you decrease the volume there are more particle collisions per second.

#4961538 Aim using a vector?

Posted by on 20 July 2012 - 06:54 PM

If the speed of your bullet is very high compared to the movement of everything else in your world (for example a laser beam), you're better off using the vector approach, or more correctly, a Ray. A Ray has an origin and a direction, whereas a vector just has direction.

If the speed of your bullet is low enough that its reasonable that the player will be able to see it coming and dodge it, then you'll have to use collision detection. There are ways of preventing situations where collision detection misses a collision due to the speed of the projectile, you can simply test against an object that is extruded forwards in time by a certain amount, or use shorter timesteps to get a higher resolution.

#4960796 textures textures textures :)

Posted by on 18 July 2012 - 09:45 PM

The dds format can be uploaded in a compressed state and decompressed by the graphics hardware, whereas .png will need to be decompressed at the cpu/graphics driver end and uploaded as raw bitmap data, which consumes more bandwidth.

That said, I'm currently using .png, as it is easier to manipulate during development. When I'm closer to release I'll convert them all to .dds and see if it makes a difference to performance at all.

#4958616 interpolation of normal on low polygon useless

Posted by on 12 July 2012 - 07:25 PM

If the angle between adjacent faces is more than a certain threshold, you really need to switch to using face normals. If you want a hard edge, use face normals. If you want a smooth edge, use averaged vertex normals.

Also, don't forget to re-normalise the normals after summing them together.

#4942422 C# SQL connector very slow

Posted by on 22 May 2012 - 08:55 PM

Batching the updates together will make a definite improvement. Try something like 100 or 1000 and see how you go. Another thing to look at is how you're building the query string you're executing. If you're concatenating a lot of strings together it will severely impact your performance, as .net has to reallocate the string every time you modify it. The recommended way to build strings is with the StringBuilder class.

#4942141 Broken Game as an Anti-Piracy Measure

Posted by on 22 May 2012 - 03:40 AM

My favourite anti-piracy reaction of all time was from last year by Garry Newman of Garry's Mod fame. He pushed out an update via steam that detected if the game was hacked and threw up an error message when you'd try to run it. The error message included a long error code that was actually the user's steam ID. So when the pirates complained in support forums and posted the error code Garry knew exactly which forum and steam accounts to ban.

Using such a scheme is risky due to the chance of false positives. But it was terribly amusing to read about.

In my personal opinion, there's nothing you can do to make your game completely secure. DRM is good in theory, but when it goes wrong (and they ALWAYS seem to go wrong), you risk pissing off your legitimate customers while the pirates have already found a way around it so they aren't inconvenienced.

#4942133 Textures not rendering

Posted by on 22 May 2012 - 03:00 AM

One idea that springs to mind is that "texture" is null. Direct3D won't complain if you pass null into a SetTexture() call, you just won't get anything displayed.

One thing that seems odd is that you're asking direct3D to return the texture in an unknown format in the FromFile() call. Most likely you'd want to use something like A8R8G8B8?

As Jebbles pointed out, Managed DirectX was discontinued by Microsoft quite some time ago. It was replaced by XNA, which you should look into instead. If the book you're using is the one I think it is, then its from 2004, which explains the obsolete technology it's advocating.

#4930110 direct x9 project

Posted by on 10 April 2012 - 10:40 PM

It depends on what you're trying to achieve. If your goal was to draw a triangle, you're done. If not, tell us where you want to go, and we can offer suggestions.

#4922915 recommended ways of storing game entities and state game structure

Posted by on 17 March 2012 - 05:06 PM

I would definitely cache your textures. Creating and destroying Texture objects all the time is a great way to kill your frame rate. I like the idea of having a centralised Texture Cache that's responsible for creating and destroying Texture objects because I use an "on-demand" resource allocation strategy. Ie, on render, I'm checking if the resource is allocated or not, and creating it as required, rather than allocating everything on load. This also allows texture re-use if objects are using the same texture.

You can then get a bit more advanced with reference counts to deallocate textures that you haven't used in a while to manage your video memory a bit better.

#4922780 WHAAAATT!

Posted by on 17 March 2012 - 03:32 AM

I think it has to do with the fact that to represent a point or vector in 3d space, you need 3 coordinates, and to transform those coordinates using rotations, etc you multiply it against an appropriate matrix. A 3x1 Vector multiplied by a 3x3 Matrix will give you another 3x1 vector, representing the transformed point.

The issue is that a 3x3 Matrix can represent rotation and scaling, but can't include translation. To do that we need to use a 4x4 matrix. But in order for that to work, our original 3x1 point needs to be expanded to 4x1, since you can't multiply a 3x1 vector by a 4x4 matrix. The new coordinate, w, controls if the translation part of the 4x4 matrix is added to the result, so under most circumstances you want it to have a value of 1.0. However, if you're transforming a vector instead of a point, you don't want the translation applied, since a vector is an offset from 0,0,0 and the translation will change the vector's direction and magnitude, so you can use the same transformation matrix as before, but set the w coordinate of the vector to be 0.

I think that ordinarily, Direct3D takes care of adding that w=1.0f term automatically when it expands from a float3 to a float4, so when you use input.Pos, the value would be correct.

I don't fully understand the thing myself, but my explanation makes sense to me. Doesn't mean it's correct though. Maybe someone more knowledgeable like MJP can chime in and correct me if I'm wrong?