Results 1 to 10 of 87

Thread: Space Shooter Game Editor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #28
    I must have perfectly synced sprites somehow, I don't want to complicate my life with Sprite Groups...
    For example I might want to have some object that consists of 4 tiles do something out of sync, other times in a certain order, or in perfect sync. I believe it should be doable to sync newly created tiles with previously created tiles, only problem is this seems to be beyond my knowledge right now...

    I've tried to do it like this :

    1. Created a new 2d array , that is responsible for holding the current animation position for every tile on my tile map ( I though baaammmmmmm eat this EVIL sprite engine time offset demon )
    Code:
      TAnimTable=array of array [0..19] of single;
    2. I've created the following procedure :
    Code:
    procedure TMain.AnimCounter;
    var i,j: integer;
    begin
          for i:=0 to Map.map_length do
            begin
              for j:=0 to 19 do
                begin
                  if map.Lines[i,j].AnimCount > 1 then
                    begin
                      AnimTable[i,j]:=AnimTable[i,j]+(1*map.Lines[i,j].AnimSpeed);
                    end
                  else
                    begin
                      AnimTable[i,j]:=1;
                    end;
                  if AnimTable[i,j] > map.Lines[i,j].AnimCount then AnimTable[i,j]:=0;
                end;
            end;
    end;
    This I've checked (using a few EDIT boxes ) works, for example Animated Sprite at 0,0 has 3 animation positions , and it's speed is 0,01 ... I've checked the position goes up with the apropriate speed.
    I've added another Sprite at 0,1 which has 6 animation positions, and it's speed is 0,5 , I've checked it again it goes at a much faster rate...

    I thought to myself YEAH I solved this darn problem... (and the program is still pretty fast, even on me amd duron 1400+ , with my test level...which is not to long , but I don't plan to make enormous levels...a dude has to start somewhere...)

    I've modified my smooth scroll test procedure a bit :

    Code:
    procedure TMain.TestExecute(Sender: TObject);
    var x,y : integer;
        new_line : boolean;
    begin
      if Offset < Map.map_length-14 then    // -14 , Number of Tile Lines Drawn on Screen
        begin
        inc(Counter,1);         // I'm using this to check if I've scrolled down one tile Height (32), if I did
        if Counter = 32 then    // then I'm increasing Offset by 1 and reseting Counter to 0, Offset is used to tell the new line of sprites which Line of TileData
          begin                 // to read from the array
            Inc(offset,1);
            Counter:=0;
          end;
    
        for y:=0 to 15 do
          begin
            for x :=0 to 19 do
              begin
                BackGround[x,y].Y:=BackGround[x,y].Y-1;
                if BackGround[x,y].Y = -32 then
                  begin
                    BackGround[x,y].Dead;
                    new_line := true;
                  end;
                if new_line = true then
                  begin
                    BackGround[x,y]:= TBackGround.Create(SpriteEngine);
                    Edit9.Text:=inttostr(offset);
                    BackGround[x,y].ImageName:= Images.Item[map.Lines[offset+15,x].ImageIndex].Name;
    
                    if BackGround[x,y].PatternCount = 1 then
                      begin
                        BackGround[x,y].DoAnimate:=false;
                      end
                    else
                      begin
                       BackGround[x,y].DoAnimate:=true;
                       BackGround[x,y].AnimLooped:=true;
                      end;
                    BackGround[x,y].X:=x*32;
                    BackGround[x,y].Y:=480;
                    BackGround[x,y].Z:=1;
                    new_line:=false;
                   end;
                   BackGround[x,y].AnimStart:=round(AnimTable[x,y+Offset]);
                   BackGround[x,y].AnimCount:=map.Lines[y+Offset,x].AnimCount;
                   BackGround[x,y].AnimSpeed:=map.Lines[y+Offset,x].AnimSpeed;
              end;
          end;
      end;
    end;
    The AnimCounter procedure is executed at AsphyreDevice1Render .

    And I still get the cursed wave effect , how....is....this....possible ?

    Now that I think of it...maybe the problem is...that now since I'm doing the position calculation... maybe I should manually step the images? Can I do that somehow?
    The idea here was to calculate all animation positions for every tile , even uncreated... thus eliminating the lag caused by it's creation... I think it should work...if I could somehow manually step the Sprite Position
    every time when the TEST action runs to my AnimTable[x,y] position... I can even add Animation Offset into this combo...


    Greetings
    Robert
    Last edited by robert83; 11-01-2013 at 07:28 PM.

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
  •