Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411613 Posts in 69390 Topics- by 58447 Members - Latest Member: sinsofsven

May 10, 2024, 03:27:31 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The happy programmer room
Pages: 1 ... 181 182 [183] 184 185 ... 279
Print
Author Topic: The happy programmer room  (Read 679703 times)
RalenHlaalo
Level 0
***



View Profile WWW
« Reply #3640 on: January 05, 2014, 10:20:50 AM »

For one of my previous games, I implemented the ability to record the player's inputs and play them back later to re-simulate the play session. It was pretty cool, and I wanted it in my current project, so I turned it into a reusable library. Got it integrated into the new one now, and it worked perfectly first try. I'm automatically saving all play sessions to disk in a way that won't be disrupted by a crash, with the idea that this would be an amazing feature to have for debugging... If I find a bug or a crash, I'll always have a replay that can reproduce the problem. Very pleased with it!

The benefits of determinism! Does this mean you're limiting the frame rate somehow, as opposed to moving things by variable deltas? That's what I'm doing, by sleeping the thread - which works more reliably on some platforms (Linux) than on others (Windows).

Another advantage is the ability to play in-game cut-scenes as just a sequence of actions, requiring very little memory. For example, a character could run and jump onto a moving platform, blast a bad guy, all while dodging pieces of falling debris, and you can guarantee that it will run the same every time.
Logged

zacaj
Level 3
***


void main()


View Profile WWW
« Reply #3641 on: January 05, 2014, 10:22:41 AM »


Another advantage is the ability to play in-game cut-scenes as just a sequence of actions, requiring very little memory. For example, a character could run and jump onto a moving platform, blast a bad guy, all while dodging pieces of falling debris, and you can guarantee that it will run the same every time.

If you can encode your cutscenes using regular input, you might want to reconsider them being cutscenes...
Logged

My twitter: @zacaj_

Quote from: mcc
Well let's just take a look at this "getting started" page and see--
Quote
Download and install cmake
Noooooooo
RalenHlaalo
Level 0
***



View Profile WWW
« Reply #3642 on: January 05, 2014, 11:51:04 AM »


Another advantage is the ability to play in-game cut-scenes as just a sequence of actions, requiring very little memory. For example, a character could run and jump onto a moving platform, blast a bad guy, all while dodging pieces of falling debris, and you can guarantee that it will run the same every time.

If you can encode your cutscenes using regular input, you might want to reconsider them being cutscenes...

Perhaps I didn't mean 'cutscenes'. What word would you use? I'm sure you knew what I meant.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #3643 on: January 05, 2014, 01:53:10 PM »

The benefits of determinism! Does this mean you're limiting the frame rate somehow, as opposed to moving things by variable deltas? That's what I'm doing, by sleeping the thread - which works more reliably on some platforms (Linux) than on others (Windows).

Yep, fixed delta for everything related to game logic. If sleeping your thread isn't reliable, you might be able to get better results by enabling vsync and doing something like this.

Release it!

Working on it! I'll post here once it has a home. It's technically available now (with minimal documentation, and a bunch of dependencies on other things in my game framework) if you want to dig through my svn repository: http://sacredsoftware.net/svn/misc/StemLibProjects/inputcontroller/trunk/
Logged

RalenHlaalo
Level 0
***



View Profile WWW
« Reply #3644 on: January 05, 2014, 02:38:52 PM »

The benefits of determinism! Does this mean you're limiting the frame rate somehow, as opposed to moving things by variable deltas? That's what I'm doing, by sleeping the thread - which works more reliably on some platforms (Linux) than on others (Windows).

Yep, fixed delta for everything related to game logic. If sleeping your thread isn't reliable, you might be able to get better results by enabling vsync and doing something like this.

The problem is, my renderer runs in a separate thread. If I were to use the method described in that article, it would essentially amount to 'busy waiting', which I'm trying to avoid. I'm proud of the fact that when my engine is running, the CPU usage is very low (for a simple game). You can minimise the game and do other things without the fan speeding up or your laptop getting hot.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #3645 on: January 05, 2014, 03:14:25 PM »

Waiting on vsync should use basically no CPU. That said, there are other benefits of multithreading, like being able to take advantage of multiple CPU cores... It should still be possible to use a fixed timestep with your method, just by having the logic thread try to sleep for an appropriate amount of time, and the render thread block on vsync and use the latest results it can get from the logic thread to draw stuff.
Logged

RalenHlaalo
Level 0
***



View Profile WWW
« Reply #3646 on: January 05, 2014, 03:26:34 PM »

Waiting on vsync should use basically no CPU. That said, there are other benefits of multithreading, like being able to take advantage of multiple CPU cores... It should still be possible to use a fixed timestep with your method, just by having the logic thread try to sleep for an appropriate amount of time, and the render thread block on vsync and use the latest results it can get from the logic thread to draw stuff.

Yeah, that is what I'm doing. It's just that sleeping isn't quite as reliable under Windows as it is under Linux, but it's not a big deal.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #3647 on: January 05, 2014, 03:32:45 PM »

Yeah, that is what I'm doing. It's just that sleeping isn't quite as reliable under Windows as it is under Linux, but it's not a big deal.

Maybe you could use a semaphore to wake the logic thread when the render thread finishes a buffer swap? I don't do a lot of real-time multithreading, so I'm not sure if this is a good idea, but off the top of my head it seems like it might work...though maybe Windows's semaphores have timing just as imprecise as its sleep functions.
Logged

RalenHlaalo
Level 0
***



View Profile WWW
« Reply #3648 on: January 05, 2014, 05:23:37 PM »

Yeah, that is what I'm doing. It's just that sleeping isn't quite as reliable under Windows as it is under Linux, but it's not a big deal.

Maybe you could use a semaphore to wake the logic thread when the render thread finishes a buffer swap? I don't do a lot of real-time multithreading, so I'm not sure if this is a good idea, but off the top of my head it seems like it might work...though maybe Windows's semaphores have timing just as imprecise as its sleep functions.

I imagine the thread would still have a tendency to occasionally oversleep. Moreover, the reason I decoupled the renderer from the main thread in the first place was to allow the game logic to run at a decent speed on occasions when rendering is slow - such as on low-spec hardware - thus maintaining the speed and responsiveness of the underlying simulation. Tying the main thread to the renderer in the way you suggest would defeat the purpose of this multi-threaded design.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #3649 on: January 12, 2014, 11:53:48 AM »

Happy moment yesterday: I had a need for some small snippets of code scattered around various modules to run at startup. I didn't really want to have to update main() to call each one explicitly, but I didn't know of another way to do it. After discussing with other programmers for a while, and briefly considering parsing my executable for to load symbols matching a specific pattern and execute them, I stumbled upon __attribute__((constructor))...exactly what I needed! gcc function attributes can do all kinds of cool shit: http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
Logged

Rusk
Level 1
*


View Profile
« Reply #3650 on: January 12, 2014, 04:34:34 PM »

Happy moment yesterday: I had a need for some small snippets of code scattered around various modules to run at startup. I didn't really want to have to update main() to call each one explicitly, but I didn't know of another way to do it. After discussing with other programmers for a while, and briefly considering parsing my executable for to load symbols matching a specific pattern and execute them, I stumbled upon __attribute__((constructor))...exactly what I needed! gcc function attributes can do all kinds of cool shit: http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

That is cool... but I can imagine how tricky it would be to hunt down a bug in those functions if you didn't know (or forgot) about that. Well, hello there!
Logged
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #3651 on: January 12, 2014, 04:48:28 PM »

That is cool... but I can imagine how tricky it would be to hunt down a bug in those functions if you didn't know (or forgot) about that. Well, hello there!

For sure! Definitely a thing to use as sparingly as possible. The situation I have is perfect for it though.
Logged

Slader16
Level 8
***



View Profile
« Reply #3652 on: January 12, 2014, 05:01:02 PM »

I made my first program in Java. It prints out the multiples of whatever number a user inputs.  Grin
Logged

OniWorld
Level 2
**



View Profile WWW
« Reply #3653 on: January 12, 2014, 07:06:10 PM »

Finally got support in for quadratic bezier curves, now I can make amazing environments with very little effort and processing power!

Logged

TheLastBanana
Level 9
****



View Profile WWW
« Reply #3654 on: January 12, 2014, 09:10:07 PM »

That looks super cool, OniWorld!
Logged
oahda
Level 10
*****



View Profile
« Reply #3655 on: January 13, 2014, 06:14:02 AM »

Finally got support in for quadratic bezier curves, now I can make amazing environments with very little effort and processing power!
ÆæÆÆÆææææÆæææä that looks soo good.
Logged

Noogai03
Level 6
*


WHOOPWHOOPWHOOPWHOOP


View Profile WWW
« Reply #3656 on: January 17, 2014, 10:57:24 AM »

1) dat bezier curve


2) it's so weird when you find really cool frameworks that have barely been used by anyone, especially when they're really advanced (like with their own setup program, etc)
Logged

So long and thanks for all the pi
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« Reply #3657 on: January 17, 2014, 01:04:46 PM »

Just made an Answer Set Programming model that can create metroidvania style maps with lock and key mechanisms. It can burn out 1000 different maps in 1.5 seconds.  Pretty psyched.
Logged
Garthy
Level 9
****


Quack, verily


View Profile WWW
« Reply #3658 on: January 17, 2014, 03:12:55 PM »


Happy moment yesterday: I had a need for some small snippets of code scattered around various modules to run at startup. I didn't really want to have to update main() to call each one explicitly, but I didn't know of another way to do it.

If you're using C++ and are after a compiler-portable way to do it, you can always use the constructor in a class that is used for a global object, eg:

Code:
static void CodeToCallOnInit()
{
  // Do stuff here.
}

class Foo
{
  public:
    Foo() {CodeToCallOnInit();}
};

static Foo foo;

Early C++ compilers had some trouble with this (I saw similar code have problems with gcc circa 1997 but the actual gcc may have been older) but it's been a safe construct for a while now. It'll be called before main() begins, at least in every environment I've seen.
Logged
riksteri
Level 0
**



View Profile
« Reply #3659 on: January 19, 2014, 06:31:30 AM »

Preparing to publish my first open source project. It is really just for giggles and learning the ropes of the hosting services out there (this one is in Bitbucket). Hopefully it also gets employers to tick off another box for me when I apply for jobs. Not a too serious development effort, but still plenty of reason to make me happy for the moment. Still a couple things to do before hitting the button. (It is not a game, by the way).
Logged
Pages: 1 ... 181 182 [183] 184 185 ... 279
Print
Jump to:  

Theme orange-lt created by panic