Results 1 to 10 of 87

Thread: Space Shooter Game Editor

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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.

  2. #2
    I could not attach to previous post for some reason , so here it is .

    I've edited a bit more , and added BackGround.OnMove
    Code:
    procedure TBackGround.Move(const MoveCount: Single);
    begin
      inherited;
      if StartDemo = true then
        begin
          WorldY:=WorldY+4;
        end;
    end;
    Using this it scrolls trough one screen of my map, but wont create new lines, wonder why? I tried playing with VisibleArea on a per sprite bases when creating the map but could not get it working properly
    Code:
    BackGround[z,x,y].VisibleArea := rect(-32,(y*32-32),640,(y*32)+480));
    The idea is that I'd create each sprite with a different Visible area... but for some reason, the above code does not do what I expected it to do...

    so for now I'm doing onmove using

    Y:=Y+4;

    seems smoth now on my laptop in smoothscreen, maybe I must do movement in onMove ?

    Greetings
    Robert
    Attached Files Attached Files
    Last edited by robert83; 26-02-2013 at 09:11 AM.

  3. #3
    (Sorry for some reason I cannot get the file upload to show when editing my post)

    Anyway I think I did it...

    Code:
    procedure TBackGround.Move(const MoveCount: Single);
    begin
      inherited;
      if StartDemo = true then
        begin
          if SpriteEngine.WorldY = 0 then
            SpriteEngine.WorldY:=(Map.MapLength*32)-480;
          SpriteEngine.WorldY:=SpriteEngine.WorldY-0.0010;
        end;
    end;
    Note I had to move SpriteEngine from Private to Public...

    The strangest thing is , if it's running non fullscreen I get 27FPS probably the visible area not kicking in, but if I run fullscreen it runs at full 60 fps smooth , on this laptop with integrated gpu...I think that is a big word... I set the visible area for each sprite, I did set it on purpose to be less then screen size to see what happens and if it works.

    So this means I have to make the Editor itself fullscreen to ? (or leave editor as is, since it's easier to work with components available, and do the game in fullscreen later....)

    Update : if Form size is same as asphyre device size, it works in non full screen mode as well at same speed.
    Question : why do I have to use such a low value to move the WorldY now ? 0.0010 , the Speed for Timer is 15 only...

    Greetings
    Robert
    Attached Files Attached Files
    Last edited by robert83; 26-02-2013 at 09:39 AM.

  4. #4
    Quote Originally Posted by robert83 View Post
    The strangest thing is , if it's running non fullscreen I get 27FPS probably the visible area not kicking in, but if I run fullscreen it runs at full 60 fps smooth , on this laptop with integrated gpu...I think that is a big word... I set the visible area for each sprite, I did set it on purpose to be less then screen size to see what happens and if it works.
    Not so strange. Most games run better in FullScreen.

    Quote Originally Posted by robert83 View Post
    So this means I have to make the Editor itself fullscreen to ? (or leave editor as is, since it's easier to work with components available, and do the game in fullscreen later....)
    I suggest that you leave editor as it is since you actually don't realy need smoth movment in editor. But when you would be designing your game you would deffinitly do it in FullScreen mode.
    But if you are prepared to do lot of work you could made Editor to work in FullScreen mode but for this you would need to recreate all VCL components in it and this is nowhere an easy job. I know since I'm trying to do something like this myself. I'm developing a library which would alow me to create VLC-like components which would be rendered by AsphyreSphinx graphic engine. And since 2D portion of AsphyreSphinx graphics engine isn't so different than Asphyre Extreme engine I could probably port my library to it also.

    Quote Originally Posted by robert83 View Post
    Question : why do I have to use such a low value to move the WorldY now ? 0.0010 , the Speed for Timer is 15 only...
    Speed of 15 in timer means that OnProcess will try to execute every 15 miliseconds which means aprox 66 times per second. You need to know that values in AsphyreTimer are just desired delays in miliseconds. And if Rendering takes to much time OnProcess would be executed more than once to catch up.

  5. #5
    For the past two hours I was trying to track this problem but unfortunately I had no luck in going this. I even tried mesuring execution time for Rendering procedure where time needed for completing it was jumping between a few miliseconds to 15 miliseconds. But in worse case it jumped to 247 miliseconds and this happened when I wasn't even moving the map. Why did this happend I have no real answer. I can only suspect that some program has been doing something on the same core that it was asigned to the editor.
    I even tried changing process afinity so that it alwasy ran on one of the cores and increasing the overal prioity but there were still theese hickups.

    Gues I'll need to go and try profiling execution time for each even so small method, probably even those in Asphyre graphic engine itself to pinpoint the problem. I will notify you of my results when I have some.
    But for now based on what is written on the link you provided theese hickups should be less comon when you run your application in FullScreen mode. But this means no VCL components so it might be only usable for game and not editor.

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
  •