Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Sync mask for split screen?

Author
Message
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th May 2010 15:33 Edited at: 20th May 2010 15:59
I'm trying my first attempt at a split screen game using camera 0 for player 1 (Top half of screen) and camera 1 for player 2 (Bottom half of screen).

The problem I am having is that the bottom half of the screen shows explosions (textured planes using the explosion code from an old newsletter) correctly angled toward the camera but the top half seems to flicker and show the planes facing both cameras.

I'm guessing that what's happening is it's rendering the top half twice and the bottom half once but I can't figure out why...

Some help would be much appreciated! Here is my sync code:


...and here is a link to my WIP (sorry it's over 50Mb) so you can see the flicker:
http://www.filefront.com/16496261/HFL.zip/

Use "WASD" to drive player 1 and 'v' to fire
Use "[;'#" to drive player 2

Just for those interested the game will be a football game using vehicles... called "Hell for leather!"

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th May 2010 16:19
Why!

I have no idea why people use extra cameras so much, for a split screen game they really aren't necessary.

I mean, why not just change the camera view, so have camera 0 - and change the player render each loop - update the first player, then the next loop, update the second player.

This has the benefit that it will affect the frame rate very little - changing the camera view means that you are rendering a smaller area, even rendering every other loop is no issue if you use timer based movements. This worked incredibly well in Drew's Dumbo and Cool. So consider this...

If you use an extra camera, you have an extra camera!, taking up performance, not allowing full control over rendering, rendering differently on different cameras, 2 sets of parameters to worry about, inflexible, horrible to disable.

But if you only have 1 camera...

* You have 1 set of parameters only.
* You can be sure that it'll render as expected.
* There is nothing taking up performance in the background.
* You can use your own camera system, virtual cameras if you like.
* You can be dynamic - easy to set back to a single player view, no cameras to delete or manage.
* Your shaders will just work as expected - extra cameras have issues when rendering for shaders.

Maybe I'm being OTT - but I would never use an extra camera just because it's 'convenient' - mainly because they are not convenient at all. What is convenient is the ability to have player 2 join or quit without affecting anything.

I should make a little example again, split screen multiplayer tanks with timer based movement and roaming players, a top view option, and with no extra cameras or non-standard commands. I'll have it done tonight.


Health, Ammo, and bacon and eggs!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th May 2010 16:31
Quote: "I have no idea why people use extra cameras so much, for a split screen game they really aren't necessary."

Well, I'd never thought of doing it that way, and as I said it's my first attempt at a split screen multi-player so...

Quote: "Maybe I'm being OTT "
... maybe a little.

Did I touch a nerve by being ignorant or something?

By the way your way is much better. I'm changing my code now, just go and have a cup of tea and relax a little

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th May 2010 16:43
Hehe - it's too damn hot right now - I want an ice lolly

Was not instigating that you were being ignorant - extra cameras seem like a good idea, but you will love the benefits of not bothering with them.


Health, Ammo, and bacon and eggs!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th May 2010 16:49
Quote: "it's too damn hot right now"

Tea is a bad idea then sorry!

Quote: "you will love the benefits of not bothering with them"

I will when I get the **** thing working. I'm using "set camera view" is that a bad idea? A quick pointer would be great if you have 2 mins? [bowing down to the master]

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th May 2010 16:58
Yeah, SET CAMERA VIEW should do the trick. I would setup a type for the camera, storing the 3D XYZ position, XYZ rotation, and the actual screen area to render to.

I will make an example when I get home, promise.


Health, Ammo, and bacon and eggs!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th May 2010 18:21 Edited at: 20th May 2010 18:22
Well I got it working using your suggestion @Van B, thanks.

There were a couple of side issues that arose because of the change;
1- Now I am 'sync'ing twice per loop I had to mess around a bit with my movement etc as I had no timer based movement yet
2- It screwed up the "set camera to follow" routine as I was using smoothing so it was trying to smooth constantly between being behind both vehicles. The solution was to make my own code for smoothing the camera position (easier than I thought to impliment).

Here is a rough draft of my camera smoothing (for one camera):


Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 20th May 2010 18:44
Don't sync twice per loop.

One loop update one view, next loop do the other.

My signature is NOT a moderator plaything! Stop changing it!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th May 2010 18:48
If I don't sync how does it draw the view to the screen?

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th May 2010 19:08
Here's that example I promised...



I did what mobiius has just said, swap between 'players' and update only one view per loop - update both players controls etc though. Have fun finding your balls in the dark...


Health, Ammo, and bacon and eggs!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st May 2010 01:14
Thanks Van B!! I'll run this and study it. I'm close with what I have I think but there's some interesting stuff in there on first inspection!

One thing I just noticed is that you declare several globals in one line, I do that in C# but didn't know it was possible in DBP just using spaces

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th May 2010 13:51 Edited at: 26th May 2010 13:52
I have a further question.

I'm using something very similar (but not as cleverly written) to Van B's suggestion but when I start using sprites it all goes 'flickery' and sometimes cameras don't work...

Just add this in before the loop:


Using the attached media and you'll see what I mean.

I'm hoping to use sprites for my text and images 'in game' and I'm sure there must be a simple way around it but I can't work it out...

EDIT: Forgot to attach media

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th May 2010 14:30
Ahh, see when you change the camera view, the bits of screen that are not in the view will be left, because theres probably nothing clearing it out - so you might have problems with sprites flickering because they will probably be saving their back (like storing the space under them so it can be replaced if they move). Usually backsave is not necessary with sprites, it should really be disabled by default for all the good it does.

However, there's probably ways around it - depends on what text you want to display. I would only update the text on the current view, so the camera view setting will wipe out the back, then I would use PASTE SPRITE, this is like PASTE IMAGE, totally 2D rather than relying on a 3D environment. If you paste your sprites then you can keep them off screen, then you will have total control over them. I actually use the same sprite over and over when pasting - with my bitmap text fonts, these days I just use a writer sprite, it works like a print head, pasting the appropriate image or part of image as it goes. There are benefits in sprites, but often you have to take control over them, be able to paste them when you need so you don't have to leave sprites hanging around on the screen, causing mischief.

So... I think the best thing to try, is positioning your sprites off screen somewhere -10000,-10000 for instance - but then PASTE SPRITE into the real position. I think that will afford you the control you need, then remember that the other view doesn't get wiped with the sync.


Health, Ammo, and bacon and eggs!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 26th May 2010 14:35
Quote: " I think the best thing to try, is positioning your sprites off screen somewhere -10000,-10000 for instance "

Or use Hide Sprite...

My signature is NOT a moderator plaything! Stop changing it!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th May 2010 14:56 Edited at: 26th May 2010 15:19
Quote: "positioning your sprites off screen somewhere -10000,-10000 for instance"

I was already using "paste sprite" and positioning off screen (I found this helped a lot in "Odd Blox" for text and 'help' images).

Quote: "Or use Hide Sprite..."

...already doing that too

One important fact here (maybe) is that these sprites are not even being pasted in at this moment in time, they're just hidden off-screen! They were in use in the menu but not being used in the loop.

EDIT: "Paste image" does not cause the flickering so I can only put it down to sprites. Unfortunately I need to be able to re-size my images and using sprites gives me much more control for various other things so I can't just use "paste image"

EDIT2: FIXED! You were right Van B, I had to turn backsave off!

Solution:


Login to post a reply

Server time is: 2026-07-25 11:29:17
Your offset time is: 2026-07-25 11:29:17