Autor Beitrag
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mo 05.05.03 17:35 
Hallo,
habe da ein array problem. schaut euch mal den code an:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
procedure TSokubahn.MoveKiste(NewX, NewY,OldX,OldY,DirX, dirY:Integer);
var
  oldTex,OldTyp,kx,ky:Integer;
begin
  if (Map[NewX, NewY].Typ <> Wand) and (Map[NewX, NewY].Typ <> Kasten) then begin
    oldTyp:=Map[OldX, OldY].Typ;
    oldTex:=Map[OldX, OldY].Tex;

    kx:=NewX+DirX;
    ky:=NewY+DirY;

    ax:=Kx;
    ay:=Ky;
    if Map[kx, ky].Typ = Ziel then begin
      oldTyp2:=Map[kx,ky].Typ;
      oldTex2:=Map[Kx,ky].Tex;
    end;

    Map[OldX, OldY].Typ:=None;
    Map[OldX, OldY].Tex:=None;

    Map[NewX, NewY].Typ:=oldTyp;
    Map[NewX, NewY].Tex:=oldTex;

    if (oldTyp2 = Ziel) and (GoMovekiste = True) then begin
      ShowMessage(IntToStr(ax) + '\' + IntToStr(ay));
      GoMovekiste:=False;
      Map[ax, ay].Typ:=oldTyp2;
      Map[ax, ay].Tex:=oldTex2;
      oldTyp2:=-1;
    end;
  end;
end;

procedure TSokubahn.SetPlayerPos(NewX, NewY:integer);
begin
  if ( Map[Player.X+NewX,Player.Y+NewY].Typ <> Wand ) and ( Map[Player.X+NewX,Player.Y+NewY].Typ <> Kasten ) then begin
    Player.X:=Player.X+NewX;
    Player.Y:=Player.Y+NewY;
  end
  else begin
    if (Map[Player.X+NewX,Player.Y+NewY].Typ = Kasten) and (Map[Player.X+NewX+NewX,Player.Y+NewY+NewY].Typ <> Wand)then begin
      Player.X:=Player.X+NewX;
      Player.Y:=Player.Y+NewY;
      MoveKiste(Player.X+NewX,Player.Y+NewY,Player.X,Player.Y,NewX, NewY);
      GoMovekiste:=True;

    end;
  end;

end;


könntet ihr ihr einen "Logenschen Denkfehler" Sehen ?
es kann sich nur darum handel.

_________________
MFG
Michael Springwald, "kann kein englisch...."
Alni
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 205

Win 2000, XP, SuSe, Debian
D5 Prof, D7 Prof, Kylix
BeitragVerfasst: Mo 05.05.03 17:41 
Inwiefern funktioniert das denn nicht
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mo 05.05.03 17:44 
also ich "schiebe" einen stein über das ziel und das ziel verschindet nach dem ich wieder vom ziel wegbin.
mein ziel:
das ziel soll nicht verschwinden sondern wieder erstellt werden nachdem du das ziel verlassen(mit dem Player und der Kiste) hast....
und irgenwie bekomme ich es einfach nicht hin :(

_________________
MFG
Michael Springwald, "kann kein englisch...."
Alni
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 205

Win 2000, XP, SuSe, Debian
D5 Prof, D7 Prof, Kylix
BeitragVerfasst: Mo 05.05.03 18:13 
In MoveKiste schreibst du
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
    ax:=Kx; 
    ay:=Ky; 
    if Map[kx, ky].Typ = Ziel then begin 
      oldTyp2:=Map[kx,ky].Typ; 
      oldTex2:=Map[Kx,ky].Tex; 
    end;


Wenn ich richtig verstanden hab soll ax,ay die Position des Ziels speichern um es wieder herzustellen, dann müsstest du aber schreiben

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
    if Map[kx, ky].Typ = Ziel then begin 
      ax:=Kx; 
      ay:=Ky;
      oldTyp2:=Map[kx,ky].Typ; 
      oldTex2:=Map[Kx,ky].Tex; 
    end;


sonst überschreibst du die Variablen beim nächsten Aufruf von Movekiste bevor du sie brauchen konntest.

Oder hab ich da was falsch verstanden?
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Mo 05.05.03 18:16 
das wars nichts..... aber du hast es richtig verstanden :)
aber danke für den Tip....

_________________
MFG
Michael Springwald, "kann kein englisch...."