Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Frame Rate Droppage

  1. #1

    Frame Rate Droppage

    I'm writing a 2d asteroids clone. Nothing fancy, its the first game I actually plan on finishing. I'm not using TSprites just the DXImageList.Draw functions at the moment. Picture this, I have an asteroid, an explosion and a ship, wizzing about 60 fps no problems. However when I add the "Laser Beam" (I feel like Dr. Evil now) or the "Shields" my framerate drops (to about 55 with the laser beam and about 30 with the shields). These are both using DrawRotateAlpha's but if I change them to plain on DrawRotate's I get the same frame droppage.

    I've listed out the on screen items below, what functions I'm using to draw them and their sizes. If anyone could shed some light on the situation I'd be very gratefull.

    Asteroid: DrawRotate
    64x64, 4096bytes

    Explosion: Draw
    194x129 Image (6 64x64 frames), 25284bytes

    Ship: DrawRotate
    64 x 192 (3 64x64 frames), 12288 bytes

    EnergyBar Outline: Draw
    21 x 176, 4224 bytes

    EnergyBar: StretchDraw (stretch height from 1 to 176)
    21 x 176, 4224 bytes

    Laser: DrawRotateAlpha
    5 x 192, 1536bytes

    Shields: DrawRotateAlpha (this is drawn over the SHIP)
    96 x 96, 9216 bytes





  2. #2

    Frame Rate Droppage

    It could be a number of things. But without seeing the code, I can't really say for sure what it is. I'm guessing, the problem is in your drawing routine. Perhaps you are doing something like this?

    Code:
    if (key = vk_space) then dxdraw1.surface.draw(x,y, yourBeam... etc)
    This will effectively draw a beam (or the shield for that matter) over and over again, while you are pressing the spacebar. This is of course not what you want, because you may end up with 10 beams instead of just 1.

    Instead try this:
    Code:
    if (key = vk_space) and (shooting = false)  then shooting := true;
    
    //then in your drawing procedure draw the beam
    if (shooting) then dxdraw1.surface.draw(x,y, yourBeam... etc)
    Of course you should set shooting to false at some point again.

    But, like I said, I''m only guessing here, perhaps your problem is of a very different nature.

    Btw, I noticed you are using stretchdraw to display the energybar. I'm not sure how you have done it, but I imagine it may look a bit weird (unless it's made of just one color).
    Perhaps you might be interested in this way....

    Code:
    Form1.DXDraw1.surface.Draw(10,30,rect(0,0,decreaseThisValueForTheEffect, 20),energybar,false);
    Anway, I hope it helped a bit.

  3. #3

    Frame Rate Droppage

    It's already working pretty close to the way you suggested. My ship "Object" has a "laser" property. In the drawing section I'm checking this variable and drawing the laser if need be. It's nice to know I'm on the right lines with *something* at least.

    Things are just getting wierder however.
    I discovered the slow down at work when I was doing a little after hours games programming. My pc at work is a celeron running at 1.5Mhz I think. Strange thing is, when I take this program home and run it here on my Athlon xp+ (running at 1.7Mhz, and this pc has a much better Graphics card) it runs like a dog, putting out 30 frames per second even if I don't touch the controls.

    The code ain't real easy to read, I'm a bit too ashamed to post it here (ops , I've decided to got back to the drawing board, do a few tutorials from here and there and see if I notice any glaring mistakes in my code that way.

    As a side note, I've noticed that you don't use the DelphiX animation and do it yourself. Any reason behind this, have you found it to slow?

    Cheers for the help

    P.s. regarding the energy bar (it's a yellow to red gradient from top to bottom), seeing as it was more informative than anything else and I couldn't be bothered working out how to take a piece of my graphic so I went for the stretch option. It's looks pretty funky luckily enough but I was wondering how to take a chunk of a graphic so that code snippit definately helps.

  4. #4

    Frame Rate Droppage

    It couldn't be because I'm using Bitmaps instead of Dibs could it?

  5. #5

    Frame Rate Droppage

    You aren't using the Canvas anywhere are you? I made that fault in the past as well, for drawing my text. Only a few months after giving up on the project because the framerate was to low, I found out that using the Canvas and after you are done Canvas.Release, takes a real bite out of your framerate. So that might be your problem...

  6. #6

    Frame Rate Droppage

    I am using the canvas but only with a few TextOuts. You know, framerate and a few other variables. I gave it a go and commented it all out but I still got the lag.

    I didn't have any problems when I was using 640x480 and 32x32 sprites but I recently upped it to 1024x768 and 64x64 sprites (which are all 255 colours). I'm just presuming that other people have wrote games working with this res and this size sprites without the whole thing coming to a standstill? I mean theres only 4 or 5 images being drawn on the screen, whats gonna happan when that number goes to 10 or 20+

  7. #7

    Frame Rate Droppage

    DrawRotate and DrawRotateAlpha using software acceleration.
    You can try:
    set propety editor-doSystemMemory=True

  8. #8

    Frame Rate Droppage

    DelphiX -IS- outdated. If you want high resolutions, lots of pixels and blinding graphics, dump it. You are WAY better of using a 3D engine (which uses DX3D/OpenGL, I don't care) which can use hardware acceleration. DelphiX hardly uses any hardware, so using a screensize of approx 2.5 times your old resolution, also slows your program down 2.5 times.

    Oh, and what is VSync set to? For best speed you'd like it to be Off (DXDraw.Options I think it is?)...

  9. #9

    Frame Rate Droppage

    doSystemMemory didn't make much difference at all. But thanks for the effort.

    I changed DXDraw.doWaitVBlank (it was the nearest thing I could find) and hey presto straight back up to 60fps. So that is all fantastic., if anyone could explain what thats all about that would be great.

    I can accept that DelphiX is outdated, but it's so darn easy to use. I'm do this as a hobby not a career so something that lets me produce poor-ish results sooner, rather than fantastic results after a huge steep learning curve is going to be a winner for me. Don't get me wrong, using the Delphi SDL libraries is on my todo list, but game code using those libraries looks exactly like C++ code, just in Pascal whereas DelphiX code looks like a delphi app.

    Surely your not telling me that there is no way of creating high resolution games with prerendered sprites without resorting to 3D? What about games like Diablo?

    Anywayz, thanks alot for your help, I really appreciate it. Now you've sorted my problem out and I can get back to having fun, and if you can point me at some good non-delphiX tutorials (maybe some with a little 2D in there to keep me sweet) I'll be sure to have a go.

    Cheers

    BK

  10. #10

    Frame Rate Droppage

    I disagree, you are definitely NOT better of with a 3D engine!
    Surely it may look all nice and fancy, but when I see people asking questions about how to draw a rectangle on the screen (no offence intended) do you really think they can handle a 3D engine?

    DelphiX may be outdated yes, but so is my geforce 2! And even I still use both every now and then.
    True, it may not be the fastest lib in the world, but it sure is a great way to learn the basics. And ok, it won't do all the cool fx you see in your 3D engine, but you could also ask yourself the question if it's really needed? Command & Conquer didn't use them either you know!

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •