263 procedure DrawHH(Gear: PGear; ox, oy: LongInt); |
263 procedure DrawHH(Gear: PGear; ox, oy: LongInt); |
264 var i, t: LongInt; |
264 var i, t: LongInt; |
265 amt: TAmmoType; |
265 amt: TAmmoType; |
266 sign, hx, hy, tx, ty, sx, sy, m: LongInt; // hedgehog, crosshair, temp, sprite, direction |
266 sign, hx, hy, tx, ty, sx, sy, m: LongInt; // hedgehog, crosshair, temp, sprite, direction |
267 dx, dy, ax, ay, aAngle, dAngle, hAngle, lx, ly: real; // laser, change |
267 dx, dy, ax, ay, aAngle, dAngle, hAngle, lx, ly: real; // laser, change |
|
268 wraps: LongWord; // numbe of wraps for laser in world wrap |
268 defaultPos, HatVisible: boolean; |
269 defaultPos, HatVisible: boolean; |
269 HH: PHedgehog; |
270 HH: PHedgehog; |
270 CurWeapon: PAmmo; |
271 CurWeapon: PAmmo; |
271 iceOffset:Longint; |
272 iceOffset:Longint; |
272 r:TSDL_Rect; |
273 r:TSDL_Rect; |
405 |
406 |
406 tx:= round(lx); |
407 tx:= round(lx); |
407 ty:= round(ly); |
408 ty:= round(ly); |
408 hx:= tx; |
409 hx:= tx; |
409 hy:= ty; |
410 hy:= ty; |
410 while ((ty and LAND_HEIGHT_MASK) = 0) and |
411 wraps:= 0; |
411 ((tx and LAND_WIDTH_MASK) = 0) and |
412 while ((Land[ty, tx] and lfAll) = 0) do |
412 (Land[ty, tx] = 0) do // TODO: check for constant variable instead |
413 begin |
413 begin |
414 if wraps > cMaxLaserSightWraps then |
|
415 break; |
414 lx:= lx + ax; |
416 lx:= lx + ax; |
415 ly:= ly + ay; |
417 ly:= ly + ay; |
416 tx:= round(lx); |
418 tx:= round(lx); |
417 ty:= round(ly) |
419 ty:= round(ly); |
418 end; |
420 // reached edge of land. |
419 // reached edge of land. assume infinite beam. Extend it way out past camera |
421 if ((ty and LAND_HEIGHT_MASK) <> 0) then |
420 if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then |
422 begin |
421 begin |
423 // assume infinite beam. Extend it way out past camera |
422 tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2)); |
424 tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2)); |
423 ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2)); |
425 ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2)); |
424 end; |
426 break; |
425 |
427 end; |
426 //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then |
428 |
427 begin |
429 if ((sign*m < 0) and (tx < LeftX)) or ((sign*m > 0) and (tx >= RightX)) then |
428 DrawLine(hx, hy, tx, ty, 1.0, $FF, $00, $00, $C0); |
430 if (WorldEdge = weWrap) then |
429 end; |
431 // wrap beam |
|
432 begin |
|
433 if (sign*m) < 0 then |
|
434 lx:= RightX - (ax - (lx - LeftX)) |
|
435 else |
|
436 lx:= LeftX + (ax - (RightX - lx)); |
|
437 tx:= round(lx); |
|
438 inc(wraps); |
|
439 end |
|
440 else if (WorldEdge = weBounce) then |
|
441 // just stop |
|
442 break; |
|
443 |
|
444 if ((tx and LAND_WIDTH_MASK) <> 0) then |
|
445 begin |
|
446 if (WorldEdge <> weWrap) and (WorldEdge <> weBounce) then |
|
447 // assume infinite beam. Extend it way out past camera |
|
448 begin |
|
449 tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2)); |
|
450 ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2)); |
|
451 end; |
|
452 break; |
|
453 end; |
|
454 end; |
|
455 |
|
456 DrawLineWrapped(hx, hy, tx, ty, 1.0, (sign*m) < 0, wraps, $FF, $00, $00, $C0); |
430 end; |
457 end; |
431 // draw crosshair |
458 // draw crosshair |
432 CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle)); |
459 CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle)); |
433 CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle)); |
460 CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle)); |
434 |
461 |