Results 1 to 10 of 87

Thread: Space Shooter Game Editor

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    Ok so your basic issue is synchronizing the animation of sprites, that may of been added at any time during the animation of the others.

    There are many ways you could do this (although unless you have two co-dependant animations I can't see why you'd want this) but rather than incrementing every single sprite for the next frame of animation, how about you group the same sprites together or sprites that have the same number of frames? IE:

    SpriteGroup1_FrameNumber = 3

    for I := 0 to SpriteGroup1_SpriteCount-1 do
    Spites[I].CurrentFrame = spritegroup1_framenumber;


    That way you can ensure that for animations of the same speed/number of frames, that they are always rendered on the same frame, regardless if one was added halfway thru the animation cycle.

    Now as far as synchronzing animations of different lengths, why? scheduling so they start at the same time will mean that at some point, you'll have something that should be on screen, but isn't because it's waiting for the start of the next cycle.

    if you have animations of different lengths that you wish to synchronize, then you should scale the frame-rate of one of the animations so they both take the same amount of time to run.

    --

    I'm currently extending my 3D animation lib with better interpolation between animations. Here's an example to get you thinking :

    Walk animation -15 frames - 0.8 second cycle from left foot to left foot. actual movement Speed = 3
    Run animation - 20 frames - 0.4 second cycle """ actual movement Speed = 5

    So how do you smoothly interpolate the skeleton between frames so you can blend walk into run and visa versa?

    The trick is (other than other artist/bone related stuff to make animations that will blend well) that you scale both
    animations at the same time. so if walk has an anim cycle of 0.8, and run 0.4, then halfway through the blend, both animations are scaled so they both have a cycle of 0.6 and a speed of 4 (exactly half way between the two).

    So it doesn't matter where in the animation you start running or walking, it'll always be able to interpolate fairly well.

    --

    As far as sprites are concerned, what's so offputting about the non synchronized animations? if you created a forest you want all the trees to sway in sync?

    Like I say, unless your animations are co-dependant and require sync (two sprites throwing a ball at each other) then you should probably not bother.

    Oh and if you absolutely must sync different length anims so they start on the same frame, then just add dummy frames to the shorter one so it's the same number of frames. yes that'll use slightly more more memory but you'll save yourself a whole bunch of code. Combine that with grouping of sprites
    Last edited by phibermon; 11-01-2013 at 01:17 PM.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  2. #2
    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.

  3. #3
    I DID IT!!!!!!!!!!!!!!!!!! AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    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;
                BackGround[x,y].AnimPos:=AnimTable[y+Offset,x];
                Edit2.Text:=formatfloat('####.##',AnimTable[y+Offset,x]);
                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].AnimStart:=0;
                       BackGround[x,y].AnimCount:=map.Lines[offset+15,x].AnimCount;
                       BackGround[x,y].AnimSpeed:=map.Lines[offset+15,x].AnimSpeed;
                       BackGround[x,y].AnimPos:=AnimTable[y+Offset,x];
                       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;
              end;
          end;
    
      end;
    end;
    Had it reversed on AnimTable[x,y]... [y+Offset,x] is correct... damn I'm getting lost on my arrays... anyway I'll clean up the code a bit... and post the full source with the exe here... I've tried it again just to make sure...it works...no matter what I do
    I scroll down a bit ...wait....scroll again....or scroll completely to the end... the result...perfectly synced sprites the way I like em...

    EDIT : something is still off... I'll need to check the code ...I'm getting lost in my arrays.... I'm not reading the animpos correctly from the array for the vertical line... will recheck

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

  4. #4
    Hi,

    finally did it, it works now. Animation is synced, I'm using another array to keep track of the animations, I've modified the program a bit
    if you decide to run it, you select FILE , OPEN MAP, select demolevel2.map from the directory of the program, then you click on TEST button
    and it will start scrolling trough the map, when it reaches the end of it, it starts again.

    Next I'm planing to add layer2 , any tips for me how to do it properly ? (SilverWarrior)

    Also... I wonder , how I could do with this editor that so called "Paralax" scrolling . I was thinking that maybe I would create layer 1 that would be shorter, and layer 2 that would be longer . For example if Layer1 would be 30 lines long, Layer2 which would go at twice the speed would be 60. But now comes the problem, I would need to define map length for layer1 and layer 2 as well right ? How would you do it ?

    I would like to know how I could create the following for example.

    I saw the following in games which I liked . ( I'll try to describe how that seemed to me ) (JamesTown pc game)

    Layer 1 was a very slow moving (far) background
    Layer 2 was a normal moving background for example flying mountains, or other objects
    Layer 3 was clouds which moved the fastest

    Rright now I'm having problems even trying to figure out how to do it properly , how to start thinking about it. A few hints would be much appriciated.

    Greetings
    Robert
    Attached Files Attached Files

  5. #5
    Found a bug
    In your demo map at the ofset 75 those fast blinking Landing Lights are actually causing water animation to animate faster. I haven't yet looked through your code to figure out why this is happening. Will do as soon as I find some more time.
    Another bug which probably isn't important for editor itself. During map testing the colision procedure doesn't take into account smoth sprite movment and if you do click to try placing tile at specific location during test phase it is placed in wrong line and whole map jumps either up or down can't tell exactly.

    As for Paralax scrolling I personally have no expirience with this but I will take a look at this approach to learn more about it.

  6. #6
    Hello Thank you, but that is not a bug, I did that on purpose to see how it would look, I tried to create a river sorta thing with faster water...moving , and since the river goes into that smaller one the first two tiles are working at the same speed the rest are slower. That is a bug in my drawing , that is being lazy and not creating proper tiles... gona have to start it sooner or later. I think I will probably start working on my layer1 tiles , making em a lot more better...but it sure takes a hell of a lot of time to make em look good....I think I will do a different kind of water... don't like this... I was thinking about some cooler tilesest where the water is moving up and down on the shore... I think I don't need to make the water actually move everywhere...

    As for the Editor thing, I did not intend to use it that way. I need to disable controls during the scrolling, but since it's intended for personal use to be used by only me...I'm not sure if it's worth it.

    I was having a hell of a time with making the scrolling work, could not figure out why it would not work with my DrawSprites routine... so I needed to delete all the sprite lines before I recreated them again for scrolling... otherwise I was getting errors.
    My original scrolling was from bottom to top and stop. And If I used DrawSprites procedure to draw the initial 15 bottom sprites and then create one in top of it... and then move it down, and add one at top till I reach the end. If I clicked on anything no matter
    where on the drawing surface I got an error... I could not figure out why, then I started playing with the scolling trough the map and start again and then I noticed why, or I think why... the lines the way I recreated them were not in order...

    Example I started like this : (for simplicity 4 lines only)
    0
    1
    2
    3

    And depending on my map length but when I reached the end it was like this (probably)
    2
    3
    0
    1 -> this was destroyed because in our example the screen can use say 3 lines

    Anyway this is something that I probably should not bother with, because I don't intend to use the editor and the scrolling at the same time...

    So then let's postpone the paralax thing for now. If you can give me a few hints on how would you do the aditional layers ? Should I just simply add another TMapLine2 ... TMapLine3 ... TMapLine[n] ?

    Also was thinking about the following (think it's doable...and I think it would look kinda cool...) I was thinking of adding speed to each line of the map. Meaning I could set the speed if I wanted to at line level, kinda like scripting the map a bit...
    For example lines 1..12 would go at 8x... then til 75 I would go at 2x.... then at line 100 would go at 8x etc... So I could change the speed of the level depending on the situation, more enemies less enemies , escape etc...

    Was thinking that I could implement it like this :

    To the right side of my Panel1 (Asphyre surface) I would ad 15 edit boxes... , when i create the map I would specify the default speed and would fill up the array with it till end
    Going down and up on the map I would fill the edit boxes with the apropriate speeds from the array ... and I could also change them.

    Right now looks like this :
    Code:
      TTileData=record
             ImageIndex: integer; // Tile Number
             AnimStart: integer; // Tile Animation Start Position
             AnimSpeed: Single; // Tile Animation Speed
             AnimCount: Integer; // Tile Animation Count
            end;
    Would change it to this :

    Code:
      TTileData=record
             Speed:integer // Scrolling Speed  (2,4,6,8,16)
             ImageIndex: integer; // Tile Number
             AnimStart: integer; // Tile Animation Start Position
             AnimSpeed: Single; // Tile Animation Speed
             AnimCount: Integer; // Tile Animation Count
            end;
    I think I would use another 2 layers for background (that is just background nothing else) ... so I could place grass for example, and trees above grass...

    The frouth layer would be by the current plan the layer that would tell the map for example that at 19,4 spawn enemey ship , type, life, speed, direction type, firing type etc... or spawn cloud , birds , etc... which means this last layer would have a lot of variables , I would like to do the magic at the map editor level . So I can create the "randomness" by hand... one ship here other ship there... or a stationary turret here there , but right now I only mentioned it so you can point me to the right direction with your helpfull tips / hints . Only thingking about it right now kinda overwhelms me. Gona do it by baby steps.

    Anyway think I'll watch a movie now Nighty night!
    Last edited by robert83; 17-01-2013 at 09:46 PM.

  7. #7
    GOOD news! I have finally managed to prepare development enviroment so I'm finally able to Compile and Debug your program. So expect more practical solutions (code samples) in future.
    BAD news! After quick debug tracing through your code I see that there are several DANGEROUS sections (even if Asphyre engine doesn't manages to initialize you still try to initialize SpriteEngine which then fails as it needs already initialized Asphyre engine) which might lead to many bugs.

    So what I'm gonna do first is study your code, try to find this sections and also try to fix them. Might take some time.
    Then I'm gonna make some quick test to check SpriteEngine capability so I get some idea what we might be able to get out of it. This would probably largely affect my futurte suggestions.

    As for the layers I was thinking about making a system which would alow you to use as many layers as you need (in editor you simply add new layers when needed). And if SpriteEngine is capable of working with thextures which also support Alpha chanell we might use so caled texture layering where you combine two textures to gain desired end effect. For instance:
    Layer1: Contains simple texture which basically defines the overal colour of the water.
    Layer2: Contains texture which has some parts semitransparent. This texture also controls water animation.
    Layer3: Contains land texture. Part of this texture is transparent so water texture from below can be seen (shoreline).
    So now we only need to figure out how much will each layer drop the overal performance (more layers more work for Graphics engine).

    As for controlling the scroll speed I was thinking about storing the information about scroll speed in the TLine itself so that when you create specific line of sprites you also check if scroll speed should be adjusted.
    Actually I was thinking about proposing you to implement some ingame event system with which you could contoll enemy spawning, maybe even change in enemy AI, scroll speed, and even controll sprites animations.
    And when I'm talking about controlling sprite animations I have idea of implementing system which would alow you to easily synchronize animation between varios tiles and alow full controll on theese animations (stop them at any time, set them to specific position, change their speed, etc).
    So you could have something like this in your game: Destroying a power statkion on an island causes all the lights to go blank, radars to stop turning, defensive turets to stop fireing at you etc. Posibilities are almost endles.

    Yes yes implementing all theese ideas won't be an easy task but I'm sure it would be woth the efford in the end. And yes I'm preapred to give you a hand in all this now that I have development platform ready.

    Wait when I'm gonna work my own projects

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
  •