More Speed in Game - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html) +--- Thread: More Speed in Game (/thread-1470.html) |
More Speed in Game - Aaron - 07-13-2003 I'm working on a top down scroller and am having problems getting enough speed out of it. Currently my code is something like this: (pseudo-code) Do Get Input Update Positions of everything Update graphics Send Graphics to Screen Loop So, what I want to do is to only update the graphics everyonce in awhile, and only when I want to send them to the screen, while still having the code for getting the input and updating the postitions of everything run in the background. In addition, I want to limit the speed of the updating and such because I am afraid when the graphics portions are only done when needed, the rest of the code will run too fast. Basically, what I am wondering, is if anyone has any suggestions for me. (BTW, I'm not using any libraries or assembly, so any suggestions would be greatly appreciated. I would post my code, but right now, it is in fairly early stages, and quite long and uncommented. It is no where near finished, but I still want to try to do what I'm suggesting while it is still early in the process of being coded) : - Agamemnus - 07-13-2003 1) have key/mouse input constantly update. 2) have logic and graphics update either separately or together. (together is best..) Sometimes it's best for some graphics-intensive stuff to update BLA times less than logic with a counter... Code: dim shared counter(1 to 10) as integer More Speed in Game - relsoft - 07-14-2003 SETVIDEOSEG. ;*) More Speed in Game - Aaron - 07-15-2003 ok, so I read the faq on setvideoset, and I don't understand it exactly. when you change the video segment, do you just write to you memory segment and then have it appear on the screen? or do you write to the memory after you have changed the video segment, and if so, what good does that do? wouldn't there still be flicker? Right now, I'm just writing to a buffer, that has previously been defined as an array, and then just PUTting it onto the screen. Will the whole SetVideoSeg work alot better than that, and if so, how? Thanks for your help More Speed in Game - na_th_an - 07-15-2003 It works exactly in the same way that your buffer does, but you can also use QB's drawing functions. You just change the video segment (just like in SCREEN 7 and similar you set a non visible page as active), you draw, you set the video segment again to &HA000, then you copy your buffer to screen,. General explanation here: http://faq.qbasicnews.com/?blast=DoubleBufferingConcepts More Speed in Game - relsoft - 07-15-2003 And way faster the POKEing each pixel. ;*) here: http://forum.qbasicnews.com/viewtopic.php?t=3165 More Speed in Game - Aaron - 07-16-2003 ok, this is the routine I'm currently using to write to my buffer: Code: SUB fastput (x%, y%, filename$) will it be much faster to use setvideoseg and then use the native qbasic functions? and if so, how much faster? thank you guys for all your help also, my buffer is already put compatible and all that, should I use put to transfer it to the active memory page? More Speed in Game - relsoft - 07-16-2003 Yes, much faster. Try to read the example scroller to see how to use it. ;*) Also Pre-Clipping your sprite dimensions would be faster than an F then inside your X loop. |