⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.~pas

📁 类似超级玛丽模型之二(DELPHIX)
💻 ~PAS
📖 第 1 页 / 共 4 页
字号:

      If Not blockcrash Then
        For i := 1 To 31 Do
        Begin
          If (Not crashy) And (isblock(trunc(xx + 16), trunc(yy + dy) + i) > 0) Then crashy := true;
          If (Not crashx) And (dx <> 0) Then
            If (isblock(trunc(xx + dx + 16), trunc(yy) + i) > 0) Then
              If i >= 26 Then
              Begin
                If ((dy = 0) Or (crashy)) And (dvy >= 0) Then
                Begin
                  If crashy Then
                  Begin                 // flytte fyren opp 1 hakk
                    crashy := false;
                    moveobject(obj, 0, -1, level + 1);
                    crashy := true;
                  End Else moveobject(obj, 0, -1, level + 1);
                End Else crashx := true;
              End Else crashx := true;
        End;

      If crashx Then dx := 0 Else xx := xx + dx;
      If crashy Then dy := 0 Else yy := yy + dy;
    End;
  End;

Begin
  If level < 32 Then
    With game.objs[obj] Do
      If (dvx <> 0) Or (dvy <> 0) Then
      Begin

        If abs(dvx) > abs(dvy) Then len := abs(dvx) Else len := abs(dvy);
//   len:=sqrt(sqr(dvx)+sqr(dvy));

        dx := dvx / len;
        dy := dvy / len;
        For l := 1 To trunc(len) Do movestep;
        dx := dx * frac(len);
        dy := dy * frac(len);
        movestep;
      End;
End;


Procedure TMainForm.ProcessObjs;
Var da, aa, i       : integer;

Begin
  For i := 0 To length(game.objs) - 1 Do
    With game.objs[i] Do
      If (typo <> 0) Then
        If (xx - game.scrollx > -100) And (xx - game.scrollx < mainform.dxdraw1.width + 100) And
          (yy - game.scrolly > -100) And (yy - game.scrolly < mainform.dxdraw1.height + 100) Or (typo = 4) Then
        Begin


          currentobj := i;
          invince := 0;
          If abs(vx) < 0.15 Then vx := 0; {}
{  if abs(vy)<0.25 then vy:=0;{}
          vx := vx + ax;
          vy := vy + ay;
          If typo = 30 Then ay := 1.20;

          aa := isblock(trunc(xx + 16), trunc(yy + 16));
          If (-aa >= 5 * 16) And (-aa < 8 * 16) Then Begin;
            If vy > 0 Then vy := vy / 2;
            vx := vx / 1.3;
            ay := 0.61;
          End Else
            If (vy > 1) And (length(tag) = 3) Then
              If (tag[1] + tag[2] = 'H0') Then
              Begin
                vy := vy / 1.2;
                ay := 0.51;
                tag[3] := inttostr((strtoint(tag[3]) + 1) Mod 4)[1];
              End;

          If vy > 12 Then vy := 12;
          If vy < -20 Then vy := -20;


          crashx := false;
          crashy := false;



          If typo = 4 Then
          Begin
            ay := 0;
            ax := 0;
 // Oppover/Nedover/Venstre/H鴜re
            If (trunc(xx) Shr 5 Shl 5 = trunc(xx)) Or (trunc(yy) Shr 5 Shl 5 = trunc(yy)) Then
            Begin
              da := -isblock(trunc(xx + 8), trunc(yy + 8));
              If da = 15 Then tag := 'H';
              If da = 12 Then tag := 'N';
              If da = 14 Then tag := 'V';
              If da = 13 Then tag := 'O';

              If da = 8 Then tag := 'NH';
              If da = 9 Then tag := 'OV';
              If da = 10 Then tag := 'NV';
              If da = 11 Then tag := 'OH';
            End;

            If tag = 'H' Then Begin;
              vx := liftspeed;
              vy := 0;
            End;
            If tag = 'V' Then Begin;
              vx := -liftspeed;
              vy := 0;
            End;
            If tag = 'O' Then Begin;
              vx := 0;
              vy := -liftspeed;
            End;
            If tag = 'N' Then Begin;
              vx := 0;
              vy := liftspeed;
            End;

            If tag = 'NH' Then Begin;
              vx := liftspeed;
              vy := liftspeed;
            End;
            If tag = 'OV' Then Begin;
              vx := -liftspeed;
              vy := -liftspeed;
            End;
            If tag = 'NV' Then Begin;
              vx := -liftspeed;
              vy := liftspeed;
            End;
            If tag = 'OH' Then Begin;
              vx := liftspeed;
              vy := -liftspeed;
            End;


            ax := 0;
            ay := 0;
          End;


          ox := xx;
          oy := yy;
          ovy := vy;
          If gravity Then ay := 0.6 Else ay := 0; // gravity
          MoveObject(i, vx, vy, 0);
//  if not crashx then
          vx := xx - ox;
//  if ovy=vy) and (not crashy) then
          vy := yy - oy;

          If crashx Then vx := 0;
          If crashy Then vy := 0;

          ax := 0;
          py := 0;

          If typo = 78 Then
          Begin
//    game.objs[handl].gravity:=false;
            py := -sin((xx * 0.77 + yy * 0.77 + stall) / 32 * 3.14) * 4;
            inc(stall);
          End;


          If (typo = 40) Or (typo = 41) Then
          Begin
            If stall < 50 Then inc(stall);
            py := -sin(stall / (8) * 3.14) * 4 * (50 - stall) / 50;
            ay := 0;
          End;




          If istrampo Then              // (trampo topp)
          Begin
            If stall < 100 Then inc(stall);
            py := sin(stall / (8) * 3.14) * 6 * (100 - stall) / 100 + 3;
          End;


          If typo = 1 Then
          Begin                         //Joffa da man
            If (yy > game.level.info.height * 32) Then killjoffa(i, i);
            If isbonus(round(xx), round(yy)) <> -1 Then
              With game.objs[isbonus(round(xx), round(yy))] Do
              Begin
                blockcrash := false;
                If (pic >= -4) And (pic <= -2) Then
                Begin
                  game.objs[i].tag := 'H' + tag + '1';
                  PlaySoundFX(xx, yy, 2);
                End Else PlaySoundFX(xx, yy, 3);

                typo := 98;
                stall := 255;
                invince := 255;
                vy := -2;
              End;
            If stall = 0 Then
            Begin
              Case isblock(trunc(xx + 16), trunc(yy + 32)) Of
                8 * 16..8 * 16 + 15:
                  Begin
                    killjoffa(i, i);
//       if tag='' then typo:=99 else tag:='';
//       pic:=8; stall:=255; vy:=-8;
                  End;
              End;
              Case isblock(trunc(xx + 16), trunc(yy - 1)) Of
                8 * 16..8 * 16 + 15:
                  Begin
                    killjoffa(i, i);
                  End;
              End;
            End;

            If stall > 0 Then dec(stall);
            If stall Shr 4 Shl 4 = stall Shr 3 Shl 3 Then invince := 128 Else invince := 0;
            If stall = 0 Then invince := 0;
            If length(tag) = 3 Then
              If (tag[1] = 'H') And (tag[2] <> '0') Then
              Begin
                tag[3] := inttostr((strtoint(tag[3]) + 1) Mod 4)[1];
              End;
//   if invince>0 then dec(invince);
   // player
            If vy > 2 Then If vy > 3 Then pic := 7 Else pic := 0;
            If vy < -2 Then If vy < 3 Then pic := 6 Else pic := 0;
          End;


          If typo = 30 Then
          Begin
            If crashx Then              //typo:=0;
              direction := integer(direction = 0);
            If direction = 0 Then vx := 12 Else vx := -12;
            ax := 0;
            If (isblock(trunc(xx + 12), trunc(vy + yy + 33)) > 0) Or
              (isblock(trunc(xx + 31 - 12), trunc(vy + yy + 33)) > 0) Then ay := -8;
            dec(stall, 4);
            invince := stall;
            If stall <= 0 Then typo := 0;
          End;
// ai
          If typo >= 100 Then
          Begin
            pic := pic - (typo - 100 + 7) * 16;
            If (random(4) = 0) And (crashx) Then direction := integer(direction = 0);

            If isblock(trunc(xx + 16), trunc(yy + 16)) = -15 Then direction := 0;
            If isblock(trunc(xx + 16), trunc(yy + 16)) = -14 Then direction := 1;

            If (isblock(trunc(xx + 16), trunc(vy + yy + 33)) > 0) Then
              If (typo = 103) And (random(4) = 0) Then Begin;
                ay := -6;
                PlaySoundFX(xx, yy, 0);
              End;


            If isblock(trunc(xx + 16), trunc(yy + 16)) = -13 Then
              If (isblock(trunc(xx + 16), trunc(vy + yy + 31)) > 0) Then Begin;
                vy := 0;
                ay := -8;
                PlaySoundFX(xx, yy, 0);
              End;

            If (stall = -500) Then stall := 20;

            If stall <= 0 Then
            Begin
//   if (crashy) and (random(5)=1) then stall:=20;
              If random(5) * random(5) * random(5) * random(5) = 1 Then stall := 20;
              If (random(5) * random(5) * random(5) = 1) Then
                If (isblock(trunc(xx + 16), trunc(vy + yy + 33)) > 0) Then Begin;
                  ay := -6;
                  PlaySoundFX(xx, yy, 0);
                End;

//
//   if direction=1 then begin;ax:=-0.35;end;
//   if direction=0 then begin;ax:=0.35;end;
              ax := 0.17;
              If typo = 104 Then ax := 0.18;
              If typo = 100 Then ax := 0.16;
              If typo = 102 Then ax := 0.19;

              ax := ax * (1 - direction * 2);
            End;
            dec(stall);

//  if invince>0 then dec(invince);
            If vx = 0 Then pic := 0 Else
            Begin
              pic := pic + 0.2;
              If pic >= 6 Then pic := 1;
            End;
            If vy > 2 Then If vy > 3 Then pic := 7 Else pic := 0;
            If vy < -2 Then If vy < 3 Then pic := 6 Else pic := 0;
            If (stall > 0) And (tag <> 'D谼') Then pic := 9;

            pic := pic + (typo - 100 + 7) * 16;
            If typo = 102 Then Begin;
              vy := 0;
              ay := 0;
            End;
          End;

          aa := isblock(trunc(xx + 16), trunc(yy + 16));
          If (-aa >= 5 * 16) And (-aa < 8 * 16) Then invince := 128;

          If typo = 1 Then
            If isdoor(round(xx), round(yy)) <> -1 Then
              LoadLevel(game.level.filename + game.objs[isdoor(round(xx), round(yy))].tag);


          If typo = 99 Then
          Begin
            If stall > 0 Then dec(stall, 3);
            If stall <= 0 Then typo := 0;
            If invince < stall Then invince := stall;
          End;

          If typo = 98 Then
          Begin
            vy := -2;
            If stall > 0 Then dec(stall, 4);
            If stall <= 0 Then typo := 0;
            If invince < stall Then invince := stall;
          End;

//  if typo<>4 then
          If crashy Then
          Begin
            If (typo = 1) And (pic = 7) Then vx := vx * 0.93
            Else vx := vx * 0.90;

          End Else vx := vx * 0.92;


{  if vy>1 then vy:=vy-0.10;
  if vy<-1 then vy:=vy+0.10;{}
        End;
End;

//var j,jj : integer;

Procedure ObjDraw;
Var i               : integer;
Begin
  For i := 0 To length(game.objs) - 1 Do
    With game.objs[i] Do
      If (typo <> 0) Then
        If (pic >= 0) Then
        Begin
          If (invince = 0) Then
            mainform.dximagelist1.items[2 + direction].Draw(mainform.dxdraw1.surface, trunc(xx) - game.scrollx, trunc(yy + py) - game.scrolly, trunc(pic + 0))
          Else
            mainform.dximagelist1.items[2 + direction].drawalpha(mainform.dxdraw1.surface, bounds(trunc(xx) - game.scrollx, trunc(yy + py) - game.scrolly, 32, 32), trunc(pic + 0), invince);

// Helmet draw
          If typo = 1 Then
          Begin
            If length(tag) = 3 Then
              If tag[1] = 'H' Then
              Begin
                mainform.dximagelist1.items[2 + direction].draw(mainform.dxdraw1.surface, trunc(xx) - game.scrollx, trunc(yy + py) - game.scrolly, 19);
                mainform.dximagelist1.items[2 + direction].draw(mainform.dxdraw1.surface, trunc(xx) - game.scrollx, trunc(yy + py) - game.scrolly - 32, 16 * 3 + strtoint(tag[2]) * 4 + strtoint(tag[3]));
              End;
          End;
        End Else                        //heiser
          mainform.dximagelist1.items[1 + direction].draw(mainform.dxdraw1.surface, trunc(xx) - game.scrollx, trunc(yy + py) - game.scrolly, trunc(-pic + 0))
End;




Procedure Resetlevel;
Var l, xx, yy       : integer;
Begin
  For l := 0 To game.level.info.layers - 1 Do
    For xx := 0 To game.level.info.width - 1 Do
      For yy := 0 To game.level.info.height - 1 Do
        game.level.l[l][xx, yy] := -1;
End;

Procedure ResetObjs;
Var i               : integer;
Begin
  For i := 0 To length(game.objs) - 1 Do
  Begin
    zeromemory(@game.objs[i], sizeof(game.objs[i]));
  End;
End;


Procedure BackgroundDraw(scrollx, scrolly, layer: integer);
Var dx, dy, sx, sy, xx, yy, w, h: integer;
  aa                : smallint;
Begin
  If layer = 0 Then
    If game.level.info.scrollbackground > 0 Then
    Begin
      w := mainform.dximagelist1.items[0].width;
      h := mainform.dximagelist1.items[0].height;
      sx := scrollx Div game.level.info.scrollbackground;
      sy := scrolly Div game.level.info.scrollbackground;
      dx := (sx Div w) * w;
      dy := (sy Div h) * h;
//  mainform.dxdraw1.surface.bltfast(0,0,bounds(sx-dx,sy-dy,640-sx+dx,480-sy+dy),DDBLTFAST_NOCOLORKEY or DDBLTFAST_WAIT,mainform.dximagelist1.items[0].patternsurfaces[0]);//or DDBLTFAST_WAIT
      mainform.dximagelist1.items[0].draw(mainform.dxdraw1.surface, (-sx) + dx, -sy + dy, 0);
      mainform.dximagelist1.items[0].draw(mainform.dxdraw1.surface, (-sx) + dx + w, -sy + dy, 0);
      mainform.dximagelist1.items[0].draw(mainform.dxdraw1.surface, (-sx) + dx + w, -sy + dy + h, 0);
      mainform.dximagelist1.items[0].draw(mainform.dxdraw1.surface, (-sx) + dx, -sy + dy + h, 0);
    End Else
      mainform.dxdraw1.surface.bltfast(0, 0, bounds(0, 0, 640, 480), DDBLTFAST_NOCOLORKEY Or DDBLTFAST_WAIT, mainform.dximagelist1.items[0].patternsurfaces[0]); //or DDBLTFAST_WAIT


  sx := scrollx Shr 5;
  sy := scrolly Shr 5;
  dx := -scrollx + sx Shl 5;
  dy := -scrolly + sy Shl 5;
  For xx := 0 To mainform.dxdraw1.display.width Shr 5 + 1 Do
    For yy := 0 To mainform.dxdraw1.display.height Shr 5 + 1 Do
    Begin
      aa := game.level.l[layer][(xx + sx) Mod game.level.info.width, (yy + sy) Mod game.level.info.height];
      If aa > -1 Then
      Begin
        mainform.dximagelist1.items[1].draw(mainform.dxdraw1.surface, xx Shl 5 + dx, yy Shl 5 + dy, aa);
      End Else
        If (-aa >= 16 * 5) And (-aa < 16 * 8) Then
        Begin
          mainform.dximagelist1.items[1].draw(mainform.dxdraw1.surface, xx Shl 5 + dx, yy Shl 5 + dy, -aa);
        End;
    End;
End;



Procedure TMainForm.PlayerInput(PlayerObj: integer; dxistates: tdxinputstates);
Var aa              : integer;
Begin
  Slide := False;

  If game.objs[playerobj].typo <> 1 Then exit;
  If (isLeft In dxistates) And Not (isDown In dxistates) Then
  Begin
    game.objs[PlayerObj].ax := -0.35;
    game.objs[PlayerObj].direction := 1;
  End;
  If (isRight In dxistates) And Not (isDown In dxistates) Then
  Begin
    game.objs[PlayerObj].ax := 0.35;
    game.objs[PlayerObj].direction := 0;
  End;

  If ((isright In dxistates) Or (isleft In dxistates)) And Not (isdown In dxistates) Then
    With game.objs[PlayerObj] Do
//  if vx=0 then pic:=0 else
    Begin
      pic := pic + 0.35;
      If pic >= 6 Then pic := 1;
    End Else game.objs[playerobj].pic := 0;

  If (isUp In dxistates) Then
    With game.objs[PlayerObj] Do
//  if (isblock(trunc(xx+16),trunc(vy+yy+33))>0) then
// if {(ovy>0) and} (isblock(trunc(xx+16),trunc(yy+33))>0) then
      If (crashy) And (ovy >= 0) Then

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -