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 / SplashScreen flickering in my 3D game

Author
Message
SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 6th Mar 2013 17:40
Hi there.
In my game i have some bitmaps that i want to displaay on my screen...basically a splashscreen. the problem is the\at it is flickering.
Here is an example of one of them.
(It is a Bitmap with a question on it.)


If I put it outside a Do loop then it only flashes once and moves on; and if I take out the SYNC then it will not load agail when it repeats.

-Sa
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 6th Mar 2013 18:37 Edited at: 6th Mar 2013 18:37
Use



or



ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 6th Mar 2013 18:56
Chris Tate's second solution seems to be the best option here. If you simply want to load and display an image, use the image commands (or even sprites, but in this case images should suffice). I believe bitmaps (I'm not referring to the file format, but the DBP-bitmap-commands - bmp-files can also be loaded as image) are used for more complex cases that, for instance, involve drawing only to certain areas of the screen (which would be required when implementing something like a split screen mode of a 2D game).

Also, "load image" (as well as load bitmap and basically all other load commands) should always be called before the main loop, not inside it, since the media that is loaded stays in the memory until you delete it (or the program ends).
The drawing however, as well as the key checks, should be implemented inside of a loop, since otherwise the commands will be executed just once - in this case the image would be drawn once very quickly, after that the 4 if-statements would all check whether a key is pressed and probably return "false", and then your program continues with whatever comes after that (or just end when there's no more code left).

If those things have already been clear to you, sorry about that, but after reading your post I wasn't quite sure.

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 6th Mar 2013 23:36 Edited at: 6th Mar 2013 23:41
Quote: "I believe bitmaps ... are used for more complex cases that, for instance, involve drawing only to certain areas of the screen (which would be required when implementing something like a split screen mode of a 2D game)."


Now, now, there is nothing quite wrong with using bitmaps to display images; the person who created Dark Basic often used the same procedure with bitmaps to display images in FPSC. Bitmaps can be used in simple cases too.

The end result of both snippets is an image displayed on the screen; correct me if I am mistaken. Only the second method is simply what 'most people' find comfortable, or what they are used to seeing each other use.

One advantage of using bitmaps is that you can easily draw additional graphics onto them without having to redraw such elements whilst displaying the result at variable sizes with clipped ranges; something not so easy with images. In this instance, neither images, sprites, camera backdrops, 3d planes or bitmaps will make a significant difference to the result of displaying an image on the screen. As they say, it's not what the tool is called or what it was intended for, but what it produces.

SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 7th Mar 2013 17:14
@ Chris Tate,
I tried both of your suggestions, but the same results come.
Any other ideas?
I've tried making different DO LOOPs with different commands to get the bitmap to load, but it always ends up flickering, or not loading.
By the way, the game is 3D, so I have a function before loading the splash where I delete all the objects.

-Sa
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 7th Mar 2013 23:50
Flickering playback indicates that either the sync command has been used without activating it using 'sync on' or something else is disrupting your view.

Unless someone recognizes this issue of the bat, your best bet is to post up all of the code so we can see the problem.

SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 8th Mar 2013 17:16
Here it is.



-Sa
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 9th Mar 2013 00:16 Edited at: 9th Mar 2013 00:23
As suspected; you will need to use [Sync On], before using the [sync] command; it literally prepares the engine to wait for your sync command before rendering (or refreshing) the scene.

Just a little question, why did you use the sync command anyway?

At this point;
you are rendering the scene that is already being rendered automatically.

Quote: "By default, sync is set to off which allows the system to automatically handle screen refreshing. When SYNC ON is used, your program is responsible for handling screen refreshing."


There are some other things to watch out for;

Quote: "load bitmap "E:\advanced tech\edutainment\Game Images\images\splash.bmp""


This is quite suitable for the splash screen you are creating, but you have flickered this bitmap away when you used the Sync command without first using Sync On, but generally, you need not use any sync commands at first.

You should have done something like this at the start for the splash screen:


That will suffice for a splash screen, it shows the bitmap for 5 seconds.

If you must use the sync command, you should specify a bitmap ID since the current bitmap (0) is the screen; not specifying the ID references the current bitmap, the screen by default, which is always wiped off by the next frame of rendering when sprites or 3D is active. Specifying another bitmap would store the image in memory, which can be copied to the screen. Take another look at the first examples I gave.

Quote: "sync rate 12000"


This is not a good idea. What you are telling the CPU is to render the scene 12,000 times per second, which is extreme. Most people tend to synchronize 60 times per second, but it depends on the application. Sometimes 30 is better, other times setting it to the maximum possible by using a value of zero is desirable.

I am sure you will change this as stated earlier


There are other problems with your code that I am sure you will correct as you get better, but one that can be quite detrimental to your progress is your use of the GoSub command, and in particular your use of the GoTo Command.

Generally speaking, a sub routine (gosub) should be a routine that forms part of a larger procedure, and should be concluded with a Return statement which sends the flow back to the calling procedure. But you are using it and the GoTo command as means to structure logic, which is breaking up the flow of the logic.

These structures of program logic will be more easy to work with in the long run:



Remember sub routines are a part of a large routine; hence the phrase 'sub' routine

Good ways to use Gosub (or functions)



Goto is never used in logical programming in this fashion, only to rearly skip past a small section of code or to exit a series of loops in loops.

Its a lot to consider and seems pointless at first, but it all makes sense when you start hitting bugs that need tracking; logically structured code is just simply easier to perfect.

SS45
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 12th Mar 2013 16:12
@Chris Tate Thanks very much!
With your help I managed to fix my game!
Just one more question: Is there an alternative to using static collision boxes (they don't seem to work for me) that I can use but still have objects not go through each other?
Once again, THANKS so much for helping!

-Sa
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 12th Mar 2013 22:53 Edited at: 12th Mar 2013 22:57
My pleasure SS45.

They have created a number of collision and trigger systems because the standard commands are limited. Here are alternatives; just work from the examples provided in the downloads, once you do that you will be more unlikely to struggle...

Dark Dynamix | Dark Physics (Popular NVidea PhysX wrappers, Dynamix the more recent and the one I like to use) One of these are a good place to start, using these kinds of plugins lets the computer do more of the work, giving you more time to work on the game.

Additionally, Sparkys Collision should be used as a free replacement for all of the standard collision commands; although not directly hardware accelerated like the PhysX plugins, sometimes a CPU calculation is easiest to work with, and SPC is smarter than the standard collision system.

All the static stuff in the GameFX help file is pretty much Lee's toolbox for creating the FPS Creator x number of years ago; most people avoid using many of those commands in today's programming; They're quite dated, these days games throw the collision burden on NVidea; unless you're Valve or Blizzard entertainment.

If you are only interested in a short term free solution, there is a free edition of Dynamix available.

What also is quite handy is Matrix1's zone commands, you can use statements like IF Point In Zone(ID). Where the point is a characters location, you can check the area the player is in; obviously what applies to one object as the player can apply to all objects.

Login to post a reply

Server time is: 2026-07-07 08:18:48
Your offset time is: 2026-07-07 08:18:48