I'm currently making a game with my own game engine which I've written in C++ and I'm using the most recent directx SDK.
The game is a top down space shooter (with a pretty interesting twist) and I'm looking to have a sort of nebula effect that the player will fly through. I really want to try and nail that nice tactile feel of hundreds of particles moving out of the way of the player ship as it flies into them. Somewhat like how particles would move out the way of the player in Geomtry Wars on XBLA.
I'm an experienced programmer when it comes to C++. I don't know, however, how to start implementing this effect. Does anyone have any cool ideas or design choices I might want to look into? Feel free to answer to any degree of depth you fancy.
It's a cool idea. You'd need some sort of diffusion gradient around your ship. There are three physical models I can think of that you might want:
You want it to seem almost like it's a liquid medium, where the pressure gradient rebalances, i.e. once you've passed some particles they move back into your wake (like water behind a boat). In this instance, particle's positions are absolute, and it's only their relation to the player which temporarily modifies their rendering position. This is a bit like when you pass a thick magnifying glass over things, and the diffraction seems to make them move -- but only until you move the glass away. In this case, your ship is the glass.
If you want them to move away from the ship, and carry on moving once they've moved. This is like standard physics in generally empty space where there are no (or very small) pressure gradients.
You want to move the particles away from the ship swiftly as it approaches, as in (1) and (2), but once the ship is gone, the particles will slowly rebalance themselves to be equidistant in your wake.
Common to all three solutions: you need to have a diffusion field that moves with your ship. In this example we will make it circular. You then detect vector, call it v1, between the ship and each particle within that region. Push your particle away along that vector. How strongly you will push it away will depend on it's distance from the ship: use
1 - v1.magnitude. This formula will give you a linear strength, however you could modify it to use something else like a circular strength curve that diminishes in strength toward the edges. This would give it more of a look as though there is a spherical rather than circular pressure gradient around the ship.
For solution 1: All you now do is modify the render position of that particle (that is, the sprite position) on every render update, by this vector. Because you're doing it this way, this is purely a rendering effect and has no effect on the particle's actual world position. So you add the world position to the render offset (v1) and you now have nicely displaced particles as you move past toward or beside them, and smoothly reverting particles as you pass by (behind you).
For solution 2: Instead of just applying v1 to the view position, apply it on each logic update, to the particle's position. So,
p1.position += v1. So you are applying an accelerative force to the particle, which translates into velocity. Probably, you'll want each particle's velocity to be dampened so that they they will gradually slow down and come to a halt once you've passed. You can see how this solution will result in bunched-up particles in your nebula, because they will never rediffuse. Not very realistic, I'm sure, since nebulae have pressure gradients within them, no matter how weak in reality.
For solution 3: Same as (2), but in this case you're going to have to rediffuse your particles. To do this easily is a bit of a brute force approach, but since these are only particles and thus eye-candy, you probably don't need to cover a huge area of interest (probably only a radius of playerPosition + maxPlayerSpeedPerTick, or whatever rectangular area circumscribes that, for logic purposes). Each particle will apply a force on each other particle in within the area of interest. They will apply forces based, once again, on their distances from one another. Calculate all interparticle forces in a single sweep across the area of interest, and then apply all forces in a single sweep. Lastly, make sure that you only perform this inter-particle force processing on particles that have zero velocity. And once any given particle reaches some minimum speed, cut it's velocity vector to zero, so that it's no longer using up processor time.
There are all kinds of diffusion formulae etc. out there, but I think in this case a simple solution works best.
to work correctly. Player movement ends up being very glitchy and repositions the player when I don't want it to. Part of the reason is probably because I feel like this is something so simple but I'm...I am trying to create a 2D platformer (Mario-type) game and I am some having some issues with handling collisions properly. I am writing this game in C++, using SDL for input, image loading, font... I need to start with. What I need is an easy way to both detect which side the collision occurred on and handle the collisions properly. So, basically, if the player collides with the top
I have begun creating a very simple game engine and I am trying to work out how to create a time scale for the game. By time scale I mean some way of increasing and decreasing the speed of the game (not the fps) like creating a slow motion effect. I have no idea how this could be accomplished so any help would be appreciated. If this helps I'm using windows, OpenGL, and C++ to make my game engine. How my engine is setup: I have an update and draw function. The update function is called 25 times per second while display is called as much as possible.
* . This is the part I really have no idea on. Any advice on solving something like this is appreciated, even if it means some kind of design change on my part. I'm just looking for a clear way on how..., IPhysics, and IRenderable. I then also have a player which inherits from IPlayer, IPhysics, and IRenderable. I need a way so that, when Player and Gun collide, if Player is not currently wielding...I'm trying to design my game to be component based rather than overly hierarchical. Essentially, every high level object in the game (like gun, or whatever) inherits and implements the interfaces
I'm programming a 3D game (using C++ and OpenGL), and I have a few 3D objects in the scene, we can say they are boxes for this example. I want to let the player click on those boxes to select them... coordinates. I guess I could then do some sort of ray-box collision test to see if any objects lie as the path of the mouse click. I'm afraid I might be over complicating it. Any better methods out there? ... to do this? The fact that these objects go through several transforms before getting to window coordinates is what makes this a bit tricky. One approach I thought about was that if the player clicks
Lately I have been working on a game that i plan to make online. I have used different libraries to make this game as far as i could, but I feel that I should rethink on how Im sertting this game up, so I planned to start over. The libraries that I have used are SFML, OpenGL, and Bullet Physics, along with GLM to load the models. But the problem is that the 3D graphics arent working with the Physics correctly... So my main question is: What would be a good combination of libraries to make an online game with? Im sure that many people have good combinations of libraries for making a game
. This way all I have to do is plug in the x and z values to the equation to get the y. However, this would require adding 4 floats to every vertex of the heightmap which is a little ridiculous memory...I'm working on implementing the physics surrounding a player walking on a heightmap. A heightmap is a grid of points which are evenly spaced on the x and z axes, with varying heights. The physical... that has some height. Feel free to move this over to math, physics, or stack overflow, but I'm pretty sure this is where it belongs as it is a programming question related to games. Here's my current
itself). I don't believe that the game currently includes this feature and I'm trying to get a feel for how big a challenge it would be to add. My background is as a J2EE and PHP developer/architect, so I don't know C++ as such, but am prepared to give it a crack if there are resources and guides to assist, and it's not a herculean task. Alternatively, if you know of any open source games that do include vibration feedback, please feel free to let me know! Preferably the game would be of the style that the player had to navigate a character (or character's vehicle) over a repeatable course
know if my speculations are ok, as I don't have much experience with 3d animations yet. I want to make a well decision as any option I choose would require a lot of work to get it to render and I don't want to find out in the end that I have to rewrite everything again, as a lot of other objects will be working with these data. Sorry if it's a too subjective matter, but I need some insight. I'm... them to be attached to the node in most cases, even if I allow setting global lights to the scene. @Nicol: Yes that's what I'm trying to figure out. You can see the code doesn't rely on any hardware
areas of concern I have and wanted to get some opinions on the proper way others have solved them or would solve them. 1. Cyclical Dependencies When I was doing the game in C#, I didn't really have to worry about this since it isn't an issue there. Moving to C++, this has become a fairly major problem and made me think I may have designed things incorrectly. I can't really imagine how to decouple my classes and still have them do what I want. Here's a few examples of a dependency chain: I have a status effect class. The class has a number of methods (Apply/Unapply, Tick, etc.) to apply