# HG changeset patch # User nemo # Date 1382212787 14400 # Node ID a5005b7ca305c249fab38702048e474efbaa9354 # Parent 485b424be76995228afd9812b9d612ec74cfe316 differentiate borders a bit diff -r 485b424be769 -r a5005b7ca305 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Sat Oct 19 00:42:24 2013 +0400 +++ b/hedgewars/uGearsHandlersMess.pas Sat Oct 19 15:59:47 2013 -0400 @@ -285,7 +285,7 @@ land: word; begin tX:= Gear^.X; - if WorldWrap(Gear) and (WorldEdge = weWrap) and (Gear^.AdvBounce <> 0) and + if (Gear^.Kind <> gtGenericFaller) and WorldWrap(Gear) and (WorldEdge = weWrap) and (Gear^.AdvBounce <> 0) and (TestCollisionXwithGear(Gear, 1) or TestCollisionXwithGear(Gear, -1)) then begin Gear^.X:= tX; diff -r 485b424be769 -r a5005b7ca305 hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Sat Oct 19 00:42:24 2013 +0400 +++ b/hedgewars/uGearsUtils.pas Sat Oct 19 15:59:47 2013 -0400 @@ -61,7 +61,6 @@ var doStepHandlers: array[TGearType] of TGearStepProcedure; - implementation uses uSound, uCollisions, uUtils, uConsts, uVisualGears, uAIMisc, uVariables, uLandGraphics, uScript, uStats, uCaptions, uTeams, uStore, @@ -1229,20 +1228,25 @@ begin if (hwRound(Gear^.X)-Gear^.Radius < leftX) then Gear^.X:= int2hwfloat(rightX-Gear^.Radius) - else Gear^.X:= int2hwfloat(leftX+Gear^.Radius) + else Gear^.X:= int2hwfloat(leftX+Gear^.Radius); + LeftImpactTimer:= 150; + RightImpactTimer:= 150 end else if WorldEdge = weBounce then begin if (hwRound(Gear^.X)-Gear^.Radius < leftX) then begin + LeftImpactTimer:= 333; Gear^.dX.isNegative:= false; Gear^.X:= int2hwfloat(leftX+Gear^.Radius) end else begin + RightImpactTimer:= 333; Gear^.dX.isNegative:= true; Gear^.X:= int2hwfloat(rightX-Gear^.Radius) - end + end; + PlaySound(sndMelonImpact); end else if WorldEdge = weSea then begin diff -r 485b424be769 -r a5005b7ca305 hedgewars/uRender.pas --- a/hedgewars/uRender.pas Sat Oct 19 00:42:24 2013 +0400 +++ b/hedgewars/uRender.pas Sat Oct 19 15:59:47 2013 -0400 @@ -44,6 +44,7 @@ procedure DrawCircle (X, Y, Radius, Width: LongInt); procedure DrawCircle (X, Y, Radius, Width: LongInt; r, g, b, a: Byte); +procedure DrawLine (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); procedure DrawFillRect (r: TSDL_Rect); procedure DrawHedgehog (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); @@ -348,6 +349,11 @@ DrawTexture(X - round(Source^.w * scale) div 2, Top, Source, scale) end; +procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; +begin +DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF) +end; + procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); var VertexBuffer: array [0..1] of TVertex2f; begin @@ -533,7 +539,7 @@ procedure Tint(r, g, b, a: Byte); inline; var nc, tw: Longword; begin - nc:= (a shl 24) or (b shl 16) or (g shl 8) or r; + nc:= (r shl 24) or (g shl 16) or (b shl 8) or a; if nc = lastTint then exit; @@ -554,6 +560,7 @@ procedure Tint(c: Longword); inline; begin + if c = lastTint then exit; Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF)) end; diff -r 485b424be769 -r a5005b7ca305 hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Sat Oct 19 00:42:24 2013 +0400 +++ b/hedgewars/uVariables.pas Sat Oct 19 15:59:47 2013 -0400 @@ -83,6 +83,8 @@ InputMask : LongWord; GameFlags : Longword; WorldEdge : TWorldEdge; + LeftImpactTimer : LongWord; + RightImpactTimer: LongWord; TurnTimeLeft : Longword; TagTurnTimeLeft : Longword; ReadyTimeLeft : Longword; @@ -2448,6 +2450,8 @@ InputMask := $FFFFFFFF; GameFlags := 0; WorldEdge := weNone; + LeftImpactTimer := 0; + RightImpactTimer := 0; TurnTimeLeft := 0; TagTurnTimeLeft := 0; cSuddenDTurns := 15; diff -r 485b424be769 -r a5005b7ca305 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sat Oct 19 00:42:24 2013 +0400 +++ b/hedgewars/uWorld.pas Sat Oct 19 15:59:47 2013 -0400 @@ -85,6 +85,7 @@ AmmoMenuTex : PTexture; HorizontOffset: LongInt; cOffsetY: LongInt; + WorldEnd, WorldFade : array[0..3] of HwColor4f; const cStereo_Sky = 0.0500; cStereo_Horizon = 0.0250; @@ -1130,7 +1131,7 @@ smallScreenOffset, offsetX, offsetY, screenBottom: LongInt; VertexBuffer: array [0..3] of TVertex2f; lw, lh: GLfloat; - WorldEnd, WorldFade : array[0..3] of HwColor4f; + c1, c2: LongWord; // couple of colours for edges begin if (cReducedQuality and rqNoBackground) = 0 then begin @@ -1241,15 +1242,6 @@ begin (* I think for a bounded world, will fill the left and right areas with black or something. Also will probably want various border effects/animations based on border type. Prob also, say, trigger a border animation timer on an impact. *) - FillChar(WorldFade, sizeof(WorldFade), 0); - WorldFade[0].a:= 255; - WorldFade[1].a:= 255; - FillChar(WorldEnd, sizeof(WorldEnd), 0); - WorldEnd[0].a:= 255; - WorldEnd[1].a:= 255; - WorldEnd[2].a:= 255; - WorldEnd[3].a:= 255; - glDisable(GL_TEXTURE_2D); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); @@ -1303,8 +1295,47 @@ glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required glEnable(GL_TEXTURE_2D); - DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 3.0, $FF, $00, $FF, $FF); - DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 3.0, $FF, $00, $FF, $FF); + // I'd still like to have things happen to the border when a wrap or bounce just occurred, based on a timer + if WorldEdge = weBounce then + begin + // could maybe alternate order of these on a bounce, or maybe drop the outer ones. + if LeftImpactTimer mod 2 = 0 then + begin + c1:= $5454FFFF; c2:= $FFFFFFFF; + end + else begin + c1:= $FFFFFFFF; c2:= $5454FFFF; + end; + DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 7.0, c1); + DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0, c2); + DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 3.0, c1); + DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 1.0, c2); + if RightImpactTimer mod 2 = 0 then + begin + c1:= $5454FFFF; c2:= $FFFFFFFF; + end + else begin + c1:= $FFFFFFFF; c2:= $5454FFFF; + end; + DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 7.0, c1); + DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, c2); + DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 3.0, c1); + DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 1.0, c2) + end + else if WorldEdge = weWrap then + begin + DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0, $A0, $30, $60, max(50,255-LeftImpactTimer)); + DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 2.0, $FF0000FF); + DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, $A0, $30, $60, max(50,255-RightImpactTimer)); + DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 2.0, $FF0000FF); + end + else + begin + DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0, $2E8B5780); + DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, $2E8B5780) + end; + if LeftImpactTimer > Lag then dec(LeftImpactTimer,Lag) else LeftImpactTimer:= 0; + if RightImpactTimer > Lag then dec(RightImpactTimer,Lag) else RightImpactTimer:= 0 end; // this scale is used to keep the various widgets at the same dimension at all zoom levels @@ -1971,6 +2002,16 @@ AMState:= AMHidden; isFirstFrame:= true; stereoDepth:= stereoDepth; // avoid hint + + FillChar(WorldFade, sizeof(WorldFade), 0); + WorldFade[0].a:= 255; + WorldFade[1].a:= 255; + FillChar(WorldEnd, sizeof(WorldEnd), 0); + WorldEnd[0].a:= 255; + WorldEnd[1].a:= 255; + WorldEnd[2].a:= 255; + WorldEnd[3].a:= 255; + end; procedure freeModule;