一直以来,weyl的复刻版就没有一个正经的船,取而代之的是主角像变形金刚一样的无限转变形态(人形-船-人-船。。。)
所以。。作为一个pascal语言的小白,我把船改了出来。。很简单的修改- -
先上效果图
贴源码- -- //判定主地图某个位置能否行走, 是否变成船
- //function in kys_main.pas
- function CanWalk(x, y: integer): boolean;
- begin
- if buildx[x, y] = 0 then
- canwalk := true
- else
- canwalk := false;
- //canwalk:=true; //This sentence is used to test.
- if (x <= 0) or (x >= 479) or (y <= 0) or (y >= 479) then
- canwalk := false;
- if (earth[x, y] = 838) or ((earth[x, y] >= 612) and (earth[x, y] <= 670)) then
- canwalk := false;
- if ((earth[x, y] >= 358) and (earth[x, y] <= 362)) or ((earth[x, y] >= 506) and (earth[x, y] <= 670)) or ((earth[x, y] >= 1016) and (earth[x, y] <= 1022)) then
- begin
- if(Inship = 1) then //isship
- canwalk :=true
- else
- if(x=shipy) and (y=shipx) then //touch ship?
- begin
- InShip := 1;
- canwalk :=true
- end
- else
- // InShip := 0; //option_explicit_ori_on
- canwalk :=false
- end
- else
- begin
- if(Inship = 1) then //isboat??
- begin
- shipy := Mx; //arrrive
- shipx := My;
- shipface := Mface
- end;
- InShip := 0;
- end
- end;
复制代码- //显示主地图场景于屏幕
- //[color=Red] procedure in kys_engine.pas[/color]
- procedure DrawMMap;
- var
- i1, i2, i, sum, x, y: integer;
- temp: array[0..479, 0..479] of smallint;
- pos: TPosition;
- begin
- if (SDL_MustLock(screen)) then
- begin
- if (SDL_LockSurface(screen) < 0) then
- begin
- MessageBox(0, PChar(Format('Can''t lock screen : %s', [SDL_GetError])), 'Error', MB_OK or MB_ICONHAND);
- exit;
- end;
- end;
- //由上到下绘制, 先绘制中心点靠上的建筑
- for sum := -29 to 40 do
- for i := -15 to 15 do
- begin
- i1 := Mx + i + (sum div 2);
- i2 := My - i + (sum - sum div 2);
- Pos := GetPositionOnScreen(i1, i2, Mx, My);
- if (i1 >= 0) and (i1 < 480) and (i2 >= 0) and (i2 < 480) then
- begin
- if (sum >= -27) and (sum <= 28) and (i >= -9) and (i <= 9) then
- begin
- DrawMPic(earth[i1, i2] div 2, pos.x, pos.y);
- if surface[i1, i2] > 0 then
- DrawMPic(surface[i1, i2] div 2, pos.x, pos.y);
- end;
- temp[i1, i2] := building[i1, i2];
- end
- else
- DrawMPic(0, pos.x, pos.y);
- end;
- //draw boat
- for sum := -29 to 40 do
- for i := -15 to 15 do
- begin
- i1 := Mx + i + (sum div 2);
- i2 := My - i + (sum - sum div 2);
- if (i1 = shipy) and (i2 = shipx) then
- if inship = 0 then
- begin
- Pos := GetPositionOnScreen(i1, i2, Mx, My);
- DrawMPic(3715 +4 * shipface, pos.x, pos.y);
- break;
- end
- end;
- for sum := -29 to 40 do
- for i := -15 to 15 do
- begin
- i1 := Mx + i + (sum div 2);
- i2 := My - i + (sum - sum div 2);
- if (i1 >= 0) and (i1 < 480) and (i2 >= 0) and (i2 < 480) then
- begin
- x := buildy[i1, i2];
- y := buildx[i1, i2];
- Pos := GetPositionOnScreen(x, y, Mx, My);
- if (buildx[i1, i2] > 0) and (((buildx[i1 - 1, i2 - 1] <> buildx[i1, i2]) and (buildx[i1 + 1, i2 + 1] <> buildx[i1, i2]))
- or ((buildy[i1 - 1, i2 - 1] <> buildy[i1, i2]) and (buildy[i1 + 1, i2 + 1] <> buildy[i1, i2]))) then
- begin
- if temp[x, y] > 0 then
- begin
- DrawMPic(building[x, y] div 2, pos.x, pos.y);
- temp[x, y] := 0;
- end;
- end;
- //如在水面上则绘制船的贴图
- if (i1 = Mx) and (i2 = My) then
- if (InShip = 0) then
- begin
- if still = 0 then
- DrawMPic(2500 + MFace * 7 + MStep, CENTER_X, CENTER_Y)
- else
- DrawMPic(2528 + Mface * 6 + MStep, CENTER_X, CENTER_Y)
- end
- else
- DrawMPic(3714 + MFace * 4 + (MStep + 1) div 2, CENTER_X, CENTER_Y);
- if (temp[i1, i2] > 0) and (buildx[i1, i2] = i2) then
- begin
- DrawMPic(building[i1, i2] div 2, pos.x, pos.y);
- temp[i1, i2] := 0;
- end;
- end;
- end;
- if (SDL_MustLock(screen)) then
- begin
- SDL_UnlockSurface(screen);
- end;
- //SDL_UpdateRect(screen, 0,0,screen.w,screen.h);
- end;
复制代码 我是小白- -。。第一次改代码。。肯定有错的,请大家指正~~
最后。。附上exe...要玩的可以下下来玩玩
[ 本帖最后由 黄顺坤 于 2009-7-22 21:28 编辑 ] |