Is my scrolling smooth? Help needed with timing
BlitzPlus Forums/BlitzPlus Programming/Is my scrolling smooth? Help needed with timing
| ||
Hi, I have written a scrolling routine and it runs beautifully on my PC, smooth as chocolate milkshake, and superfast too. But I sent to to my brother in another town and he says it’s jerky on his PC. He tested it on two PCs and it was jerky on both. They are both fast PCs, he plays lots of 3D games; this is only a 2D game. Download it here (compiled version also source code, all in a .zip) http://www.darenking.co.uk/scrolltest.html Even if you (ie all the people who read this) can’t offer any advice it’d be great if people could email me and tell if it runs smoothly or not as it is; if I find it runs fine on almost all PCs then I guess it doesn’t matter too much. I haven’t done anything clever with the timing, the game just goes through a main loop which draws the graphics on the screen then just does “flip” for the double buffering. Main loop looks like this, I’m sure that will give you an idea: While Not KeyHit(ESCAPE) functionInput() ; read the keyboard functionGamePlayerMove() ; use the keys to move the player intCameraPerfectX=intPlayerPerfectX ; update viewpoint intCameraPerfectY=intPlayerPerfectY ; update viewpoint functionGameDraw() ; draw the graphics Flip ; flip (double buffer) Wend You can email me here: daren@... |
| ||
In BlitzBasic (BlitzPlus' predecessor), if your game takes the following format, your game should run "as desired" on all PCs: timer=CreateTimer(30) ;create a game timer While game_on ;while game is in progress... frames=WaitTimer(timer) ;how many times should we update? For k=1 To frames ;do the updates... UpdateGame() Next Cls ;standard double buffered drawing... RenderGame() Flip Wend (Taken from BlitzBasic's in-built Programmers' Guide) However, I don't think this will work in BlitzPlus as I think the above Timer functions have been removed from the command set. I may be wrong, so give it a try anyway. Ryan |
| ||
Smooth Scrolling:AutoSuspend 1 CreateTimer(60) ; Limit to 60 FPS Repeat Select WaitEvent() Case $4001 ; Timer Tick Cls ; Do all rendering here VWait 1: FlipCanvas Canvas, 0 ; VSYNC ON End Select Forever |
| ||
Thanks so much for this Eikon, but “FlipCanvas Canvas” just brings up an error, “Invalid Canvas Gadget handle”. Am I supposed to replace the word Canvas with a variable name of some sort, some kind of handle? I'm using BlitzPlus 1.39, and there doesn't seem to be a mention of anything called "FlipCanvas" in the manual! Grateful for any help, Daren King |
| ||
Hi King, Blitz+ takes advantage of a new event system and canvases. By looking at your code above, it seems like you're foregoing all of that and using it more like B2D/B3D. If you care to learn about using the GUI aspect of the language, you could start by learning the basic framework of a B+ window: Also note that if you wish to see the documentation for a command like "FlipCanvas", place your cursor on the command and hit F1 twice. This should take you straight to the command reference. |
| ||
Hi Eikon I don't know why it puts my name as King, my first name is Daren! But I don't mind being called King, it makes me sound important. Anyhow, thanks for taking time on this, you're taught me a lot, but I'm wondering if it is possible to make the window run fullscreen, with no border at all? I know you can click the square in the top right hand corner, and the window stretches to fill the screen, but it's still running in a window, with a sort of border round it, even if you turn off all the options! I have been reading the user manual and have since added the command: MaximizeWindow(Parent) but it still has the grey border around the edge! Really grateful if you can help. Have spent several months on my mapper program and will be rather gutted if I can't get this to work! Daren |
| ||
When you use the CreateWindow command, the last parameter is used to specify it's style 1 - The window has a title bar 2 - The window is resizable 4 - The window has a menu 8 - The window has a status bar 16 - The window is a 'tool' window 32 - The window shape is in 'client coordinates' e.g. 1 + 2 + 4 would give you a resizable window with a titlebar and menu. Style 16 is what you want, it makes the window borderless. Win = CreateWindow("Title", 0, 0, ClientWidth(Desktop()), ClientHeight(Desktop()), 0, 16)should do what you need |
| ||
King Daren, when you signed up on these forums you entered a nickname. =] |
| ||
Thanks, Toby! |
| ||
Hi Eikon, Thanks so much for your help! You seem to have solved my problem with the window, it now fills the screen. However, I wonder if you could take one final look at my altered version of your original program. Have I done things in the most efficient way? In other words, when I removed the borders and the menu, did I leave behind any fragments of the old version of the program? Do I still need both the “parent window” and the “canvas” now that I have removed the border and the sunken frame thing? The program now looks like this: ; Parent Window Parent = CreateWindow("B+ Window Framework by Eikon", 0, 0, ClientWidth(Desktop()), ClientHeight(Desktop()), 0, 0) ; Sunken Panel (nicer canvas look) Panel = CreatePanel(0, 0, 1600, 1200, Parent) ;NOTE I’M RUNNING IN 1600,1200 SetGadgetLayout Panel, 0, 0, 0, 0 ; Canvas Canvas = CreateCanvas(0, 0, 1600, 1200, Panel) ;NOTE I’M RUNNING IN 1600,1200 SetBuffer CanvasBuffer(Canvas) Local OX, OY ; Old MX, MY AutoSuspend 1 SeedRnd MilliSecs() CreateTimer 60 ; 60 FPS Repeat Select WaitEvent() Case $803: End ; X Out Case $1001 ; Menu Event If EventData() = cnt_EXIT Then End Case $4001 ; Tick MX = MouseX(Canvas): MY = MouseY(Canvas) If MX <> OX Or MY <> OY Then ; Mouse moved OX = MX: OY = MY Color Rand(0, 255), Rand(0, 255), Rand(0, 255) Rect MX, MY, Rand(5, 10), Rand(5, 10) EndIf VWait 1: FlipCanvas Canvas, 0 End Select Forever |