Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!

Splinter of Chaos

Member Since 08 Jun 2006
Offline Last Active Private

Topics I've Started

What do i google? (Trying to implement some lighting and shadows.)

16 March 2011 - 08:22 AM

Whenever someone says they don't know where to start, i think that they don't know enough about the topic at hand and need to do some research until they understand. So i googled lighting and opengl, but it wasn't entirely productive because i really don't understand a thing about lighting. Seems like OpenGL has some light-related functions, i've also heard of implementing lighting with GLSL. If there's two techniques, might there be more?

Here's what my game looks like with no lighting.

Posted Image

I color each side of the walls differently, manually, but i want that to be done by the lighting. Also, i want them to cast directional shadows to help the player understand the platform's relative positions. (Information that would normally come naturally through perspective. I also want the player to cast a sharp shadow, no aliasing.

I've little-to-no interest in graphics programming so i'm just looking for the cheapest, easiest solution. That brings me back to the topic: What should i google, what do i need to learn in order to know what to do?

Having trouble with optimizing particle physics with multi-threading.

30 January 2011 - 02:09 AM

Here's the basic situation: In my game, pretty much all parts of the code, in terms of execution time, are peanuts when compared to my particles. It's a game that takes place in space and everything orbits each other. I found that in order to have particles update with any sort of accuracy, i need to update the particles along side everything else like so:
for each timestep:
    update all actors (the player, the enemies, etc.)

    for each particle:
        for each actor:
            calculate gravitational acceleration
            check collision with actor
They update at four times a frame (assuming 60fps).

The problem: I want to be able to render as many particles with a stable FPS on screen as possible. Currently, all the work is done on one CPU and this lets me have 8 thousand at one time on my computer (2.8Ghz CPU, if i remember right). I'd think that multi-threading this would let me render over 10K, but all attempts at multi-threading have thus far bore no fruit. What i'm wondering is if the overhead of starting and stopping all the threads four times a frame, or 4*60=240 times a second is so great that it cancels out any improvement. On top of that, particle physics is otherwise written directly into int main; splitting it up into a function itself creates a performance drop.

My current attempt was a copy/paste of this, the worker thread part. The only thing i changed, practically, was the names of variables. Even so, it's all opensource here and all the relevant code is in main.cpp, lines 998-1086, 1107-1113, and 1266-1268. (The number of threads used when i uploaded this code was 60--a mistake, but i've tried many different numbers, no change.)

I'm open to the idea that i'm doing just about everything entirely wrong, but i'm hoping i can get some benefit from parallel execution. I've also considered GPU programming (CUDA or PhysX), but i'm trying to avoid that because i know nothing about it.

PS: In the past, i updated particles separate from the actors, and i could have considerably more on screen at once. Since then, they've also become much more complex. That's why i believe memory access, hardware rendering, and the sort can all be eliminated as limiting factors in how many particles i can handle.

Judging game complexity verses skill.

10 September 2010 - 03:12 PM

I think i and many beginners would benefit having a discussion about coming up with game ideas, especially original ones, but keeping them simple enough that s/he will be able to pull it off without getting discouraged. For example, very few would encourage a beginner to make an MMO, but i'm not comfortable with telling beginners to make a Tetris clone. I think that beginners can make their own games, their own ideas, as long as they keep it simple.

And i don't just mean what should an absolute beginner make, but say you've made your Tetris, Breakout, and Mario clones, what should you do next? Maybe you've made a few of your own games, but aren't ready to tackle a big one yet, how might you create a more challenging, but still not overwhelming game?

I'm curious what others have done that has worked. How long did it take to make? How did it turn out and do you think a more or less challenging project would have been better, or do you think that you could have simplified it more than you did?

I felt my first game was pretty successful. The concept is you're this ship and you spawn in the center of an arena, which is where the entire game is played. Enemies spawn randomly and orbit the player. Points are awarded when you crash two enemies together and you die when one hits you. Having very little game logic helped. Few conditionals, few problematic special cases. Making it all take place in a one-screen arena helped because i didn't have to worry about side-scrolling, multiple rooms, or anything like that.

Also, each of the on-screen objects were circular, so collision detection was easy. Collision detection of differently shaped objects would probably have been too difficult.

Or coarse there were bugs i never ended up fixing and it didn't have everything i wanted in it, but it worked, it was fun, and it gave me enough confidence to go make more games.

This was a good choice for me because i have an interest in physics so i was able to understand the equations for gravitational acceleration and calculating position given a velocity and acceleration.

It took me a month to make, including just getting SDL to create a window. This was fine for me because that was the exact length of my spring vacation. I probably could have done it much faster if i used Python, which i was much more familiar with. At the same time, doing it in C++ was a better learning experience.

Have you started a game, but not finished for any reason? If you're making your first real game right now, what is it and how is it going? What have you all done and how has it helped or hurt your advancement in game programing? Thanks in advance for responding. I hope we can learn from each other.

Trouble making performance consistent on Windows and Linux. [solved]

07 September 2010 - 09:06 PM

There's not much to it: my game appears to run faster on Linux than Windows. When i start it in Linux, one of my CPUs jumps to 100% usage and the game seems like it's in fast motion. On Windows, it seems like in slow motion and i don't even see any stress on any of my cores unless i spawn several hundred particles at once, which i do.

This is the code that moves all of my game objects which i call actors:

for_each (
actors.begin(), actors.end(),
std::bind2nd( std::mem_fun_ref(&Actor::move), frameTime )

Actor::move is a pure virtual function accepting a float, dt, representing how many milliseconds to integrate. frameTime is set to be how long the last frame lasted.

I'm a little at a loss here... Since i calculate motion based on frame time, i thought maybe the difference in frame time between Linux and Windows could be to blame so i wrote this:

const int DT = 5; // in ms.
static int time = 0;
for( time += frameTime; time >= DT; time -= DT )
for_each (
actors.begin(), actors.end(),
std::bind2nd( std::mem_fun_ref(&Actor::move), DT )

But still i get the same problem. The best solution i've found so far is to replace the second argument of bind2nd with DT*1.3 or so in the Windows version, but that's obviously hacky and problematic.

I don't know if i should slow the Linux version down or speed the Windows version up, i just know i want them to behave the same. Has anyone else ever encountered such a phenomenon? Any tips?

[Edited by - Splinter of Chaos on September 8, 2010 10:14:25 AM]

Rectangular vectors, angular physics

24 May 2010 - 08:13 AM

It's been a little while since physics class, but not too long... Anyway, in my game, i have these stick men inside a circle. As far as collision detection or physics is concerned, the stick men are represented as points and the circle is a circle. The stick man, point, spawns inside the circle, and is pulled by gravity until it hits the circumference. It then, ideally, should be pulled by gravity down the slope of the circle. Friction isn't a feature i care about, yet. I was able to get the code working such that the stick men are pulled by gravity and while on the rim of the circle a normal force sums up to a force tangent to the circle. This means that every frame, my stick men move slowly away from the center of the circle. What i need is a centripetal force, but i'm using a linear one. I understand the equations and basics, but i believe my problem to be not having a good understanding of how to relate the linear data (position, velocity, acceleration) to angular data. Even if i can produce a tangential acceleration, i can't understand how to product angular motion. I believe my problem to be similar to a pendulum and there are a lot of physics examples i found through google for that, but i wasn't able to produce the expected results at all. I'd show what i've written, but i haven't written anything worth not erasing. I'd be grateful for some sources on this. Right now, i'm trying to get the stick man physics right, but eventually i'll be making the circle a physical object as well and complexities like colliding with sticks and circle while maintaining system momentum will be keeping me up at night. So, sources that go beyond the scope of this discussion are appreciated.