Results 1 to 10 of 87

Thread: Space Shooter Game Editor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #33
    No problem , it was fun coding that stuff , and I still think it might come handy later. And after testing it out the way you told me to, I think I'll need it still...

    I've looked into the AsphyreSprite code as well, you mean this part takes care of what to draw and what not to draw?
    Code:
    procedure TSprite.Draw;
    var
         ImgName: string;
    begin
         if (FX > FEngine.WorldX + FVisibleArea.Left)  and
            (FY > FEngine.WorldY + FVisibleArea.Top)   and
            (FX < FEngine.WorldX + FVisibleArea.Right) and
            (FY < FEngine.WorldY + FVisibleArea.Bottom)then
         begin
              if not FVisible then Exit;
              case ImageType of
                   itSingleImage: ImgName := FImageName + IntToStr(FImageIndex);
                   itSpriteSheet: ImgName := FImageName;
              end;
    Anyway I created a few test maps to see if it does kick in , a map that is 1500 lines long, and has all layers filled with sprites , that is 120.000 sprites , and my framerate dropped to 75, then i've created a map that is 5000 Lines long
    and has a total of 400.000 Sprites , and I get 26 FPS , I know these are scenarios which I will probably not reach on the long run. Even if the VisibleArea does work , cause I think it does I did another Editor to test it :
    Code:
    procedure TMain.EditorDrawGrid;
    var x,y,z : integer;
    begin
      // 15 lines
      for y := 0 to Map.MapLength-1 do
        // 4 layers
        for z := 0 to 3 do
          // 20 columns
          for x := 0 to 19 do
            begin
              // create/modify sprite with image
              if map.Layer[z].Lines[y,x].ImageIndex <> 0 then
                begin
                  // if sprite was not created I create it
                  if BackGround[z,x,y] = nil then
                    begin
                      BackGround[z,x,y] := TBackGround.Create(SpriteEngine);
                      BackGround[z,x,y].ImageName:= Images.Item[map.Layer[z].Lines[y,x].ImageIndex].Name;
                      BackGround[z,x,y].X:=x*32;
                      BackGround[z,x,y].Y:=y*32;
                      BackGround[z,x,y].VisibleArea:= rect(-32,-32,640,480);
                      BackGround[z,x,y].Z:=z;
                    end
                  // otherwise I only set new image
                  else
                    begin
                      BackGround[z,x,y].ImageName:= Images.Item[map.Layer[z].Lines[y,x].ImageIndex].Name;
                    end;
                  // animation properties
                  if BackGround[z,x,y].PatternCount = 1 then
                    begin
                      BackGround[z,x,y].DoAnimate:=false;
                    end
                  else
                    begin
                      BackGround[z,x,y].AnimStart:=0;
                      BackGround[z,x,y].AnimCount:=map.Layer[z].Lines[y,x].AnimCount;
                      BackGround[z,x,y].AnimSpeed:=map.Layer[z].Lines[y,x].AnimSpeed;
                      BackGround[z,x,y].AnimPos:=(EditorAnimationCounter mod BackGround[z,x,y].AnimCount)+map.Layer[z].Lines[y,x].AnimStart;
                      BackGround[z,x,y].DoAnimate:=true;
                      BackGround[z,x,y].AnimLooped:=true;
                    end;
                end
              // if sprite is empty, I kill it , and set the array entry to nil
              else
                begin
                  if BackGround[z,x,y] <> nil then
                    begin
                      BackGround[z,x,y].Dead;
                      BackGround[z,x,y]:=Nil;
                    end;
                end;
            end;
    end;
    BackGround[z,x,y].VisibleArea:= rect(-32,-32,640,480); if I make this smaller , like 380, the Visible area is smaller, but the speed stays the same not to mention the memory usage, it seems even though it's NOT drawing, the part that does the calculations and who knows what are still taking a considerable tax on the machine.


    Anyway I've created a new version, using this simplified method, where I create all them tiles I need for the Entire Map, then I do the scrolling by moving to the WorldPosition:=(32*Map.MapLength)-480; (last screen) .
    Then Using SpriteEngine.WorldY:=SpriteEngine.WorldY-ScrollSpeed (or be it 4) , I move the map .... and, I don't know I just dont know, it still has hickups on my computer now, the strangest thing is, sometimes when i start it it goes pretty good, then all of a sudden a hickup then goes good for a while... sometimes I start it and it's downright choppy (even tough I have a modest 300FPS now...using all sprites) .

    I'm attaching the source code and a few images to show you what I mean. Can you take a look at the code, what am I doing wrong ?
    Also I've commented out all the inttostr conversions and formatfloat during the rendering onprocessing to make sure that the problem is not cased by them...

    UPDATE : the button DON'T PUSH ME , can be used to fill a map to the max with sprites.... (just carefull if map is very long, it takes a lot of time to create all them sprites...) 1500-5000 enough... for maplength

    UPDATE2 : found this via google.com http://dev.ixchels.net/forum/archive...php/t-139.html , they talk about jerky movement, and it's explained why it's jerky in non fullscreen mode,...guess I'll try to redo in full screen the scroll only, maybe I've missed something....

    UPDATE3 : did a quick test going fullscreen, removed all code again, only left the one necessary for loading level and moving, it still feels jerky if timer speed is 60 (max fps I get on laptop is around 100fps) , now If I move the movement code into device render is a lot smoother, but get that rollercoaster speed effect) , if I increase the speed to 100 on timer , then the movement is pretty fast and seems constant, though I'm not 100% sure it still files like it's doing the hickups but at a much quicker and constant rate. (or I'm seeing things, need someone to check this demo out) Attached is a fullscreen.zip , with executable, it goes fullscreen, map needs to be placed on c drive map is included inside zip, with ESC you can quit anytime, it just loops trough this one map... (I'm not sure if I'm doing this right, I'm right now moving the world down by 4 pixels ... I don't know why I keep thinking this but I think I should move the world map down by 1 pixel only at a much higher interval for worldmap movement only, is this not how it's done properly ?)

    Greetings
    Robert
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by robert83; 26-02-2013 at 07:58 AM.

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
  •