Results 1 to 10 of 87

Thread: Space Shooter Game Editor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #30
    I did it


    Scrolling works now, and I've tested it in multiple scenarios , and I understand why it works now , so simple (now...)

    1. I move every available sprite down in the BackGround array
    2. Once I reach 32 with my LineHeight counter (that means I went trough 1 line of Map data) , i do the following :
    a) locate empty line inside BackGround array
    b) read next line of MapData and put it inside of this empty line inside the BackGround array

    Code:
    procedure TMain.ScrollMap;
    var x,y,z : integer;
        i : integer;
        a,b,c : integer;
    begin
      if RanOnce = false then
        begin
          for z:=0 to 3 do
            SetLength(AnimTable.Layer[z].TileAnim, Map.MapLength);
          if MapOffset in [0..15] then
            begin
              MapOffset:=Map.MapLength-15;
            end;
          LineHeight:=0;
          GameDrawGrid;
          RanOnce:=true;
        end;
     
      if MapOffset > 0 then
        begin
          LineHeight:=LineHeight+ScrollSpeed;
    // Background : Layers [0..3], Tiles [0..19], Lines [0..15] of TBackGround;
    // Map.Record : Layers [0..3], Lines [0..Map.Length-1] , Tiles [0..19]
          // move available sprites down
          for z:=0 to 3 do
            for y:=0 to 15 do
              for x:=0 to 19 do
                begin
                  if BackGround[z,x,y] <> nil then
                    begin
                      BackGround[z,x,y].Y:=BackGround[z,x,y].Y+ScrollSpeed;
                      if BackGround[z,x,y].Y = 480 then
                        begin
                          BackGround[z,x,y].Dead;
                          BackGround[z,x,y]:=nil;
                        end;
                    end;
                end; // X loop
          // screen scrolled down one line
          if LineHeight = 32 then
            begin
              Dec(MapOffset,1);
              OffsetEdit.Value:=MapOffset;
              LineHeight:=0;
              // locate an empty line in the BackGround array
              if MapOffset > 0 then
                begin
                  a:=0;
                  y:=0;
                  c:=0;
                  repeat
                    for z:=0 to 3 do
                      for x:=0 to 19 do
                        if BackGround[z,x,y] <> nil then
                          a:=-1;
                    if a = -1 then
                      begin
                        inc(y);
                        a:=0;
                      end
                    else
                      begin
                        b:=y;
                        c:=-1;
                      end;
                  until c = -1;
                  // get next line of tiles and put into free line in background array
                  for z:=0 to 3 do
                  for i:=0 to 19 do
                    if Map.Layer[z].Lines[MapOffset-1,i].ImageIndex <> 0 then
                      begin
                        BackGround[z,i,b] := TBackGround.Create(SpriteEngine);
                        BackGround[z,i,b].ImageName:= Images.Item[map.Layer[z].Lines[MapOffset-1,i].ImageIndex].Name;
                        BackGround[z,i,b].X:=i*32;
                        BackGround[z,i,b].Y:=-32;
                        BackGround[z,i,b].Z:=z;
                        // animation properties
                        if BackGround[z,i,b].PatternCount = 1 then
                          begin
                            BackGround[z,i,b].DoAnimate:=false;
                          end
                        else
                          begin
                            BackGround[z,i,b].AnimStart:=0;
                            BackGround[z,i,b].AnimCount:=map.Layer[z].Lines[MapOffset-1,i].AnimCount;
                            BackGround[z,i,b].AnimSpeed:=map.Layer[z].Lines[MapOffset-1,i].AnimSpeed;
                            BackGround[z,i,b].AnimPos:=AnimTable.Layer[z].TileAnim[MapOffset-1,i];
                            BackGround[z,i,b].DoAnimate:=true;
                            BackGround[z,i,b].AnimLooped:=true;
                          end;
                      end;
                end;
            end;
        end // if Offset
      else
        begin
          // Destroy sprites
          for x:=0 to SpriteEngine.Count-1 do
            SpriteEngine.Items[x].Dead;
          // Clear dynamic array
          for z:=0 to 3 do
            for y:=0 to 15 do
              for x:= 0 to 19 do
                BackGround[z,x,y]:=nil;
          // Start again
          RanOnce:=false;
        end;
    
    end;

    SilverWarrior :

    -I'll get the art in my next post, I'll reasemble the tree, cause I've cut it out into parts from a larger image
    -I'll also give you the shore tiles which are transparent

    If you can then please move this thread to myprojects as you've suggested and name it Space Shooter Game Editor . (think by the end it will be more then just a simple Level Editor)

    Next in plan :
    a) speed set by map position
    b) add snow (perhaps rain, but rain makes me depressed so i'll probably wont do that),
    when game reaches a part of map for example I have a special tile that triggers snow , till another special tile stops it, I planed to make it snow like this :
    -- snow would start faling at line 0 and be destroyed at line 2, next instance of snow would start falling at line 1 and be destroyed at line 3, etc (2,4,3,5,4,6...)
    hopefully with this I would achive a sense of depth, that the snow is actually falling down. This way I could do this without Collision detection, which would probably slow it down pretty much.





    ----
    As for the Object things, there was a reason I've used arrays, I must confess that I'll need to go back to reading and practicing object oriented programing, while I do understand the basics how it works , I did not write code at all in an object oriented way (excluding the Delphi 7 graphichs interface part , but that is automatic, so it doesn't count)
    I've started reading Mastering Delphi7 , that is why I updated my variable, procedure etc...names, as well as why I started commenting in a different way.
    ----

    Greetings
    Robert
    Attached Files Attached Files
    Last edited by robert83; 20-02-2013 at 10:20 AM.

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
  •