Unit SackClass

The Sack object for the Giant Sack of Catnip

Declaration of routine with many parameters

Procedure draw (with 10 parameters):

{Draws the sprite with the specified coordinates and transformations. 'alpha' is only  
for a convenience if you want to use it in a custom draw procedure where you send the
alpha value as a shader uniform. The frame is used when using spritesheets. You can override
the shader bound to the sprite or globally with 'shaderOverride' and override the drawing
procedure with 'customDrawFunctionOverride'}
procedure draw(x, y, depth : real; rotation : real = 0.0; xScale : real = 1.0; yScale : real = 1.0;
               alpha : real = 1.0; frame : real = 1.0; shaderOverride : PShader = nil;
               customDrawFunctionOverride : customDrawFunctionType = nil);      

The unit

{
   Copyright (c) 2011 Max Foster

   http://creativecommons.org/licenses/by/3.0/
}
unit SackClass;

{$mode objfpc}{$H+}

interface

uses 
  GameActorClass;

type
  //The Giant Sack of Catnip
  PSack = ^TSack;
  TSack = object(TGameActor)
    constructor create(destX, destZ, newRotation : real);
    destructor destroy; virtual;
    procedure update; virtual;
  end;

procedure initSack;
procedure freeSack;

implementation

uses 
  GraphicalAssetClasses, GlobalGameVariables;

var
  sackModel : PModel;

procedure initSack;
begin
  sackModel := new(PModel, create('sack', 'assets/models/sack/', 'sack.smo'));
end;

procedure freeSack;
begin
  dispose(sackModel, destroy);
end;

constructor TSack.create(destX, destZ, newRotation : real);
begin
  TGameObject.create('sack', destX, 0, destZ, sackModel);
  yRotation_ := newRotation;
  scale(3, 3, 3);
  dieFlag := false;
  radius := 70;
  yRotation_ := 270;
  initialHealth := SACK_HEALTH;
  health := initialHealth;
  attributes := [castsShadow];
  collidables.add(@self);
  width_ := 3;
end;

destructor TSack.destroy;
begin
  TGameObject.destroy;
end;

procedure TSack.update;
begin
  if (visible) then
    begin
      shadowCircle^.draw(x_, 0, z_, yRotation, width_, width_);
      draw(true, true);
    end;
end;

end.
Programming - a skill for life!

by Max Foster: L6 Age ~17