Autor Beitrag
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Sa 12.03.05 17:52 
Hallo!
ich habe parrallel bzw zusammen mit larus ein snake mit editor geschrieben.
nun haben wird nach der einbindung eigener maps und dem bonus essen, den
fehler, dass das essen, ohne aufgesammelt zu werden, woanders wieder auftaucht.

Woran liegt das ?
Einloggen, um Attachments anzusehen!
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Do 17.03.05 08:53 
ihr habt in euren Timer folgendes stehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
  if BonusStay >= 5 then
      inc(BonusStay);
  if BonusStay > 34 then
    begin
      BonusStay:= 0;
      Map[BonusPos.X, BonusPos.Y]:= 0;
      BonusPos.X:= 0;
      BonusPos.Y:= 0;
      BonusExists:= false;
    end;

das ist für mich eine zeitschleife:
wenn der Punkt nicht innerhalbt einer gewissen zeit aufgesammelt wird, verschwindet er und taucht irgendwoander wieder auf das macht ihr mit MakeBonus etwas weiter unten im timer:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
      if BonusStay < 5 then
        inc(BonusStay);
      if (BonusStay = 5) and (BonusExists = false) then
        MakeBonus;


aber das er verschwindet ohne eingesammelt zu werden daran ist
if BonusStay > 34 then dieser block dran schuld(oder ich habe die frage falsch verstanden)

_________________
MFG
Michael Springwald, "kann kein englisch...."
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 17.03.05 15:07 
das soll so sein, das ist fürs bonus essen, das verschwindet, wenns nicht eingesammelt wird, aber das normale food springt einfach mal so woanders hin :idea:
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Do 17.03.05 15:37 
Ich habe jetzt mal die MakeFood procedure etwas veränder testes es mal hiermit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure MakeFood;
var
  i,rx,ry: integer;
begin
  rX:= random(40) + 1;
  rY:= random(40) + 1;
  for i:= 0 to snakelength do begin
    while ((Snake[i].X = rX) and (Snake[i].Y = rY)) or (Map[rx, rY] = Wall) do
      begin
        rX:= random(40) + 1;
        rY:= random(40) + 1;
      end;
  end;
  FoodPos.X:=rx;
  FoodPos.Y:=ry;
  map[FoodPos.x, FoodPos.y]:= food;
end;

hatte nämlich folgende vermutung:
jedes mal wenn diese procedure eine neues positions aussucht siehst du das ja am bildschrim, muss nicht so sein, und jetzt ist diese möglichkeit ausgeschloßen.... und die esten beiden wihle bedingungen habe ich in () zusammengefasst ist übersichtlicher(finde ich, aber mehr macht es glaube ich auch nicht aus)

_________________
MFG
Michael Springwald, "kann kein englisch...."
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 17.03.05 15:38 
es muss ja irgendwie an den maps liegen, vorher ging es ja :?

kommt in seltenen fällen immer noch vor :cry:
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 05.04.05 14:29 
habs behoben, zwar konnte ich die ursache des fehlerhaften aufrufs von makefood nicht entdecken, aber hier ist der bugfix:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
  if (Map[FoodPos.X, FoodPos.Y] <> food) then begin
    BonusPos.X:= random(40) + 1;
    BonusPos.Y:= random(40) + 1;
    for i:= 0 to snakelength do
      while (Snake[i].X = BonusPos.X) and (Snake[i].Y = BonusPos.Y) or (Map[BonusPos.x, BonusPos.Y] = Wall) or (Map[BonusPos.x, BonusPos.Y] = Food) do
        begin
          BonusPos.X:= random(40) + 1;
          BonusPos.Y:= random(40) + 1;
        end;
    map[BonusPos.x, BonusPos.y]:= bonus;
    BonusExists:= true;
  end; 

das gleiche bei makebonus ^^