Starfield
Displaying 1-10 of 10 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
locke

Thanks for your help so far, guys. I'm moving along here, and I've run into a new issue.

I'm trying to build a basic starfield, but the performance is really poor, and I get a lot of flicker. I'm thinking I am missing some key concepts surrounded the timers, and the use of hooktimer.

I've cobbled together something that _works_, but again, performance is abysmal. I mean, I look at the Shippu demo, and my performance isn't anywhere near that, with half as many stars.

Something is clearly screwed.

Zaratustra (or anyone with a good starfield)? Would you be willing to show me your starfield code? Or at least how you deal with tracking and rendering so many stars with little-to-no flicker or slowdown?

If you want to take this off the air, you can email me at:

bstoffer AT mac DOT com

Thanks!

-lok

Posted on 2004-02-25 22:45:52

rpgking

To eliminate flicker in all cases, just wait until everything has been drawn to the backbuffer(or screen image in V3) before calling ShowPage(). You really only need a single ShowPage() within your game loop, and that goes after everything is drawn. If you have multiple ShowPages, or put it some place in the loop that causes it to be called multiple times before everything is drawn, there'll definitely be flicker...

Posted on 2004-02-26 04:59:11

TomT64

Try my starflight demo. When you input new x and y values into the DisplayStarField function, the stars show up in different locations. It is mainly designed for scrolling in any direction. You only need stars.vc for it to work.

Posted on 2004-02-26 10:53:38

andy

A big cause of weirdness like this is HookTimer. I generally stay the heck away from it for this reason, especially if you've already got your own game loop running. (which is necessarily the case at present)

(that being said, drawing stuff in a HookRetrace should work)

Posted on 2004-02-26 15:15:32

locke

Thanks for the advice, ya'all.

I only call ShowPage() at the end of my main game loop. I'm not using hooktimer at the moment. All of my timing is done by taking the value of "timer" and adding some amount to it, then checking that timer has reached that value. It seemed like the easiest way to keep time without having to have pile of timer variables, and it works. Just not well.

I suspect it's drawing more than once. Is there any function other than ShowPage that would case something to be drawn directly to the (viewable) screen?

I will look at RPG's demo. I suspect I just need to wrap my head around a few things. Honestly, I'm having a great time with it. I stopped working on the starfield and started in on the AI and weapons systems. I even had time to start drawing some graphics. ;)

WOOT.

Thanks again for your help, guys. I'll get this shooter out someday!

-l

Posted on 2004-02-26 16:22:32

TomT64

A common pitfall is to make a function that calls ShowPage() at the end. Don't do this. Make functions that draw, but dont' call showpage, then call all those functions THEN call ShowPage().

Also, it's MY demo muahahaha

Posted on 2004-02-27 00:17:00

locke

Heh. Yes.. yes of course... YOUR demo. Apologies. I actually liked it quite a bit. I'd even like to wrap a game around it if you were inclined to allow it. ;) I'm more of a designer than a programmer... but hey -- with VERGE I get to be both. Or something.

I only have one call to ShowPage()... it's at the very end of my main loop.

I think it's pretty simple... and I've done game development long enough to build out a simple game loop, but honestly, I think there's some weirdo lag in there from my spaghetti code.

Here... check it out for yourself. Other than the fact that the code is ugly and {insert other disclosures about style and substance here}, I wonder if you can see the weirdness.

Any advice is always welcome.

Thanks!

-b

Posted on 2004-02-27 01:03:20 (last edited on 2004-02-27 01:08:22)

blues_zodiakos

Alrighty, I don't know the exact problem yet, but if you erase the screen fill (The black rectfill) you will notice that the stars AND enemies are only being blitted every other line. That would be the cause of your flicker.

Also, you don't need to use UpdateControls, it is called automatically by ShowPage. Only use UpdateControls if you have a really tight loop, or you are using hookretrace, I think.

-edit

AHA! I was wrong, I know exactly what it is. Since you have the starfield set on a timer, and you clear the screen everytime, that means that sometimes the timer has not yet reached it's time yet by the time the next frame is set to draw. Hence, the starts are sometimes not drawn to the frame. If you want to do this, don't use timer to do it, unless you specifically blit all the stars to the frame each time.

There's a REALLY easy way to do this involving arrays. I'll right one up for your tomorrow morning.

Posted on 2004-02-27 04:52:16 (last edited on 2004-02-27 05:04:21)

TomT64

You need to divide your process_stars function out into two functions. Make process_stars() only update the x and y values. make draw_stars() draw them (SetPixel) if they are active.

Also, you can make a game around my demo, once I finish making the SDL version have full scenario scripting capability. But for now, check it out.

Posted on 2004-02-27 11:59:42

locke

Wow. Thanks guys. That's really helpful.

I will fix up the draws and the timer... I can't believe I didn't think of that. ;|

Also, breaking out the process_stars function makes a lot of sense, and after seeing your demo (Tom) I was going to do that anyway.

Ultimately I will break all of this stuff out into different files, etc, make it more readable and more managable. I just wanted to get the basics working first... then clean it up.

Thanks for your help guys.

-l

Posted on 2004-02-27 17:24:58


Displaying 1-10 of 10 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.