Page 8 of 9 FirstFirst ... 6789 LastLast
Results 71 to 80 of 87

Thread: Space Shooter Game Editor

  1. #71
    Quote Originally Posted by robert83 View Post
    1. I've tried it on multiple machines, and there is a strange thing (I'll try to explain) . The map scrolling even though it says 60FPS always , does not seem smooth... it feels like its going down at a variable speed (which is impossible since I'm moving it by 4 always....) Any ideas why?
    Why would it be imposible? If for some reason part of your code takes longer than the desired time between screen refreshes it will create slowdowns which might be seen as variating movment speed.

    Quote Originally Posted by robert83 View Post
    2. Also on one machine Amd Sempron 7100GS , it hangs at random places , the computer itself freezes completely... need to reboot. But on my computer, and another one ( I have a few of them, for them LanParty's) it goes without a problem. In fact yesterday I left it to run all night to see if I have a memory leak, or some other bug somewhere. I guess the 7100GS is overheating and that is why it hangs.... anyway if you could take a moment to look at my Scrollmap
    procedure to see if there is some potentialy dangerous code in there...that under certain circumstances might be problematic.
    Can't be sure why this is happening without even seing the code (currently at work). But there is stil posibility that the reason for theese freezes is in the Asphyre graphic engine itself.
    Have you tried running the demos which come with the graphic engine? If they work OK then there is either problem in your code or in code for SpriteEngine. Unfortunately tracking this kind of freezes which make your whole computer to freeze is quite hard.

    Quote Originally Posted by robert83 View Post
    3. A side-side question :
    I've got a Celeron 2000, GeForce 2GTS can only push out 30FPS max... , what is the culprit here ? My code ? Asphyre / SpriteEngine combo? I'm asking this because (and now I'm probably comparing apples to oranges) for example Tyrian 2000
    runs smoothly on ever lower specs... am I limited here by the programing language itself ? ( or by my knowledge to write fast code ) - I'm asking this because I always think it's my falt, but not 100% sure, I just want to make this 100% clear, so that I don't expect it to run as fast on older hardware ...when it's simply not possible ... (cause it uses some modern DirectX stuff that is even though my sprites themselves are not complex , it still taxes older generation gpu's more... )
    Greetings
    Robert
    GeForce 2GTS is rather old graphic card so there is posibility that it doesn't support some feature Asphyre graphic engine usualy uses and this forces the while graphic engine to go into compatibility mode where all the graphical processing is actualy made by CPU (software rendering).
    I'll check the Asphyre engine code to se if there is any way of telling this.


    In the mean time I recomend you download yourself Process Explorer http://technet.microsoft.com/en-us/s.../bb896653.aspx
    Process Explorer is neat litle program which alows you to monitor resource usage on your computer. It even alows you to monitor resource usage per program.
    So by using this program you can quickly see if your program is using lots of CPU time which might result in slowdowns. And if you have Windows Vista or newer you can also monitor GPU usage and even Graphical memory usage. Unfortunately this feature isnt available on Windows XP

    Anywhay I'll take a look at your code when I get home to see if there are any dangerous places.

  2. #72
    I've been playing around with the other demos, though they use differnt Apshyre version so it seems... but I've noticed that when they create the asphyre Timer they set FPS to some extreemely large value like 4000 in the SHOOTER demo, and 15.0 to speed. If I set that speed my editor scrolls by to fast. So I've tried to change around the timer, and noticed for example if I set it to MaxFPS 60, and Speed 1 , the chopiness is even more evident, wonder if it's because I can't figure out howto set them timers properly? (I've disabled vsync completely..)


    I think I've located the possible offiending line, I've changed the code when a new line of sprites is created I create always the selection_image :
    Code:
    BackGround[z,i,b].ImageName:='selection.image';
    and now I think it's smooth , but how to solve this?
    Code:
    BackGround[z,i,b].ImageName:= Images.Item[map.Layer[z].Lines[MapOffset-1,x].ImageIndex].Name;
    I think the problem is cause by the lookup of ImageName ... , I've looked trough the properties, but ImageIndex is something else , if I use ImageIndex := I get an error.... it would probably be fast if I could somehow specify ImageIndex instead of ImageName.

    UPDATE2 :

    Now that I look at it, there might be another problem , my Layer cycle, I think I'm not reading data optimaly first reading layer then line then tile, I think I'll need to modify it so tha I read line, then layer then tile . I think I'm wasting a lot of cycles here. Layer data for Line1, should be next to each other...currently it's Layer0 : line1,2,3,4... then Layer1 : line1,2,3,4... , now when I think about it , when the map array grows I'm jumping here and there inside it to get just one line of data... ( I did not start coding this yet...but I really hope this is my problem, and will magicaly solve my spead issue...if I fix this...)

    Code:
    for z:=0 to 3 do
      for y:=0 to 15 do
        for x:=0 to 19 do
           begin
           //code
           end;
    While I think by moving the Layer cycle inside I will cut my cycles down.

    Code:
    for y:=0 to 15 do
      for z:=0 to 3 do
        for x:=0 to 15 do
           begin
              // code here
           end;
    or maybe

    Code:
    for y:=0 to 15 do
      for x:=0 to 15 do
        for z:=0 to 3 do
          begin
           //code
          end
    I'll change my code the way I save it, and the way I load it...into file.

    Greetings
    Robert
    Last edited by robert83; 21-02-2013 at 05:06 PM.

  3. #73
    Quote Originally Posted by robert83 View Post
    I've been playing around with the other demos, though they use differnt Apshyre version so it seems... but I've noticed that when they create the asphyre Timer they set FPS to some extreemely large value like 4000 in the SHOOTER demo, and 15.0 to speed. If I set that speed my editor scrolls by to fast. So I've tried to change around the timer, and noticed for example if I set it to MaxFPS 60, and Speed 1 , the chopiness is even more evident, wonder if it's because I can't figure out howto set them timers properly? (I've disabled vsync completely..)
    If you take a look at the timer you wil see that it has two values:
    1. MaxPFS: Is used to control how many redraws can there be done in one second. This directly controls how often is OnTimer event being fired. You use OnTimer event to process code needed for rendering.
    2. Speed: Is used to control the speed of your game. This directly controls how often is OnProcess event being fired. You use this event to proces the code which ontrols map movment, units movment, some ingame simulations etc.

    The main problem in your case is that you only use OnTimer event to process everything while this one should only be used to process graphics. So go and move code which controll map movment into OnProcess event and there should be no more variation in map movment speed.


    Quote Originally Posted by robert83 View Post
    but how to solve this?
    Code:
    BackGround[z,i,b].ImageName:= Images.Item[map.Layer[z].Lines[MapOffset-1,x].ImageIndex].Name;
    After some checking I figred out that the problem is in the SpriteEngine itself as it is always searching for proper image from TAsphyreImages using ImageName. And since it is doing this for every redraw of every sprite it is probably afecting the overal performance a bit.

    I'm trying to modify code from SpriteEngine so that it would be posible to set proper image for certain Sprite by any other means than just by providing ImageName. But the way how Sprites are implemented right now is making it dificult to achive this.


    Quote Originally Posted by robert83 View Post
    I think the problem is cause by the lookup of ImageName ... , I've looked trough the properties, but ImageIndex is something else , if I use ImageIndex := I get an error.... it would probably be fast if I could somehow specify ImageIndex instead of ImageName.
    Yes ImageIndex is used for entirely different purpose. What ImageIndex does is that it adds number to the ImageName. So if you have several images named Grass1, Grass2, Grass3, and so on you can acces theese images by providing ImageName and then seting Image index. So ImageName 'Grass' and ImageIndex 5 would be the same as if you would set ImageName to 'Grass5'.
    I suspect that this was some old way for doing animations.
    And the error you get when changing ImageIndex is becouse SpriteEngine is trying to render image whose ImageName can't be found in TAsphyreImages. SpriteEngine has no safety mechanism for handling such situations when desired image isn't found.

    So I'll try to change TSprite class in a way so you would be able to directly pass TAsphyreImage to it. This can be quickly got by using AsphyreImages[ImageIndex].
    Also I'll try to add safety mechanism to prevent those nasty errors when desired image isn't found.
    But as sad before I have to figure out a way of how to implement this while still retaining old functionality so that my changes won't break any programs using this old ackward way.

  4. #74
    Quote Originally Posted by robert83 View Post
    Now that I look at it, there might be another problem , my Layer cycle, I think I'm not reading data optimaly first reading layer then line then tile, I think I'll need to modify it so tha I read line, then layer then tile . I think I'm wasting a lot of cycles here. Layer data for Line1, should be next to each other...currently it's Layer0 : line1,2,3,4... then Layer1 : line1,2,3,4... , now when I think about it , when the map array grows I'm jumping here and there inside it to get just one line of data... ( I did not start coding this yet...but I really hope this is my problem, and will magicaly solve my spead issue...if I fix this...)
    Changing the order of how for loops are nested won't save you any cycles as for loop sizes remains the same. It could only confuse you even more.
    Also if you decide to implement layers with different sizes of their grids you definitly need to process one layer after another and not jum from one layer to other since in that case the lines between different layers won't be on same positions.

  5. #75
    I don't remember where I've read, but I recall that some map editor tutorial in some other language did it like this :

    Process Lines
    Process Layers
    Process Tiles

    I've changed my code a bit accordingly. The problem still manifests itself on my other computer altought it's now rarer... now I get a bit of a slowdown ever 1-2 sec... instead of the constant variation...
    The system in question is a Core 2 Duo E3xxx , 9800GTX. My system runs it without hicups , its a bit better E7500...

    Even tough if I'm not saving cycles, I'm atleast getting data in a better order now no?

    I mean
    Layer0-Line1
    Layer1-Line1
    Layer3-Line1
    Layer0-Line2
    Layer1-Line2
    Layer2-Line2

    Instead of

    Layer0-Line1
    Layer0-Line2
    Layer1-Line1
    Layer1-Line2
    Layer2-Line1
    Layer2-Line2

    Right now it might not be the biggest performance hit, but later it might be no? I mean if the array is much larger.... it most jump here and there inside the array because the lines for the layers are not right next to each other. Or maybe there is no difference in speed ?

    Greetings
    Robert
    Attached Files Attached Files

  6. #76
    UPDATE: I managed to modify TSprite class so it now provides the ability to provide it with pointer ti TAsphyreImage it will use for rendering itself. So now you can easily call:
    Code:
    BackGround[z,i,b].SpriteImage:= Images.Item[map.Layer[z].Lines[MapOffset-1,x].ImageIndex];
    I have changed the TSprite class in a way so that if you assing some image to new SpriteImage property my changed code is used, but if you still just assign ImageName old code is used.
    This means that all old programs will still work.

    The only advantage of this old system is that it alows you to dynamicly load and unload seperate textures from AsphyreImages component becouse doing so can affect indexes of other textures. So accesing textures using indexes in such scenario is out of question.
    Anywhay I don't think you would need dynamic texture loading and unloading by yourself. But if you would there is still existng mechanizem to support this present.

    Here is updated AsphyreSprite.pas file:

    AsphyreSprite updated.zip
    Last edited by SilverWarior; 21-02-2013 at 08:26 PM.

  7. #77
    Quote Originally Posted by robert83 View Post
    I don't remember where I've read, but I recall that some map editor tutorial in some other language did it like this :

    Process Lines
    Process Layers
    Process Tiles
    Maybe this was necessary becouse of the overal map structure they used.


    Quote Originally Posted by robert83 View Post
    Even tough if I'm not saving cycles, I'm atleast getting data in a better order now no?
    This mostly depends on your original map structure and where do you nead certain data.


    Quote Originally Posted by robert83 View Post
    Right now it might not be the biggest performance hit, but later it might be no? I mean if the array is much larger.... it most jump here and there inside the array because the lines for the layers are not right next to each other. Or maybe there is no difference in speed ?
    When reading from multidimensional array which is stored in memory there isn't much difference. Even if you have to jump all ower the memory this would be barely noticable.
    But if you would have been reading this data from HDD jumping around would cause significant performance difference.

  8. #78
    Meanwhile I rewrote my code, to see what happens if I load entire map , which is only 7500 sprites not to much to handle on my lover end pc (e3xxx,9800GTX) . And I'm moving it down like this :
    Code:
          for y:=0 to 299 do
            for z:=0 to 3 do      
              for x:=0 to 19 do
                begin
                  if BackGround[z,x,y] <> nil then
                    begin
                      BackGround[z,x,y].Y:=BackGround[z,x,y].Y+ScrollSpeed;
                     { if BackGround[z,x,y].Y = 480 then
                        begin
                          BackGround[z,x,y].Dead;
                          BackGround[z,x,y]:=nil;
                        end;  }
                    end;
                end; // X loop
    The map if fixed length for this test.

    And behold... the problem is still there... on the other computer it has hickups... on new lines...I'm starting to wonder if my problem is this!

    if BackGround[z,x,y] <> nil .... this takes longer to compare then say if I used numbers instead , and would use the Map array to see if there is something to move or not....

    if map.Layer[0].Lines[y+MapOffset,x].ImageIndex <> 0 then

    UPDATE : rewrote the code that moves everything like this :
    Code:
      if MapOffset > 0 then
        begin
          LineHeight:=LineHeight+ScrollSpeed;
    // Background : Layers [0..3], Tiles [0..19], Lines [0..15] of TBackGround;
    // Map.Record : Layers [0..3], Lines [0..Map.Length-1] , Tiles [0..19]
          // move available sprites down
          for y:=0 to 299 do
            for z:=0 to 3 do
              for x:=0 to 19 do
                begin
                  if Map.Layer[z].Lines[y,x].ImageIndex <> 0 then
                    begin
                      BackGround[z,x,y].Y:=BackGround[z,x,y].Y+ScrollSpeed;
                    end;
                end; // X loop
          // screen scrolled down one line
          if LineHeight = 32 then
            begin
              Dec(MapOffset,1);
              LineHeight:=0;
            end;
        end // if Offset
      else
        begin
          // Start again
          RanOnce:=false;
        end;
    Same effect... I'm right now in the process of making it full screen, load this map automagically in full screen start scrolling and see what happens...without any components on the form

    Update 3:

    I've removed everything from my code, it is fullscreen, just loads the map file and scrolls trough it... it's not creating sprites or anything, it just creates them once and then moves them down...and still it sometimes is choppy on the other computer

    Attached the code and source, note if you do want to start it, make sure the map file is on c:\ , if you press ESC during the scroll it will go back to windows.

    Greetings
    Robert
    Attached Files Attached Files
    Last edited by robert83; 22-02-2013 at 03:01 PM.

  9. #79
    Code:
    BackGround[z,x,y].Y
    Your graphics consist of continuous tiles right? So why does each tile have its own X, Y variable? They have their array position already, that tells exactly where they are at on game screen. IE x*TileWidth, y*TileHeight or something.

    So code like this would be unnecessary:
    Code:
                        if BackGround[z,x,y].Y = 480 then
                        begin
                          BackGround[z,x,y].Dead;
                          BackGround[z,x,y]:=nil;
                        end;

  10. #80
    @robert83
    Recheck my posts. In one of my previous posts I wrote about how to correctly use TAsphyreTimer.
    The problem is that you are only using one of TAsphyreTimer events to do both rendering and map movment which means that overal CPU usage on some slow machine would greatly affect the smothnes of scrolling and great FPS variations. Also doing so prevents you to controll your MaxFPS and your game speed correctly.

Page 8 of 9 FirstFirst ... 6789 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
  •