Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
--- a/hedgewars/uGearsHandlersMess.pas Sun Dec 08 16:04:40 2013 -0500
+++ b/hedgewars/uGearsHandlersMess.pas Mon Dec 09 10:59:38 2013 -0500
@@ -281,15 +281,18 @@
isFalling: boolean;
//tmp: QWord;
tX, tdX, tdY: hwFloat;
- collV, collH: LongInt;
+ collV, collH, gX, gY: LongInt;
land, xland: word;
+ boing: PVisualGear;
begin
tX:= Gear^.X;
+ gX:= hwRound(Gear^.X);
+ gY:= hwRound(Gear^.Y);
if (Gear^.Kind <> gtGenericFaller) and WorldWrap(Gear) and (WorldEdge = weWrap) and (Gear^.AdvBounce <> 0) and
((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, -1) <> 0)) then
begin
Gear^.X:= tX;
- Gear^.dX.isNegative:= (hwRound(tX) > leftX+Gear^.Radius*2)
+ Gear^.dX.isNegative:= (gX > leftX+Gear^.Radius*2)
end;
// clip velocity at 2 - over 1 per pixel, but really shouldn't cause many actual problems.
@@ -298,7 +301,7 @@
if Gear^.dY.Round > 2 then
Gear^.dY.QWordValue:= 8589934592;
- if (Gear^.State and gstSubmersible <> 0) and (hwRound(Gear^.Y) > cWaterLine) then
+ if (Gear^.State and gstSubmersible <> 0) and (gY > cWaterLine) then
begin
Gear^.dX:= Gear^.dX * _0_999;
Gear^.dY:= Gear^.dY * _0_999
@@ -311,8 +314,8 @@
tdY := Gear^.dY;
// might need some testing/adjustments - just to avoid projectiles to fly forever (accelerated by wind/skips)
- if (hwRound(Gear^.X) < min(LAND_WIDTH div -2, -2048))
- or (hwRound(Gear^.X) > max(LAND_WIDTH * 3 div 2, 6144)) then
+ if (gX < min(LAND_WIDTH div -2, -2048))
+ or (gX > max(LAND_WIDTH * 3 div 2, 6144)) then
Gear^.State := Gear^.State or gstCollision;
if Gear^.dY.isNegative then
@@ -434,11 +437,24 @@
if ((xland or land) and lfBouncy <> 0) and (Gear^.dX.QWordValue < _0_15.QWordValue) and (Gear^.dY.QWordValue < _0_15.QWordValue) then
Gear^.State := Gear^.State or gstCollision;
- if ((xland or land) and lfBouncy <> 0) and
- (((Gear^.Radius < 3) and (Gear^.dY < -_0_1)) or
- ((Gear^.Radius >= 3) and
- ((Gear^.dX.QWordValue > _0_15.QWordValue) or (Gear^.dY.QWordValue > _0_15.QWordValue)))) then
+ if ((xland or land) and lfBouncy <> 0) and (Gear^.Radius >= 3) and
+ ((Gear^.dX.QWordValue > _0_15.QWordValue) or (Gear^.dY.QWordValue > _0_15.QWordValue)) then
+ begin
+ boing:= AddVisualGear(gX, gY, vgtStraightShot, 0, false, 1);
+ if boing <> nil then
+ with boing^ do
+ begin
+ Angle:= random(360);
+ dx:= 0;
+ dy:= 0;
+ FrameTicks:= 200;
+ tX:= _0;
+ tX.QWordValue:= Gear^.dY.QWordValue + Gear^.dX.QWordValue;
+ Scale:= hwFloat2Float(Gear^.Density * tX) / 1.5;
+ State:= ord(sprBoing)
+ end;
PlaySound(sndMelonImpact, true)
+ end
else if (Gear^.nImpactSounds > 0) and
(Gear^.State and gstCollision <> 0) and
(((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or (Gear^.State and gstMoving <> 0)) and
--- a/hedgewars/uTypes.pas Sun Dec 08 16:04:40 2013 -0500
+++ b/hedgewars/uTypes.pas Mon Dec 09 10:59:38 2013 -0500
@@ -86,7 +86,7 @@
sprHandResurrector, sprCross, sprAirDrill, sprNapalmBomb,
sprBulletHit, sprSnowball, sprHandSnowball, sprSnow,
sprSDFlake, sprSDWater, sprSDCloud, sprSDSplash, sprSDDroplet, sprTardis,
- sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar, sprIceTexture, sprIceGun, sprFrozenHog, sprAmRubber
+ sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar, sprIceTexture, sprIceGun, sprFrozenHog, sprAmRubber, sprBoing
);
// Gears that interact with other Gears and/or Land
--- a/hedgewars/uVariables.pas Sun Dec 08 16:04:40 2013 -0500
+++ b/hedgewars/uVariables.pas Mon Dec 09 10:59:38 2013 -0500
@@ -684,7 +684,9 @@
(FileName: 'amFrozenHog'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
Width: 64; Height: 64; imageWidth: 64; imageHeight: 64; saveSurf: false; priority: tpLow; getDimensions: false; getImageDimensions: false), // sprFrozenHog
(FileName: 'amRubber'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil;
- Width: 160; Height:160; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpMedium; getDimensions: false; getImageDimensions: true) // sprAmRubber
+ Width: 160; Height:160; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpMedium; getDimensions: false; getImageDimensions: true), // sprAmRubber
+ (FileName: 'boing'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
+ Width: 101; Height: 97; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpLow; getDimensions: false; getImageDimensions: false) // sprBoing
);
const
--- a/hedgewars/uVisualGears.pas Sun Dec 08 16:04:40 2013 -0500
+++ b/hedgewars/uVisualGears.pas Mon Dec 09 10:59:38 2013 -0500
@@ -219,6 +219,13 @@
else
DrawSprite(sprDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);
vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
+ vgtStraightShot: begin
+ if Gear^.dX < 0 then
+ i:= -1
+ else
+ i:= 1;
+ DrawTextureRotatedF(SpritesData[TSprite(Gear^.State)].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, i, SpritesData[TSprite(Gear^.State)].Width, SpritesData[TSprite(Gear^.State)].Height, Gear^.Angle);
+ end;
end;
//if (Gear^.Tint <> $FFFFFFFF) or tinted then untint;
if (Gear^.Tint <> $FFFFFFFF) then
--- a/hedgewars/uVisualGearsList.pas Sun Dec 08 16:04:40 2013 -0500
+++ b/hedgewars/uVisualGearsList.pas Mon Dec 09 10:59:38 2013 -0500
@@ -24,7 +24,8 @@
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline;
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord): PVisualGear; inline;
-function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear;
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear; inline;
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean; Layer: LongInt): PVisualGear;
procedure DeleteVisualGear(Gear: PVisualGear);
function VisualGearByUID(uid : Longword) : PVisualGear;
@@ -39,15 +40,20 @@
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline;
begin
- AddVisualGear:= AddVisualGear(X, Y, Kind, 0, false);
+ AddVisualGear:= AddVisualGear(X, Y, Kind, 0, false, -1);
end;
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord): PVisualGear; inline;
begin
- AddVisualGear:= AddVisualGear(X, Y, Kind, State, false);
+ AddVisualGear:= AddVisualGear(X, Y, Kind, State, false, -1);
end;
-function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear;
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear; inline;
+begin
+ AddVisualGear:= AddVisualGear(X, Y, Kind, State, Critical, -1);
+end;
+
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean; Layer: LongInt): PVisualGear;
var gear: PVisualGear;
t: Longword;
sp: real;
@@ -401,6 +407,8 @@
vgtCircle: gear^.Layer:= 2
end;
+if Layer <> -1 then gear^.Layer:= Layer;
+
if VisualGearLayers[gear^.Layer] <> nil then
begin
VisualGearLayers[gear^.Layer]^.PrevGear:= gear;
Binary file share/hedgewars/Data/Graphics/boing.png has changed