Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
--- a/hedgewars/CMakeLists.txt Fri Mar 07 14:47:03 2008 +0000
+++ b/hedgewars/CMakeLists.txt Fri Mar 07 17:43:05 2008 +0000
@@ -32,6 +32,7 @@
uStore.pas
uTeams.pas
uTriggers.pas
+ uVisualGears.pas
uWorld.pas
CCHandlers.inc
GSHandlers.inc
--- a/hedgewars/hwengine.dpr Fri Mar 07 14:47:03 2008 +0000
+++ b/hedgewars/hwengine.dpr Fri Mar 07 17:43:05 2008 +0000
@@ -31,6 +31,7 @@
uWorld in 'uWorld.pas',
uIO in 'uIO.pas',
uGears in 'uGears.pas',
+ uVisualGears in 'uVisualGears.pas',
uConsole in 'uConsole.pas',
uKeys in 'uKeys.pas',
uTeams in 'uTeams.pas',
--- a/hedgewars/uConsts.pas Fri Mar 07 14:47:03 2008 +0000
+++ b/hedgewars/uConsts.pas Fri Mar 07 17:43:05 2008 +0000
@@ -51,6 +51,8 @@
gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder,
gtTeleport, gtSmallDamage, gtSwitcher, gtTarget);
+ TVisualGearType = (vgtFlake);
+
TGearsType = set of TGearType;
TSound = (sndGrenadeImpact, sndExplosion, sndThrowPowerUp, sndThrowRelease,
--- a/hedgewars/uGears.pas Fri Mar 07 14:47:03 2008 +0000
+++ b/hedgewars/uGears.pas Fri Mar 07 17:43:05 2008 +0000
@@ -191,7 +191,7 @@
Result^.Hedgehog:= CurrentHedgehog;
Result^.IntersectGear:= CurrentHedgehog^.Gear
end;
-
+
case Kind of
gtCloud: Result^.Z:= High(Result^.Z);
gtAmmo_Bomb: begin
--- a/hedgewars/uLandObjects.pas Fri Mar 07 14:47:03 2008 +0000
+++ b/hedgewars/uLandObjects.pas Fri Mar 07 17:43:05 2008 +0000
@@ -379,6 +379,7 @@
end;
end;
+// sprays
Readln(f, SprayObjects.Count);
for i:= 0 to Pred(SprayObjects.Count) do
begin
@@ -391,6 +392,9 @@
ReadLn(f, Maxcnt)
end;
end;
+
+// snowflakes
+//Readln(f, );
Close(f);
{$I+}
TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true)
--- a/hedgewars/uMisc.pas Fri Mar 07 14:47:03 2008 +0000
+++ b/hedgewars/uMisc.pas Fri Mar 07 17:43:05 2008 +0000
@@ -95,7 +95,7 @@
AttackBar: LongInt = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
function hwSign(r: hwFloat): LongInt;
-function Min(a, b: LongInt): LongInt;
+function Min(a, b: LongInt): LongInt;
function Max(a, b: LongInt): LongInt;
function rndSign(num: hwFloat): hwFloat;
procedure OutError(Msg: String; isFatalError: boolean);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/uVisualGears.pas Fri Mar 07 17:43:05 2008 +0000
@@ -0,0 +1,127 @@
+(*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2008 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *)
+
+unit uVisualGears;
+interface
+uses SDLh, uConsts, uFloat;
+{$INCLUDE options.inc}
+const AllInactive: boolean = false;
+
+type PVisualGear = ^TVisualGear;
+ TVGearStepProcedure = procedure (Gear: PVisualGear; Steps: Longword);
+ TVisualGear = record
+ NextGear, PrevGear: PVisualGear;
+ State : Longword;
+ X : hwFloat;
+ Y : hwFloat;
+ dX: hwFloat;
+ dY: hwFloat;
+ Kind: TVisualGearType;
+ doStep: TVGearStepProcedure;
+ end;
+
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; dX, dY: hwFloat): PVisualGear;
+procedure ProcessVisualGears(Steps: Longword);
+procedure DrawVisualGears();
+//procedure AddClouds;
+
+var VisualGearsList: PVisualGear = nil;
+
+implementation
+uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
+ uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, GL;
+
+procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
+begin
+end;
+
+// =============
+const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure =
+ (
+ @doStepFlake
+ );
+
+function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; dX, dY: hwFloat): PVisualGear;
+var Result: PVisualGear;
+begin
+New(Result);
+FillChar(Result^, sizeof(TVisualGearType), 0);
+Result^.X:= int2hwFloat(X);
+Result^.Y:= int2hwFloat(Y);
+Result^.Kind := Kind;
+Result^.dX:= dX;
+Result^.dY:= dY;
+Result^.doStep:= doStepHandlers[Kind];
+
+if VisualGearsList <> nil then
+ begin
+ VisualGearsList^.PrevGear:= Result;
+ Result^.NextGear:= VisualGearsList
+ end;
+VisualGearsList:= Result;
+
+AddVisualGear:= Result
+end;
+
+
+procedure ProcessVisualGears(Steps: Longword);
+var Gear, t: PVisualGear;
+begin
+t:= VisualGearsList;
+while t <> nil do
+ begin
+ Gear:= t;
+ t:= Gear^.NextGear;
+ Gear^.doStep(Gear, Steps)
+ end
+end;
+
+procedure DrawVisualGears();
+var Gear: PVisualGear;
+begin
+Gear:= VisualGearsList;
+while Gear <> nil do
+ begin
+ case Gear^.Kind of
+// gtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, nil);
+ vgtFlake: ;
+ end;
+ Gear:= Gear^.NextGear
+ end;
+end;
+
+procedure AddClouds;
+var i: LongInt;
+ dx, dy: hwFloat;
+begin(*
+for i:= 0 to cCloudsNumber do
+ begin
+ dx.isNegative:= random(2) = 1;
+ dx.QWordValue:= random(214748364);
+ dy.isNegative:= (i and 1) = 1;
+ dy.QWordValue:= 21474836 + random(64424509);
+ AddVisualGear( - cScreenWidth + i * ((cScreenWidth * 2 + 2304) div cCloudsNumber), -140,
+ vgtCloud, dx, dy)
+ end*)
+end;
+
+initialization
+
+finalization
+
+end.