hedgewars/uVisualGears.pas
changeset 802 ed5450a89b96
child 803 3f73901a350a
equal deleted inserted replaced
801:0323e5c7ee54 802:ed5450a89b96
       
     1 (*
       
     2  * Hedgewars, a worms-like game
       
     3  * Copyright (c) 2008 Andrey Korotaev <unC0Rr@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    17  *)
       
    18 
       
    19 unit uVisualGears;
       
    20 interface
       
    21 uses SDLh, uConsts, uFloat;
       
    22 {$INCLUDE options.inc}
       
    23 const AllInactive: boolean = false;
       
    24 
       
    25 type PVisualGear = ^TVisualGear;
       
    26      TVGearStepProcedure = procedure (Gear: PVisualGear; Steps: Longword);
       
    27      TVisualGear = record
       
    28              NextGear, PrevGear: PVisualGear;
       
    29              State : Longword;
       
    30              X : hwFloat;
       
    31              Y : hwFloat;
       
    32              dX: hwFloat;
       
    33              dY: hwFloat;
       
    34              Kind: TVisualGearType;
       
    35              doStep: TVGearStepProcedure;
       
    36              end;
       
    37 
       
    38 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; dX, dY: hwFloat): PVisualGear;
       
    39 procedure ProcessVisualGears(Steps: Longword);
       
    40 procedure DrawVisualGears();
       
    41 //procedure AddClouds;
       
    42 
       
    43 var VisualGearsList: PVisualGear = nil;
       
    44 
       
    45 implementation
       
    46 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
       
    47      uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, GL;
       
    48 
       
    49 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
       
    50 begin
       
    51 end;
       
    52 
       
    53 // =============
       
    54 const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure =
       
    55                         (
       
    56                           @doStepFlake
       
    57                         );
       
    58 
       
    59 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; dX, dY: hwFloat): PVisualGear;
       
    60 var Result: PVisualGear;
       
    61 begin
       
    62 New(Result);
       
    63 FillChar(Result^, sizeof(TVisualGearType), 0);
       
    64 Result^.X:= int2hwFloat(X);
       
    65 Result^.Y:= int2hwFloat(Y);
       
    66 Result^.Kind := Kind;
       
    67 Result^.dX:= dX;
       
    68 Result^.dY:= dY;
       
    69 Result^.doStep:= doStepHandlers[Kind];
       
    70 
       
    71 if VisualGearsList <> nil then
       
    72    begin
       
    73    VisualGearsList^.PrevGear:= Result;
       
    74    Result^.NextGear:= VisualGearsList
       
    75    end;
       
    76 VisualGearsList:= Result;
       
    77 
       
    78 AddVisualGear:= Result
       
    79 end;
       
    80 
       
    81 
       
    82 procedure ProcessVisualGears(Steps: Longword);
       
    83 var Gear, t: PVisualGear;
       
    84 begin
       
    85 t:= VisualGearsList;
       
    86 while t <> nil do
       
    87       begin
       
    88       Gear:= t;
       
    89       t:= Gear^.NextGear;
       
    90       Gear^.doStep(Gear, Steps)
       
    91       end
       
    92 end;
       
    93 
       
    94 procedure DrawVisualGears();
       
    95 var Gear: PVisualGear;
       
    96 begin
       
    97 Gear:= VisualGearsList;
       
    98 while Gear <> nil do
       
    99       begin
       
   100       case Gear^.Kind of
       
   101 //           gtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, nil);
       
   102            vgtFlake: ;
       
   103               end;
       
   104       Gear:= Gear^.NextGear
       
   105       end;
       
   106 end;
       
   107 
       
   108 procedure AddClouds;
       
   109 var i: LongInt;
       
   110     dx, dy: hwFloat;
       
   111 begin(*
       
   112 for i:= 0 to cCloudsNumber do
       
   113     begin
       
   114     dx.isNegative:= random(2) = 1;
       
   115     dx.QWordValue:= random(214748364);
       
   116     dy.isNegative:= (i and 1) = 1;
       
   117     dy.QWordValue:= 21474836 + random(64424509);
       
   118     AddVisualGear( - cScreenWidth + i * ((cScreenWidth * 2 + 2304) div cCloudsNumber), -140,
       
   119              vgtCloud, dx, dy)
       
   120     end*)
       
   121 end;
       
   122 
       
   123 initialization
       
   124 
       
   125 finalization
       
   126 
       
   127 end.