Page 2 of 9 FirstFirst 1234 ... LastLast
Results 11 to 20 of 87

Thread: Space Shooter Game Editor

  1. #11
    Happy new year!!!

    Thank you for the tips, I did remove the random... also in my previous version (probably you did not check my source), I've already managed to save my map data using 2 for cycles, and load it as well.

    Since then I've gone a bit further, I've modified my map record like this :
    Code:
       TMapData=array of array of Integer;
      TMapAnim=array of array of Integer;
      TMap=record
             name:string[20];
             map_length:string[3];
             data:TMapData;
             anim:TMapAnim;
           end;
    It stores the tile index, and it also stores for each tile index if it should be animated or not.

    I'm also saving the data correctly map.name, map.length, map.data, map.anim , and loading correctly as well. But now I have a tiny problem , I don't know how can I make my water tiles get synced, right now if I move fast up or down on this
    map I drew, they get out of sync.

    (yeah I've created the tiles using some tutorials...to see how my map would look like).

    I'm planing to also save into my map file, anim_start, anim_speed so for example if I want to add some light (for example airport lights) to my map, I could specify in which order they would light up, so they would not look like clones of each other.

    I don't know maybe if I add anim_start and anim_speed into my map file , my water tiles will be synced again?

    As for the whole thing I don't know myself what I wanna do... My plan is to make a Space Shooter game...that as you can see will have a lot of terrain in it...with moving stuff. Right now I wanna properly finish layer1 , then I'll add another layer
    for trees, houses, other stuff, some floating on water stuff...., and much much later, I'll probably add another one Layer3 enemy objects, kinda like spawning points for enemy units, enemy buildings that shoot at you etc... but as I said I'm focusing on layer1, I don't want to overcomplicate and get lost, still got very-very-very much to learn about how exactly this sprite_engine works, and Asphyre as well, and game programing in general.

    Attached I give you my latest Editor 0.7 with my tileset, I know it's bad , I will later revise it a few times for the final product... just wanted to see how the final picture would look like.
    I've attached it again, the previous attachment had a nasty bug...

    Greetings
    Robert
    Attached Files Attached Files
    Last edited by robert83; 01-01-2013 at 11:52 PM.

  2. #12
    Hi,

    Meanwhile I've managed to simplify down my DoAnimate yes or no logic.... here is the new code :

    Code:
     procedure TMain.LoadLevel;
    var i,j : integer;
    begin
      for j := 0 to 14 do
        begin
          for i := 0 to 19 do
            begin
                BackGround[i,j] := TBackGround.Create(SpriteEngine);
                BackGround[i,j].ImageName:= 'Empty.image';
                BackGround[i,j].X:=i*32;
                BackGround[i,j].Y:=j*32;
                BackGround[i,j].Z:=1;
                BackGround[i,j].AnimStart:=1;
                BackGround[i,j].AnimCount:=3;
                BackGround[i,j].AnimSpeed:=0.01;
                BackGround[i,j].AnimLooped:=true;
            end;
        end;
    end;
    procedure TMain.DrawLevel;
    var i, j: Integer;
    begin
         for j := 0 to 14 do
            begin
              for i := 0 to 19 do
                begin
                  Used_Tile := Images.Item[map.data[i,j+Offset]];
                  BackGround[i,j].ImageName:= Used_Tile.Name;
                  if BackGround[i,j].PatternCount = 1 then
                    begin
                      BackGround[i,j].DoAnimate:=false;
                    end
                  else
                    begin
                      BackGround[i,j].DoAnimate:=true;
                    end;
                  BackGround[i, j].Draw;
                end;
            end;
    end;
    The problem still persists.... my water tile animation are no longer synced....how can I sync them? It does not matter if all animation would be synced, since I will use the map.anim to specify from which frame to start the animation , and add the map.animspeed to the mix, to make things like lights etc... be "unique" .

    Greetings
    Robert

  3. #13
    Ok,

    I've been thinking about it... and I came to a solution... I created a new procedure SyncAnim, which I right now manualy set using a button on my form... after DrawLevel, I execute it and all my tiles are synced. (later I plan to make the AnimStart variable be read from the map.anim_start[] 2d array.

    Code:
     procedure TMain.SyncAnim;
    var i, j: Integer;
    begin
      for j:= 0 to 14 do
        begin
          for i:=0 to 19 do
            begin
              BackGround[i,j].AnimPos:=0;
            end;
        end;
    end;
    Right now I'm thinking about where to put this code , so that It would execute automagically , each time I go up and down on the level, or add a new tile....

    I'm thinking about using another boolean variable
    Code:
    var something_happened : boolean;
    and if I go up or down, or add a new tile , something_happened :=true ...

    then on AsphyreDevice1Render after DrawLevel I add
    Code:
    if something_happened = true then
        begin
             SyncAnim;
             Something_happened:=false;
        end;

    Right now i don't know if there is a better way to do this? I think this should not slow things down, since I'm not re-drawing twice, I just sync the animpos for all my tiles to 0 right now...

    UPDATE :

    changed my code to see how this works , but it seems this is not the right solution...during scrolling the animpos is always reset to 0, the game will move trough the world by 1 instead of 32 , which will make my water animation along with the rest of the animation still...

    UPDATE2 :

    Code:
      if Update_Anim = true then
        begin
         DrawLevel;
         SyncAnim;
         Update_Anim:=false;
        end;
    Attached is my code with the executable, and a sample level02.map , next step if this is OK, to create a level test sorta thing... that scrolls trough the level smoothly.

    I think I've got it this seems to work quiet good

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

  4. #14
    The main reason why your sprites are not synchronized is the fact that when you are creating them or modifying them upon map move you are setting their current animation position to 0 but instead you should set animation position to the current animation position.
    So basically you need to keep track of water animation. You can do this by having one Global numerical variable which is increased at the same intervals as animation pictures needs to be changed. And then to find out which is current animation position you calculate using Mod command:
    Code:
    AnimationPos := GlobalAnimCounter mod AnimationCount;
    If you do this you shouldn't forget to reset GlobalAnimCount to 0 after some time othervise you will exceed maximum integer value which can lead to problems.

    Anywhay I'm currently at work so Iall I can give you now is general idea. But when I come home I intend to download Aspyhre eXtreme and SpriteEngine so I would be able to actually compile your source and therefore be able to test some ideas directly by changing your code.
    I have already given some thoughts about how to make map smothly scrolable to be used in your game but I need to check whether it is posible to do this using your sprite engine.
    I was also thinking about how to implement your game map in most eficient way (what would be the best way of storing information for all your needed layers).

    So stay tuned and await more of my suggestions shortly.

  5. #15
    Hi,

    I can't sleep, I've coded a bit, added AnimStart variable to my map data... you can set animstart for each tile, so the latest attached editor can make certain tiles be synced, and other tiles see them lights do their animation from different starting position.
    Also since now I'm only executing my DrawLevel and SyncAnim loop when the map is updated or moved.

    If you execute this one, and load the included level02.map you'll see that water is perfectly synced, the lights which i wanted to be synced are synced, and those 3 lights are using different anim start position, so don't look like exact copies of
    each other.

    Next I'm planing to add for each animated sprite , animation speed, so I can have faster and slower lights, or faster slower water,fire...etc....


    I was thinking myself about the scrooling, unfortunately I cannot simply use BackGround[i,j].WorldX and WorldY , because I'm only drawing as many sprite's as I'm actually using for 1 screen...

    I came up with a solution, which I think could work, I would create 1 more line of Sprite's , that would be beyond the screen height in the direction I'm moving.

    Then I would move WorldY until I would rich the end of this aditional (hidden) line of Sprite's , once I rich the end of it I would move my entire BackGround[i,j].Images in the apropriate directions, and reset my WorldY to the original position.

    My idea is that the redraw of the Sprite Grid would be so fast that the user would not notice it, and would "feel" like it's scrolling trough the map by 1 instead of 32 .

    Greetings
    Robert
    Attached Files Attached Files

  6. #16
    Well, I almost got it I made the smooth scrolling possible like this :

    Code:
     procedure TTools.DOWN_1Execute(Sender: TObject);
    var i,j : integer;
    begin
      if MainForm.Offset < strtoint(LLength.Text)-14 then
        begin
          inc(MainForm.Reset_Grid,1);
          if MainForm.Reset_Grid = 32 then
            begin
              Main.DrawLevel;
              Main.SyncAnim;
              MainForm.Reset_Grid:=1;
              inc(MainForm.Offset,1);
              for j := 0 to 15 do
                begin
                  for i := 0 to 19 do
                    begin
                        BackGround[i,j].WorldY:=0;
                    end;
                end;
            end;
          for j := 0 to 15 do
            begin
              for i := 0 to 19 do
                begin
                    BackGround[i,j].WorldY:=BackGround[i,j].WorldY-1;
                end;
            end;
        end;
    end;
    Currently it only works for down, but has a small problem which I'm trying to fix now, when I start scrolling down with it goes down 32 , then does a jump that I can feel.... but after that I cannot feel that I'm drawing that one additional line , it feels like
    I'm actually scrolling trough a 30 line long map for example....
    Also my animation is reset as I move down .... which is not good...damn, have to find a fix for that to.

    But atleast did some progress on me own.

    UPDATE : if I set RESET_GRID on FormCreate to RESET_GRID:=31 (instead of 0), my scrolling down is as smooth as can be.... only animation remains problem now that it's synced whenever I move....not good will have to
    use you're suggestion to make em synced , hopefully I can make em synced and still keep the uniqueness of invidiual animations by using startpos by tile.

    Greetings
    Robert
    Last edited by robert83; 03-01-2013 at 02:06 AM.

  7. #17
    YEAAAHHH,

    Here it is, smooth scroll works in both directions up and down, only minor problem which I need to fix now is (not a big problem for my intended game since it's a space shooter which goes in one direction only) , when I change directions it's visible. I find it difficult to explain with my english knowledge. See for youreself.

    Anyway making some really nice progress (so I think atleast)

    Greetings
    Robert
    Attached Files Attached Files

  8. #18
    Quote Originally Posted by robert83 View Post
    Hi,

    I can't sleep, I've coded a bit, added AnimStart variable to my map data... you can set animstart for each tile, so the latest attached editor can make certain tiles be synced, and other tiles see them lights do their animation from different starting position.
    Also since now I'm only executing my DrawLevel and SyncAnim loop when the map is updated or moved.

    If you execute this one, and load the included level02.map you'll see that water is perfectly synced, the lights which i wanted to be synced are synced, and those 3 lights are using different anim start position, so don't look like exact copies of
    each other.
    Nice work on this. But I still think that water animation gets out of sync when scrolling.

    Quote Originally Posted by robert83 View Post
    Next I'm planing to add for each animated sprite , animation speed, so I can have faster and slower lights, or faster slower water,fire...etc....
    Yes this would be nice feature and could come verry handy in future.


    Quote Originally Posted by robert83 View Post
    I was thinking myself about the scrooling, unfortunately I cannot simply use BackGround[i,j].WorldX and WorldY , because I'm only drawing as many sprite's as I'm actually using for 1 screen...

    I came up with a solution, which I think could work, I would create 1 more line of Sprite's , that would be beyond the screen height in the direction I'm moving.

    Then I would move WorldY until I would rich the end of this aditional (hidden) line of Sprite's , once I rich the end of it I would move my entire BackGround[i,j].Images in the apropriate directions, and reset my WorldY to the original position.
    Yes adding a new line of sprites for smoth scrolling is necessary. But I had a bit different idea of how to implement this. Instead of moving WorldY Position I would go and move the sprites instead. Why? If you move sprites instead you won't need to update all visible sprites when you have moved your map for the full line size but instead you go and destroy those sprites that are no longer needed and then make new line of sprites when they would be needed.

    Since you are trying to make SpaceShooter game I presume you will be moving your gameworld downward. So the way how I would implement this scroling is like this.
    1. First you create enough sprites to fill window size (similar as you do now).
    2. Then you create another line of sprites above current ones.
    3. You move all these sprites downward by certain amount of pixels.
    4. Once you have repeted step 3 enough times so that you moved the world for entire line height you destroy botom line of sprites which aren't visible anymore now and then you create another line of spites at the top. After that you go back to step 3.
    5. You repeat step 3 and 4 until you either reach the top of the map or reach a boss ship which temporarily halts your progression through map.
    6. Then you either end the game if it is on end of the map or wait for the boss to be kiled.

    The biggest advantage of this approach is that you are not updating the textures for existing Sprites (unles for animations) but you are just adding necessary new Sprites and killing (destroying) unnecessary ones.

    Offcourse to make this work easier I would change the map structure to someting like this:
    Code:
    TTileData = record
      ImageIndex: Integer; //Stores the index for retriving necessary image from TAspyhreImages
      AnimationCount: Integer //Stores how many pictures does animation contains
      AnimationOffset: Integer; //Stores offset from global animation position
    end;
    
    TMapLine = Array[0..15] of TTileData; //Stores the whole line of cells asuming the map width is 15 tiles.
    
    TMap = record
      Mapname: String;
      MapSize: Integer //Storing the map size in String type could lead to problems during conversion. Also storing in Integer type saves you some memory.
      TLines: Array of TMapLine; //Stores the whole map
    end;
    So with proper file handling routines you can now actually go and read the map data directly from file Line by Line and thus reduce Games memory consumption a lot and you gain the ability to have enourmus maps if needed.
    Ofcourse implementing several Layers would reqjuire aditional change to this maps structure.

    As for Sprites animations you can see that I used AnimationOffset variable in my suggested map code. The reason for this is the fact that I'm still thinking of having some Global variable to progress position of various animations so that when you are making new sprites you just set their proper aniamtion position and then leave your SpriteEngine to take care of your animations.
    To put this in code I need to get my computer set to be ready to compile your program first. Yes I know I sad that I would do this as soon as I come home but the fact is that I came home preaty beat up today so I haven't got much motivation for programing. Tis also means that above code is still just out of my head and might have some syntax errors.

  9. #19
    Quote Originally Posted by robert83 View Post
    YEAAAHHH,

    Here it is, smooth scroll works in both directions up and down, only minor problem which I need to fix now is (not a big problem for my intended game since it's a space shooter which goes in one direction only) , when I change directions it's visible. I find it difficult to explain with my english knowledge. See for youreself.

    Anyway making some really nice progress (so I think atleast)

    Greetings
    Robert
    From what I see the problem is that when you are moving UP your are not adding necessary line of sprites on uper side which makes that black line.

    Any whay now if you would excuse me I would like to go to bed as it is 3:41 am here now.
    Post any progress you made and I'll try to find some time tomorow to write you the whole map movment functions as explained in my previous post. I would also write you a Map file handling routines which would alow you to load several Layers when needed.

    EDIT: BTW I recomed you to start commenting your code. While at this time it might seem unnecessary to do this but when your code grows you will find out that you can quickly get lost in it and then don't know what which part of the code does.

  10. #20
    Hello,

    thank you , I will start commenting, and cleaning up the code, possibly using more units, try and categorize the procedures in units in a meaningfull easy to see manner.
    yeah now I see what you mean, though I'm way to tired to fully understand (went to sleep at 3:00 am, woke up at 06:30 am, at work now... will sleep today).
    if I understand you're map format would allow map file to be read line by line when needed ? instead of beaing read at once?
    once I get some sleep, I will modify the code, and I'll try to do it like you've told me .

    Now that I think about it, I will not overcomplicate my life. I'll reamove up and down by 1 , instead I will put a simple demo mode there, which when clicked on will jump to the end of the map, and from there move up by one till the end of the map. Just like it would later in the real game. And I think I will also add another variable into the map data.... scroll speed, migh come in handy if later I decide I want a map that is faster for some reason then the rest.... ligthspeed travel or escape from some boss, or something.

    Thank you for youre time, I'll post tomorrow on my progress.

    Greetings
    Robert

Page 2 of 9 FirstFirst 1234 ... 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
  •