Results 1 to 9 of 9

Thread: DelphiX Timer FPS

  1. #1

    DelphiX Timer FPS

    Hi

    I've got a problem, I am programming a game with delphiX based on the tutorial "How to create a platform game" by Alexander Rosendal.

    I finished the tutorial and started expanding and adding stuff. But now it seems that the frame rate of the DelphiX timer is constantly under 60. I only draw graphics that are on the screen and there are so far no more than the player and 7 NPCs on the screen to draw. However, I did notice that when I dont draw any NPCs, the frame rate stays at 60.

    Also, I am creating the game on a PC with 4GB RAM, Corei3 processor, 1GB graphics RAM. But when I run it on a slower PC wih 2GB RAM, Celeron processor, 500MB graphics RAM, it runs so slow it's unplayable. Why is this? I mean it isn't a a game with good graphics and there isn't much elements to draw on screen.

    Is there any way I can improve performance? Perhaps it's my code? I am new to game programming so any help with this matter will be appreciated. I can provide code from the game if you wish...
    IF YOU'VE FAILED TO TAKE OVER THE WORLD, CREATE A GAME WHERE YOU CAN.

  2. #2
    What DelphiX version? Are you using the latest UnDelphiX that's properly hardware accelerated (actually using the graphics card, not drawing with CPU)? Other thing is that there are some more modern game engines for Pascal, you should look around some more And if you do give some source code of your game, we might spot possible reasons for slowdown.

  3. #3
    I have downloaded UnDelphiX yes, but for some reason I cannot get it to work. It installs the package after I edited some of the code (it gives errors if I dont). But onve I drop certain components on the form, it give me AV errors. Also I saw that in UnDelphiX there is a new function that has to be used when drawing. Cant exactly remember it now but will name it with my next post.

    Also my game does compile with UnDelphiX after a few modifications, but once compiled, I'm staring at a black screen.

    I have also considered using Asphyre Sphinx, but I use Delphi 7 wich isn't compatible with Asphyre Sphinx. I have searched the NET for other engines, but most I find has little or no documentation... Which is important as I am new to game programming and need an introduction of some sort of the engine...
    IF YOU'VE FAILED TO TAKE OVER THE WORLD, CREATE A GAME WHERE YOU CAN.

  4. #4

    New UnDelphiX Function

    The function I mentioned below is "DXDraw1.Beginscene" And "DXDraw1.Endscene". As I understand, you have to use these before and after drawing. I have tried this but to no avail. I'm still stuck at a black screen...
    Last edited by Proph3t; 07-10-2013 at 02:51 PM.
    IF YOU'VE FAILED TO TAKE OVER THE WORLD, CREATE A GAME WHERE YOU CAN.

  5. #5

    Game Source

    Complete Source code for the game is attached. I'm not good with drawing, so excuse the crude graphics











    Legions of Doom Final.zip
    IF YOU'VE FAILED TO TAKE OVER THE WORLD, CREATE A GAME WHERE YOU CAN.

  6. #6
    Since I haven't been able to compile your game (missing wave.dcu) I cant pinpoint what exactly is the cause of slowdowns.
    Also since it is some time since I used DelphiX I might be way off but I don't think calling
    "Player.SpriteImage.LoadFromGraphic( Form1.PlayerGfx.Items.Items[Player.CurrentFrame].Picture.Graphic );"
    is a good idea for changing player animation. Doesn't that reloads SpriteImage from memory to GraphicMemory?
    The worst thing is that you are doing this constantly even if the Player frames wasn't changed.

    BTW! Doesn't DelphiX offer a different way for sprite animations where you only change sprite animation position and don't need to reload it's graphic every time?

  7. #7
    Well SilverWarrior, thank you for the info! I will look into this. I am new to game programming and that game is my first.

    Wave.dcu is included with DelphiX I think, if you want I could attach it with a future post? I also thought that something with that code seemed wrong but couldnt lay my finger on it. I got that code from a tutorial on which I am expanding.

    If you could perhaps give me an example of how to use spriteimages differently than I currently am, I will be grateful. In the meantime I will see if I cant figure this out on my own.

    Many thanks for the help

    EDIT: I have found the following proprties that DelphiX provides: AnimCount, AnimLooped, AnimPos, AnimSpeed, AnimStart.

    Those must be what you were referring to? Although what I cannot find is a different way of "loading" different frames. It doesnt seem like DelphiX has its own spriteimage property? Or maybe I'm just not looking I'll keep looking.

    EDIT2: Lol my bad, I found that the TImageSprite has a Image property which is a TPictureCollectionItem. Although, I cannot understand how it will be any different if I use the Image property? It still has to load images from a DXImagelist, doesnt it? Unless what you meant was that by using "Player.SpriteImage.LoadfromGraphic" It has to load the image into graphic memory, is this correct? Cause by using the Image property the code will look like this: "Player.Image := PlayerGfx.Items[0];".

    Then by using that method, how will I load the correct images once the player's frame has changed? This seems like it could work, I just need to figure out how to put it all together.

    EDIT3: Lol this is pretty funny. Tell me if I am correct:

    You use the Image property to specify where the player's Image is (In which DXImagelist I mean). Then by using the AnimCount property you specify the maximum frames for the player. With AnimStart you set the number for the corresponding start frame. By doing this it will load the images from the start point that you specified with AnimStart and keep loading untill it has reached AnimCount's value, then it will loop and repeat the process. Is this correct? AnimSpeed, AnimPos and AnimLooped is self-explanatory I believe.

    Then two more things. The ChangeFrame procedure. What did you mean when you said it still changes frames when the player frames havn't changed? Cause "Player.ChangeFrame(0)" is only called when the player is walking. When I use "Player.ChangeFrame(1)" it only changes the player's picture to "PlayerGfx.Items[1]", but it doesnt loop animation?

    And how will the "DXDraw1.Surface.Draw" procedure look? Cause it requires "SrcRect: TRect" and "Source: TDirectDrawSurface", which the "Player.Image" property doesnt have
    Last edited by Proph3t; 08-10-2013 at 10:59 AM.
    IF YOU'VE FAILED TO TAKE OVER THE WORLD, CREATE A GAME WHERE YOU CAN.

  8. #8
    Quote Originally Posted by Proph3t View Post
    Wave.dcu is included with DelphiX I think, if you want I could attach it with a future post?
    DelphiX comes with DXWave.pas. Now I don't know if it is the same as the Wave.dcu that you are using. Atach it the next post and I'll check it out.


    Quote Originally Posted by Proph3t View Post
    I also thought that something with that code seemed wrong but couldnt lay my finger on it. I got that code from a tutorial on which I am expanding.
    I know the tutorial which you are using. I have read it a while ago. At that time the provided code was fine but there was some changes made in UniDelphiX is the code should probably be updated a bit especially about "DXDraw1.Beginscene" And "DXDraw1.Endscene". which are used to group multiple draw cals. This should provide some performance increase and solve some graphical glitches that sometimes ocured in original DelphiX component set.


    Quote Originally Posted by Proph3t View Post
    I found that the TImageSprite has a Image property which is a TPictureCollectionItem. Although, I cannot understand how it will be any different if I use the Image property? It still has to load images from a DXImagelist, doesnt it? Unless what you meant was that by using "Player.SpriteImage.LoadfromGraphic" It has to load the image into graphic memory, is this correct? Cause by using the Image property the code will look like this: "Player.Image := PlayerGfx.Items[0];".
    As far as I know "Player.SpriteImage.LoadFromGraphic" is used for drawing Delphi specific Graphics like TBitmap. And yes those need to be loaded into graphical memory while all images from DXImage list should be loaded into Graphical memory on application start. I might be wrong on this. Please check the uniDelphiX documentation.


    Quote Originally Posted by Proph3t View Post
    Then by using that method, how will I load the correct images once the player's frame has changed? This seems like it could work, I just need to figure out how to put it all together.
    If my memory serves me corectly you use special Image for animation sprites (it combines all animation sprites in one image formed in horizontal line). Again please check the uniDelphiX documentation on this.


    Quote Originally Posted by Proph3t View Post
    You use the Image property to specify where the player's Image is (In which DXImagelist I mean). Then by using the AnimCount property you specify the maximum frames for the player. With AnimStart you set the number for the corresponding start frame. By doing this it will load the images from the start point that you specified with AnimStart and keep loading untill it has reached AnimCount's value, then it will loop and repeat the process. Is this correct? AnimSpeed, AnimPos and AnimLooped is self-explanatory I believe.
    I belive you are correct but to be sure I still recomend you check the UniDelphiX documentation.


    Quote Originally Posted by Proph3t View Post
    Then two more things. The ChangeFrame procedure. What did you mean when you said it still changes frames when the player frames havn't changed? Cause "Player.ChangeFrame(0)" is only called when the player is walking. When I use "Player.ChangeFrame(1)" it only changes the player's picture to "PlayerGfx.Items[1]", but it doesnt loop animation?
    Code for loading graphic is outside of the if clause that you use to check whether the players picture needs to be updated.


    Quote Originally Posted by Proph3t View Post
    And how will the "DXDraw1.Surface.Draw" procedure look? Cause it requires "SrcRect: TRect" and "Source: TDirectDrawSurface", which the "Player.Image" property doesnt have
    I'm not sure. Will have to check it out more thouraly myself.

  9. #9
    Quote Originally Posted by SilverWarior View Post
    DelphiX comes with DXWave.pas. Now I don't know if it is the same as the Wave.dcu that you are using. Atach it the next post and I'll check it out.
    Problem solved. That wave.dcu was from NewAC components. Just remove "wave" from the uses clause.

    I am currently going through a tutorial about animation with one horizontal image

    Thanks alot for the help!
    IF YOU'VE FAILED TO TAKE OVER THE WORLD, CREATE A GAME WHERE YOU CAN.

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
  •