iNET Interactive - Online Advertising Agency
          
Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > FPS with bitblt


Reply
 
Thread Tools Display Modes
  #1  
Old 02-18-2004, 02:53 AM
mathewmunro mathewmunro is offline
Regular
 
Join Date: Nov 2003
Posts: 71
Default FPS with bitblt

Any good way of getting the fps while using the bitblt
Reply With Quote
  #2  
Old 02-18-2004, 03:31 AM
Squalion Squalion is offline
Regular
 
Join Date: Sep 2003
Location: Manchester, England
Posts: 69
Default

How are you drawing frames? With a timer I presume?

in that case just have a variable say Frames and add to it every frame, and have another timer displaying it.

Code:
Dim Frames as Integer Private Sub Gameloop_Timer 'set to whatever fps you want 'code Frames = Frames + 1 End Sub Private Sub Frame_Timer 'set to 1000ms lblFramesPerSecond.Caption = Frames Frames = 0 End Sub

If you wanted a more accurate timer you could use a high-resolution windows or CPU timer...but I doubt that's necessary in anything less than a proper dev environment when you're testing optimizations or something.
__________________
Currently working on:
Gdi32
Reply With Quote
  #3  
Old 02-18-2004, 04:17 AM
mathewmunro mathewmunro is offline
Regular
 
Join Date: Nov 2003
Posts: 71
Default

Ok i did the fps, but i was using a loop for drawing and moving objects, but i got only 10fps

my computer is a XP2500 512mb and a geforce fx 256mb
is this right?
Reply With Quote
  #4  
Old 02-18-2004, 04:18 AM
Spodi's Avatar
Spodi Spodi is offline
Junior Contributor
 
Join Date: Oct 2003
Location: Washington, USA
Posts: 201
Default

It depends on how much you are drawing and how effecient your coding is. From what I know about your project, cant really say.
__________________
vbGORE :: Opensource Online RPG Engine
Reply With Quote
  #5  
Old 02-18-2004, 04:26 AM
mathewmunro mathewmunro is offline
Regular
 
Join Date: Nov 2003
Posts: 71
Default

is there a more effiecent way of refreshing the screeen, instead of just typing refresh?
Reply With Quote
  #6  
Old 02-18-2004, 04:42 AM
Squalion Squalion is offline
Regular
 
Join Date: Sep 2003
Location: Manchester, England
Posts: 69
Default

So you have a never ending loop that just refreshes the form?

that sounds like a bad idea, but even with inefficient code, 10 fps sounds a bit low, for that spec.

Do a game loop that's regulated by a timer, and manually blit to the screen, don't use something like Refresh.

Your code might work now but if you use a proper method (backbuffer, blit to screen) you should technically be able to get loads of frames per second, and it'll be much easier to implement new features.

could you post/attach some code?
__________________
Currently working on:
Gdi32
Reply With Quote
  #7  
Old 02-18-2004, 04:43 AM
mathewmunro mathewmunro is offline
Regular
 
Join Date: Nov 2003
Posts: 71
Default

here it is
Attached Files
File Type: zip RTS.zip (37.7 KB, 22 views)
Reply With Quote
  #8  
Old 02-18-2004, 04:53 AM
Squalion Squalion is offline
Regular
 
Join Date: Sep 2003
Location: Manchester, England
Posts: 69
Default

ok, had a look.

First of all, you need a proper game loop. Having your game loop in form_load with just a Refresh command isn't good. It'll work, but it wont really work if you want to do more things.

Secondly I think the poor FPS is due to bitblt'ing 87000 tiles, lol. Why do you need so many?
__________________
Currently working on:
Gdi32
Reply With Quote
  #9  
Old 02-18-2004, 05:06 AM
mathewmunro mathewmunro is offline
Regular
 
Join Date: Nov 2003
Posts: 71
Default

its a rts game, and it only paints the tiles that r on the screeen,(that can be seen), i am using lots of tiles because of u can scroll around the map, if u move ur mouse to the edges u can scroll.
Reply With Quote
  #10  
Old 02-18-2004, 05:39 AM
Squalion Squalion is offline
Regular
 
Join Date: Sep 2003
Location: Manchester, England
Posts: 69
Default

ok, well I don't have time to check the drawing code but 87000 checks per frame is still excessive. You could do it an easier way that doesn't need to check all of the tiles, by just drawing a tile(x) where x is inside the screen...if you get my drift.
__________________
Currently working on:
Gdi32
Reply With Quote
  #11  
Old 02-18-2004, 07:43 AM
mathewmunro mathewmunro is offline
Regular
 
Join Date: Nov 2003
Posts: 71
Default

i cant understand y its so slow its only painting wats on the screen, which is 768 tiles i think, when i did this b4 when i only have 768 tiles for the array i got 60 fps, then i declare 76800 (100 times bigger for a bigger map) it goes really slow but its still only painting 768 sqaures at most.

- updated project
Attached Files
File Type: zip Tank Wars.zip (14.3 KB, 5 views)
Reply With Quote
  #12  
Old 02-18-2004, 08:33 AM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss
* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 2,742
Default

Quote:
Originally Posted by mathewmunro
i cant understand y its so slow its only painting wats on the screen, which is 768 tiles i think, when i did this b4 when i only have 768 tiles for the array i got 60 fps, then i declare 76800 (100 times bigger for a bigger map) it goes really slow but its still only painting 768 sqaures at most.

- updated project



I believe its because all your tiles wont fit into video memory at the same time - How much memory do these tiles take up?

NumTiles*XRes*YRes*4bytes per pixel is a close enough estimation
Reply With Quote
  #13  
Old 02-18-2004, 10:37 AM
RedKnight's Avatar
RedKnight RedKnight is offline
Regular
 
Join Date: Dec 2003
Location: Golden, Co
Posts: 70
Default

i looked at the code and i cant find out whats wrong, but i have a idea for you to try.
increase the size of the tiles 64-64 (i get the most fps when its about that big - dont go any bigger or you will start to lose fps) and cut the number of tiles you have (i think it was 76816 tiles) in half.

i really dont see why you need so many tiles- thats 1229056 pixels to the right and down!!!

here is a class i made when i was reading Visual Basic Programming with DIRECTX, theres two of them one for WIn API and the Other for DD7, you cant really use the class becuase it requries the classes that came with the book, but im sure you can convert the API one very easily so you can use it im just givin it to you becuase you may wont to look at the way i made the map scroll add the clip formula too. just to warn you the API Map Class is the first one i maded and its very missy coding to.

if you have Q's about it please just email me ill be glad to help

P.S>
also about the clsMApAPI i was doing a test for anim Tiles (like the ocean moving etc.)it doesnt work right.
Attached Files
File Type: zip clsMapAPI.zip (2.6 KB, 8 views)
File Type: zip clsMapDD7.zip (1.5 KB, 8 views)
Reply With Quote
  #14  
Old 02-18-2004, 10:45 AM
SpeedPear SpeedPear is offline
Regular
 
Join Date: Jan 2004
Posts: 103
Default

I've made games with out a single control. You don't need timers to make a game, but instead use gettickcount or other hi-res timers.
__________________
SpeedPear
Enter the pear
----------------------------------
Aeon Nexus Games
Reply With Quote
  #15  
Old 02-18-2004, 11:49 AM
mathewmunro mathewmunro is offline
Regular
 
Join Date: Nov 2003
Posts: 71
Default

ive actually sorted it out now i get 300 fps, with that really big no for the tiles,


instead of doing
for n = 1 to 76187
if statement see if its on the screeen the paint it if not dont cos u cant see it anyways
bitblt ..
end if
next n

(this searches every single tile) reason y its so slow

this way its a bit tricky with numbers but i got it in the end, i cant explain (cosreally difficult to) but it gets the 1st tile that can be seen (top left corner) and i get the index of this and call it x1, and then i add the total no of tiles across the screen(wat i can see) then i call this x2

then i get y1, (y1 = x1)

and y2 = y1 + 311, (311 is total across the whole map)

then with these u can do a for n loop to just for the squares that u can see, it will miss the others out becuase they are b4 x1 and after x2 and same with y1 and y2. this stops me from having to check all 76187 tiles


have alook for urself, i will post the project. (btw the fps is lower cos i added a for n = 1 to 1000000:next n to slow it down a bit)

oh and btw thx for ur help guys, now i need to add tanks , biuldings and a AI, lot of work!
Attached Files
File Type: zip Tank Wars.zip (14.4 KB, 6 views)
Reply With Quote
  #16  
Old 02-18-2004, 12:11 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion
Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: South Carolina, USA
Posts: 15,985
Default

Perhaps you want to look at timeGetTime for your game loop, because using a timer and game loop is not good... and using a For loop as a frame limiter is also not good.
Ex:
If timeGetTime >= LastTick + MsDelay Then
LastTick = timeGetTime
'move game loop code here
End If
so if MsDelay is 1000 and you declare Public LastTick As Long, then you can move the timer code into this loop to get the FPS.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is up!
Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #17  
Old 02-18-2004, 12:18 PM
mathewmunro mathewmunro is offline
Regular
 
Join Date: Nov 2003
Posts: 71
Default

r msdelay and lasttick functions or just variables u used?
Reply With Quote
  #18  
Old 02-18-2004, 12:20 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion
Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: South Carolina, USA
Posts: 15,985
Default

r?
oh, nevermind.

timeGetTime API is the only function there...
LastTick is a variable (I said to declare it as Long)
and MsDelay-- you can just change that to 1000 directly.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is up!
Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #19  
Old 02-18-2004, 12:26 PM
mathewmunro mathewmunro is offline
Regular
 
Join Date: Nov 2003
Posts: 71
Default

i did it but now i get 2 fps, somet wrong, i post code, see wat i did wrong

Do

If GameOn = False Then
Unload Me
Exit Sub
End If

If timeGetTime >= LastTick + 1000 Then
LastTick = timeGetTime
ViewArea
PaintTiles
PaintMenu
CheckMousePos
MenuOver MX, MY
FPS = FPS + 1
Me.CurrentX = 0
Me.CurrentY = 0
Me.Print FPS

FPS = 0
DoEvents

End If
Loop
Reply With Quote
  #20  
Old 02-18-2004, 02:10 PM
Squalion Squalion is offline
Regular
 
Join Date: Sep 2003
Location: Manchester, England
Posts: 69
Default

That's what I meant about only drawing tiles on the screen

btw, if timeGetTime produces a time in milliseconds, than waiting until 1000 have elapsed = 1 second delay between frames. Try it on something lower.
__________________
Currently working on:
Gdi32
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How would i add a mask to this bit of coding? Giglimesh Game Programming 2 02-16-2004 07:16 AM
Menu / bitblt problem DeuxExeMachina Game Programming 5 01-09-2004 04:46 PM
BitBlt Tutorial Pino Tech Discussions 5 12-08-2003 03:02 PM
Bitblt animation?? SockBox Game Programming 5