Triggering screen changing?
Blitz3D Forums/Blitz3D Beginners Area/Triggering screen changing?
| ||
I know that I just created a post asking how to change screens and levels. Thanks from the help of the help of numerous Blitz3d users, I now understand how to manage screens and levels. Now all I need to learn is how to change them. I need to know how to trigger each screen to switch to the other. Can someone help me achieve this? please reply.thanks. |
| ||
Here is a sample based on the code you provided.Graphics 640,480,0,1 SetBuffer BackBuffer() Const Title_Screen = 101 Const In_Game = 201 Const In_Game_Paused = 202 Global GameStatus = Title_Screen Global SampleText$ ;This will only be used to display what's happening internally in Blitz ;Main Loop ;-------------------------------- While Not KeyDown(1) Cls GetGameStatus() Select GameStatus Case Title_Screen title() Case In_Game game() Case In_Game_Paused gamepause() End Select Text 10,10,SampleText$ Flip Wend ;-------------------------------- ;End Main Loop End ;Functions List ;-------------------------------- Function title() SampleText$ = "You are now at the Title Screen!" End Function Function game() SampleText$ = "You are now Playing the Game!" End Function Function gamepause() SampleText$ = "You have just Paused the Game!" End Function Function GetGameStatus() If KeyDown(57) ;If We Push the Spacebar GameStatus = Title_Screen ;Go to the Title Menu EndIf If KeyDown(28) ;If We Push the Enter Key GameStatus = In_Game ;Start the Game EndIf If KeyDown(25) ;If We Push the "P" Key GameStatus = In_Game_Paused ;Pause the Game EndIf End Function ;-------------------------------- ;End Functions List |
| ||
Rob The Great Thanks for the example, but I have another little problem. I tried modifying your well done example by making it change from a 2d screen with text to a 3d game with blocks. When I changed to the 3d level from the 2d title screen, it worked great, but when I tried to change to the 2d title screen from the 3d level, it doesn't change. Could you help me out again? Sorry for asking for so much from just one person, but the help would be very...well....helpful. please reply.thanks. |
| ||
Check your Graphics 3D resolution as I don't think that I have never seen a screen resolution of 1280x600 (yet) and it would be a good idea to re-write your code using a flag variable so the the graphics mode is set only once for each mode change. Edit: had another look at your code the problem your having is this bit While Not KeyDown(1) RenderWorld() If KeyDown(2) Then Return EndIf Flip Wend EndIn the "game()" function try changing it to this While GameStatus = In_Game RenderWorld() Flip GetGameStatus() If KeyDown(1) Then End Wendand it would be wise to move your Graphics3D/2D commands into the "GetGameStatus()" function so that they are set only once. What was happening was that after you was returning from the while loop the GameStatus variable was still set to In_Game and all it was doing was calling the "game()" function over and over. |
| ||
OK had a play with your code (Note you have to un-pause to goback to the title screen) |
| ||
I like the adaptation and the direction this is moving. I think you're having issues because you're trying to set two different resolutions in your game. While this can work if it's done correctly, I would recommend only setting your Graphics once, and that's when you first start the program. Here's a little example of what I'm talking about. This is an example only, and will not execute unless you find an image to load (I haven't tested it). Keep in mind that all 2d commands will work the same way, whether Graphics3D is called or not. Graphcics3D 640,480 SetBuffer BackBuffer() ;this is where you would load the title screen Global titleimage = LoadImage("YouImageHere.bmp") While Not KeyDown(1) ;Run your program stuff here. When using Renderworld, I don't even think ;that you have to use the Cls command, as it's built in. RenderWorld() ;now, if you were to place all 2D drawing commands here... DrawImage titleimage,0,0 Text 15,15,"Some Random Text, blah blah..." ;...before using the Flip command Flip ;Everything that is 2D will draw on the screen, on top of whatever was rendered below it. ;This means that if you don't have any 3D objects or cameras, it will be ;nothing but a black screen with your 2D images appearing. It also means that you can ;run a camera and a demo world with your image appearing on top of it. Wend End If this doesn't quite make sense and you wish to change graphics modes throughout your program, then just remember to use "End Graphics" before calling your next "Graphics" command, otherwise Blitz will fail to set the new graphics. Keep in mind that this will cause the program screen to flicker and jump for a second or so (I think, haven't tried that either). Graphics 640,480 ;Run your whole title screen here EndGraphics Graphics3D 1440,900 ;Real resolution on my laptop, lol. ;Run your whole game here. I didn't quite read through dawlane's version, but it sounds like she was on to something. |
| ||
You can have a second graphics call but after each Graphics call, all graphics items (like loaded images, fonts etc.) are lost from what I've seen. It's generally easier just to stick with one graphics mode, but if you wan't to try this, make sure everything necessary is loaded after each Graphics call. |
| ||
I stand corrected. I've never actually tried to call graphics twice in the same program, so I wasn't entirely sure how Blitz would react. That brings up another question: What exactly is the purpose of the EndGraphics command? To free up memory, or something? |
| ||
I stand corrected. I've never actually tried to call graphics twice in the same program, so I wasn't entirely sure how Blitz would react. That makes two of us. From what I can see the EndGraphics command returns Bliz3D back in to it's "TEXT" mode (400x300) and I use the term "TEXT" loosely as you can still use the 2D image commands etc. This is what Blitz3D defaults to if you don't use the and Graphics2D/3D command. Run the code bellow to see what I mean and then uncomment the Graphics and EndGraphics command. ; End Graphics Example ; Enter graphics mode ;Graphics 800,600,16 ; Print hello 10 times on the graphic screen For t = 1 To 10 Print "Hello" Next Print Print "Height = " + GraphicsHeight() Print "Width = " + GraphicsWidth() Print "Depth = " + GraphicsDepth() Plot 50,50 ; Wait for a left mouse button While Not MouseHit(1) Wend ; End the graphics mode ;EndGraphics ; Print again, this time to the text screen For t = 1 To 10 Print "There" Next Print Print "Height = " + GraphicsHeight() Print "Width = " + GraphicsWidth() Print "Depth = " + GraphicsDepth() WaitKey() |
| ||
I think that along with returning Blitz to its original state, it might do a similar thing to different Graphics calls and clear memory associated with 'graphics objects'. Don't take my word for it though, I'm not too sure about the internal things that happen here. |