Page 4 of 9 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 87

Thread: Space Shooter Game Editor

  1. #31
    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.

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

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

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

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

  6. #36
    Yeaaaa!!! , THANK YOU VERY VERY VERY MUCH!!!

    I've modified my TEST button a bit
    Code:
    procedure TMain.Button7Click(Sender: TObject);
    var i: integer;
    begin
      for i:=0 to SpriteEngine.Count-1 do
        begin
          if SpriteEngine.Items[i].ImageName <> 'selection.image' then
            begin
              SpriteEngine.Items[i].Dead;
            end;
        end;
      if StartDemo = false then
        begin
          StartDemo:=true;
        end
      else
        begin
          StartDemo:=false;
          RanOnce:=false;
          CreateSprites;
          DrawSprites;
        end;
    end;
    Also modified the Scollmap procedure :
    Code:
            if offset in [0..15] then offset:=Map.map_length-15;  // set offset to map end - one screen of tiles (0..14)
    This way if I press the test button and I'm not on the first screen +1 line... I can start and stop the scrolling, then start it again from same position... think this is more usefull for the editor, say I feel something is off does not go well with the rest of the map I can stop it right there edit...and then continue the scrollmap .

    For the BAD news , where to I do that ? on Form.Create ?
    Is this that DANGEROUS thing ?
    Code:
      AsphyreDevice1.Height:=480;     // Asphyre Height
      AsphyreDevice1.Width:=640;      // Asphyre Width
    
      AsphyreDevice1.WindowHandle:=Panel1.Handle;    // Asphyre uses Panel1 as rendering surface
      AsphyreDevice1.Initialize;                    // Initialization
      if AsphyreDevice1.Initialized = false then      // if failes displays message and terminates program
        begin
         ShowMessage('Error initializing Asphyre!');
         Close;  // <---- if the the initialization fails , program closes
        end;
    
    
      ASDB1.FileName:=ExtractFilePath(Application.ExeName)+'TileSet.asdb';  // path to databse ( tilesets )
      SpriteEngine := TSpriteEngine.Create;                                 // Creates the SpriteEngine
      SpriteEngine.Image:= Images;                                          // Sets SpriteEngine to use Image source
      SpriteEngine.Canvas:= AsphyreCanvas1;                                 // Sets SpriteEngine to use AsphyreCanvas
      Selection := TSelection.Create(SpriteEngine);                         // Creates the Selection Squire
    For the speed I'm not quiet sure how should I add it to this ? Quote: "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."
    Code:
      TMap=record
             name:string[20];  // Name of the Map
             map_length:integer; // Length of the Map
             Lines: array of TMapLine;  <--- I should add here somehow the Speed , but how?
           end;
    As for the Layers ... the one you mentioned makes sense... but I don't even know where to begin . Texture layering sounds good, only problem is I have no idea how to implement.

    I would probably have to change my Map record a bit...
    Code:
      TTileData=record
             ImageIndex: integer; // Tile Number
             AnimStart: integer; // Tile Animation Start Position
             AnimSpeed: Single; // Tile Animation Speed
             AnimCount: Integer; // Tile Animation Count
            end;
      TMapLine=array [0..19] of TTileData; // Stores one line of tile data
      TLayers=array of TMapline; // stores all layers of Mapline
      TAnimTable=array of array [0..19] of single;
      TMap=record
             name:string[20];  // Name of the Map
             map_length:integer; // Length of the Map
             Layers: array of TLayers; // stores each layer of the Entire map [0,0..19] , first value is 0 till map_length (vertical), second value is 0..19 (horizontal)
           end;
    Now I'm really starting to get lost in them Arrays, will have to start drawing I guess ....

    Now if I understood you correctly , we might get away with somehow only using 320 sprite's and adding to them all the layers? (1,2,3,4,5,6...n) (instead of creating 320 sprites for each layer ) .
    Unfortunately I don't know how to begin, how can I later say edit only layer2 sprites even if I have layer3,layer4 or layern on "top" of it . Was trying to google (damn Asphyre ... always brings up ACER laptops, and only a few valuable hits...)

    Greetings
    Robert
    Last edited by robert83; 18-01-2013 at 10:14 PM.

  7. #37
    Quote Originally Posted by robert83 View Post
    For the BAD news , where to I do that ? on Form.Create ?
    Is this that DANGEROUS thing ?
    Code:
      AsphyreDevice1.Height:=480;     // Asphyre Height
      AsphyreDevice1.Width:=640;      // Asphyre Width
    
      AsphyreDevice1.WindowHandle:=Panel1.Handle;    // Asphyre uses Panel1 as rendering surface
      AsphyreDevice1.Initialize;                    // Initialization
      if AsphyreDevice1.Initialized = false then      // if failes displays message and terminates program
        begin
         ShowMessage('Error initializing Asphyre!');
         Close;  // <---- if the the initialization fails , program closes
        end;
    
    
      ASDB1.FileName:=ExtractFilePath(Application.ExeName)+'TileSet.asdb';  // path to databse ( tilesets )
      SpriteEngine := TSpriteEngine.Create;                                 // Creates the SpriteEngine
      SpriteEngine.Image:= Images;                                          // Sets SpriteEngine to use Image source
      SpriteEngine.Canvas:= AsphyreCanvas1;                                 // Sets SpriteEngine to use AsphyreCanvas
      Selection := TSelection.Create(SpriteEngine);                         // Creates the Selection Squire
    Yes. For some reason Close doesn't end the Application execution when expected. Usually you use Application.Terminate instead.
    Also if you take a look at TAsphyreDevice component you will notice that it has OnInitialize event. That event can be used for aditional initialization procedures. So you can move all the stuff needed for SpriteEngine initialization into that even procedure.

    Quote Originally Posted by robert83 View Post
    For the speed I'm not quiet sure how should I add it to this ? Quote: "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."
    I was thinking of adding another variable in TMapLine record.

    Quote Originally Posted by robert83 View Post
    As for the Layers ... the one you mentioned makes sense... but I don't even know where to begin . Texture layering sounds good, only problem is I have no idea how to implement.

    I would probably have to change my Map record a bit...
    I was thinking of redesignign Map record entirely but haven't figured out how exactly yet.

    Quote Originally Posted by robert83 View Post
    Now I'm really starting to get lost in them Arrays, will have to start drawing I guess ....
    Yes multidimensional arrays can be a bit puzeling. All you have to do is learn how to think out of the box to fully understand them.
    This might help you a bit:
    Records (TTileData) are sheets of paper.
    Lines (TMapLine) are books containing this sheets of paper.
    Layers are shelves on which you have all theese books.
    Map(TMap) is a library with all theese shelves.


    Quote Originally Posted by robert83 View Post
    Now if I understood you correctly , we might get away with somehow only using 320 sprite's and adding to them all the layers? (1,2,3,4,5,6...n) (instead of creating 320 sprites for each layer ) .
    Unfortunately we would need to create specific sprites for each layer. Good news is that upper layers won't need to have full grid of sprites but would have sprites only on certain positions so final count of sprites wont be 320 * number of layers.

    Quote Originally Posted by robert83 View Post
    Unfortunately I don't know how to begin, how can I later say edit only layer2 sprites even if I have layer3,layer4 or layern on "top" of it . Was trying to google (damn Asphyre ... always brings up ACER laptops, and only a few valuable hits...)
    From what I see you manually calculate map position which needs to be updated on mouse click. That is good as you only need to add additional condition which determines which layer are you editing.


    Anywhay I have decided to go and redesign map record so it will support multiple layers.
    I plan on designing layers in a whay so that they can have varios sizes, both in lenght as in sprite sizes used in them (hopefully it would alow us to implement paralax scrolling).
    I would redesign scrolling procedure so it would be compatible with new layer types.
    I would need to design map file routine to support storing all this information in organized manner (maped file approach). Don't wory I will also write short documentation explaining how this works so you could do futher changes in the future.

    I also plan on adding some other tweaks to your code.
    For instacne you are currently calculating your mouse position inside AsphyreTimer1.Process event procedure while you could easily just use TPanels OnMouseMove event to do so.
    And to determine if mouse is over panel you could simply use TPanels OnMouseEnter and OnMouseExit events to detect when mouse is moved over panel and when away from it. The best thing about theese events is that they also detect if mouse moves over some other window which is positioned above your Panel.
    EDIT: OnMouseEnter and OnMouseExit events are unfortunately not present in Delphi 7.
    Last edited by SilverWarior; 19-01-2013 at 05:04 AM.

  8. #38
    Hello,

    I'll change that to terminate , and move Sprite Engine initialization into that part.
    Well my uncle has a Panel that he created and has onmouseenter and onmouseexit, I'll ask him for his permision to give it to you. That way we can start using that other panel, and redesign the mouse handling as well . Would be a lot more simple .

    Greetings
    Robert

  9. #39
    Quote Originally Posted by robert83 View Post
    Well my uncle has a Panel that he created and has onmouseenter and onmouseexit, I'll ask him for his permision to give it to you. That way we can start using that other panel, and redesign the mouse handling as well . Would be a lot more simple .
    Yes you can ask him for that. But even if he doesn't agree it would be no big problem as I was already suggesting similar aproach to someone else in the past I just have to remember to whom I have been suggesting this. Maybe I even have code for this somwhere on my computer.

    BTW after some fideling with your code I actually decided to go and start from scratch as there are some parts of your code which are not clear to me. This seems easier to me. I also decided to use a bit different approach which might be a bit more difficult to understand but it should provide us with more options in the end.

  10. #40
    Hello,

    Asked my uncle, gave me permission to post the AthorPanel pas,dcu,dcr here for your convinience. It has onmouse enter onmouse leave.


    I'm working further on my editor, even tough you've said that you'll do it from scrach ( I'm doing it for the sake of learning, man gotta do mistakes to learn ).

    I've changed the TileData ImageIndex to ImageName string[10] , why I did this? Well I burned myself, I was editing the asdb file... and don't know how I managed , I've deleted the last entry , added it again, then was doing something
    removed last entry added again, and the entire index of the asdb file went to hell.... my map's were using tiles but of incorrect index, thus I'm using names instead of index numbers. Did not notice any speed hit on my comp. Will post it later.

    (Note : I also managed to get my hands earlier on some level editor made by someone on the Asphyre Forums... it also stores the imagename instead of imageindex , probably for same reason...safer , the name never changes the index might)

    Greetings
    Robert

    ps.: attached the component
    Attached Files Attached Files

Page 4 of 9 FirstFirst ... 23456 ... 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
  •