Results 1 to 10 of 87

Thread: Space Shooter Game Editor

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Space Shooter Game Editor

    Hello Everyone ,

    I'm in the process of creating a map editor, but ran into a problem, I'm using tiles 32x32 , my widht is fixed 20x32 (640) , but I can dynamicaly set the length, if I generate say a map that is 1500x32 tiles long that , my editor slows down to a crawl, probably because I'm rendering all the sprites at once, not just the ones visible . How can I render only the visible sprites?

    Attached I have here my entire project. Still lots of stuff to do but I think I'm progressing nicely. Anyway try to generate a map that is say 150 in length, you'll see the FPS drops drasticaly...
    Can someone please help me with this? Only draw what is actually visible.

    Greetings
    Robert
    Attached Files Attached Files

  2. #2
    Unfrtunately I havent been able to compile your project as I don't have all components so I can't offer you exact code changes: But becouse I was doing something similar once I can still give you some hints:

    1. Instead of creating all 1500x32 sprites create just as many sprites as it fits your window. Then you are only changing the sprites texture (Image).
    For instacne you define your map the same way as you do using:
    Code:
    TMap: array of array of Integer;
    Then you define multidimensional array of sprites:
    Code:
    TSprites: array of array of TSprite;
    And then when you move your map you just check which texture should be used for which Sprite like so:
    Code:
    Sprites[X,Y].Texture := Map[X+Left,Y+Top];
    2. Decrease the number of redraws as much as posible. Since you are making a map editor you probably don't even need 30 FPS. So increase the timers interval. Or even better if you are only using static Sprites (no animations) you can forget about constant redraws and actually fire redraws only when there has been any change. This can especially come useful when you are forced to render lots of Sprites (zoomed out view of your map for instance).

    NOTE: All the code examples are purely out of my head so there is great posibility that they have syntax problems in them.

  3. #3
    THANK YOU VERY VERY MUCH!!! I did it, after spending my day here in front of the computer, checkin DraculLin-s Diablo demo, and your advice, I did it. I'm using a 2d map array to store my map, and using a second array of sprites that is
    only as much as needed to fill my rendering surface 640x480 that is 20x15 of 32x32 tiles .

    I'm attaching the code for review, please note the Layer buttons don't do anything at all...neither does the delete... a few of them edits are for debuging .... gona clean up the code, and read layers, then I'll play with using Sprites on this map
    that actualy have animation , like water , lava ... or grass that moves....

    Greetings
    Robert

    ps.: if you try it, please post FPS , on my machine it has 1100 FPS , Core 2 Duo 7500 , Geforce 250GTS , wonder what it does on slower rig....
    Attached Files Attached Files
    Last edited by robert83; 29-12-2012 at 03:39 PM.

  4. #4
    On my laptop (Acer Aspire 6530G with AMD Turion X2 Dual Core 2.0 GHz, ATI Mobility Radeon HD 3650 512 MB VRAM) and Windows 7 I'm getting between 310 and 320 FPS when idle and between 280 and 290 FPS if I do lots of mouse movments which cause selection sprite to move to other tiles.
    The performance isn't affected by the size of the map so you did it.

    BTW you can use any visual component as Aspyhre renderning target. So you don't actually need to create a new form for renderning area but simply use TPanel component for instance. Offcourse having dedicated form is advised if you are making FullScreen mode game to gain aditional performance.
    The reason why I'm telling you this is becouse currently when I launch your program both form sizes exceed the size of my screen so I can't see whole program of yours.

  5. #5
    Thank you very much for the reply. Wow that is great, but how do I do that ? How do I specify AsphyreDevice1 rendring target? I've tried after ApshyreDevice1.Initialize; to add this , AsphyreDevice1.Create(Panel1); but nothing happens...

    Greetings
    Robert

  6. #6
    To be honest I don't know exactly as newest version of Asphyre had some changes in it. But based on the dfm file of your main form AsphyreDevice1 component which has been placed on your MainForm has property WindowHandle which is currently set to 0.
    I belive that changing this property to Panel.Handle should set Panel as rendering target for Asphyre but I'm not sure. You need to change this property prior the Initialization of the engine.

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
  •