Results 1 to 10 of 87

Thread: Space Shooter Game Editor

Hybrid View

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

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

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

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

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

  6. #6
    You don't need to use more units. the only reason for using more uits is when you are trying to make part of the code so that it can be reusable in some other project of yours (you just add existing unit to another project).
    Also you don't need to make procedure or function for about everyting. You only use procedures or functions for comonly repeated parts of code.

    What I do suggest is simply use basic comenting of your code (you write simple coment on top of your procedure or series of source lines so nex time when you will look at that coude you will know what it is for.
    I'm not usre which development IDE are you using but if your development IDE supports using of Regions (available in Delphi XE or newer and in FPC) learn how to use them.
    The best feature of Regions is that they alow you to make foldable parts of your code and even name them. While regions don't affect the program execution they do provide a way to make your code easily redable.

    About scrolling capabilities while removing smoth capability to scroll your map up and down isn't needed for your editor do make sure that you leave yourself the ability to scroll by line othervise you will just make life for yourself a bit more compicated

  7. #7
    Damn I can't seem to get old Asphyre 3.1.0 eXtreme to sucsessfully compile on my Delphi XE3.
    Also the sprite engine itself is being dependant on some Units that are not present in newest Asphyre Sphinx so I can't get your sprite engine to work with newest Asphre engine.

    Which development IDE are you using anywhay?
    EDIT: Don't mind my last question I already got an answer using PE Explorer

    I gues I need to get my old laptop out of all that dust which acumulated over past years on it, fire up Delphi 7 and try to make precompiled packages for both Asphyre 3.1.0 eXtreme and SpriteEngine so I might be able to use them with Delphi XE3
    Last edited by SilverWarior; 04-01-2013 at 12:53 AM.

  8. #8
    Is this about drawing visible map section of 2D grid? You don't need to add any variables to that for background class. It's just small tricks you do in the Draw (DrawLevel?) function.

    1) You have worldX, worldY: single, floating point coords yeah? To get deltaX, deltaY, you can use function frac() for frac(worldX), drac(worldY). I don't know about your scaling, but on all maps i have done, 1.0 value in coords matches size of 1 tile. So if i draw player on 0.5, 0.5, it's in the middle of first tile.

    2) Getting drawable area should be done from the rendering context, be it TForm, TPanel or TOpenGLContext. SX:=context.Width div TileWidth, SY:=context.Height div TileHeight.

    3) When it comes to drawing...
    Code:
    iX:=floor(worldX);
    iY:=floor(worldY);
    for j:=iY-1 to iY+SY do
      if (j>=0) and (j<SizeY) then
        for i:=iX-1 to iX+SX do
          if (i>=0) and (i<SizeX) then begin
            DrawTile(i-iX+deltaX, j-iY+deltaY, @tile[i, j]);
          end;
    That's just from memory though, should work without much modifications.
    Last edited by User137; 03-01-2013 at 10:23 PM.

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

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
  •