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.

Newcomers DBPro Corner / Screen vibrates

Author
Message
Prophet Hill
15
Years of Service
User Offline
Joined: 5th Feb 2009
Location:
Posted: 26th Feb 2009 01:18
Hi all, I'm attempting to create a FPS in DBPro. I'm having trouble with this certain aspect of my game.

I want to display the amount of ammo I have left in my gun. I have the [full/dec/reload] working properly but I can't get the text to show up on screen. The text only shows up for a split second then disappears. If I put my code in the main loop the screen vibrates/shakes but you can see the text. The same applies the the [print screen fps()]



Thanks for your time!

ProphetHill
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 26th Feb 2009 13:36 Edited at: 26th Feb 2009 13:38
use the text command, not the print command

E.g text 0,0, str$(screen fps())

You have to use str$() with the text command to convert variables to strings.

You also only want the sync command once, usually at the bottom of the main loop.

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 26th Feb 2009 16:07 Edited at: 26th Feb 2009 16:09
You should not completely disregard the print command. I think you will get a better understanding if know why your camera shakes.

Use "set cursor 0,0" somewhere in your main loop. Whenever you use print command the cursor automatically starts next time round on the next line down, on the far left side. If you use set cursor command prior to a print command, text will appear at coords given. You need to use set cursor at least once if you use print command in a loop, otherwise the cursor ends up offscreen which is what you are seeing when the camera shakes.

The thing with text command is that you have to set the coords each time no matter what. Sometimes I just want to bring values to screen as its quicker than debugging so I`ll call set cursor once in the main loop and print the values in a column on the left. It has its uses.

For FPS you only need a string conversion if you choose to use the text command, if you use print command you can just print the value to screen as the variable is numerical. In your case you wish to draw two numerical values to screen. For this I would use the print command. Drawing any text to screen can be slow(depends on what else the prog does) using DBP commands, so I would think that the string conversion would add to this time, in this case unnecassarily. I too would remove the sync from this nested loop, and place it in the main loop, but only to ensure it only ever gets called once per main loop and that its at the end of the loop. I would guess that if your Ammoview routine is the last in the mainloop to get called, then leaving sync where it is now might be ok - I would still put it in main loop though;
Prophet Hill
15
Years of Service
User Offline
Joined: 5th Feb 2009
Location:
Posted: 26th Feb 2009 17:37
Thanks guys! I got it working!

Also, for any other beginner who reads this: I had the "sync" command in several subroutines, which was lowering my FPS to about 22. with that command place in my main loop only, I know get 65ish.

Thanks for your help!

ProphetHill

Login to post a reply

Server time is: 2024-11-25 10:30:10
Your offset time is: 2024-11-25 10:30:10