Friday, February 21, 2014

Time for triggers

The main change in this version is that I've added a triggering system, in the map editor one can add as many triggers as he wants.

There is a file for each level called


The values mean:
  1. TriggerId
  2. Trigger x position
  3. Trigger y position
  4. Function to call and parameters

Then there is class called TTriggerDispatcher which contains all possible methods to be called, for instance:

procedure TTriggerDispatcher.PlaySound(aX, aY: integer; const aName: string);
  TSoundDispatcher.Instance.Play('Sound\' + aName);

procedure TTriggerDispatcher.SpawnEntity(aX, aY, aOfsX, aOfsY, aEntity: integer);
  info: TMapInfo;
  entity: ISprite;

  info := TMapInfo.Create((aX + aOfsX) * FLayer.XTileSize, (aY + aOfsY) * FLayer.YTileSize, NO_TILE, aEntity);
  entity := TSpriteFactory.Instance.New(info);
  (entity as IWarp).Warp;

The way that this is handled is via rtti:

procedure TGameTrigger.Invoke;
  info : TRttiType;
  method: TRttiMethod;
  params: TArray<TValue>;
  context: TRttiContext;
  par, i: integer;

  if FTarget = '' then
    raise Exception.Create('Invalid target');

  context := TRttiContext.Create;
  info := context.GetType(TTriggerDispatcher);
  method := info.GetMethod(FTarget);
  if method = '' then
    raise Exception.Create(FTarget + ' does not exists');

  Setlength(params, FParams.Count + 2);
  params[0] := TValue.From<integer>(FX);
  params[1] := TValue.From<integer>(FY);
  for i := 0 to FParams.Count - 1 do
    if TryStrToInt(FParams[i], par)  then
      params[i + 2] := TValue.From<integer>(par)
      params[i + 2] := TValue.From<string>(FParams[i])


  method.Invoke(TTriggerDispatcher.Instance, params);

From the map editor one can design some game logic. All files should be at skydrive

  • If no animation assigned in TAnimationSprite then the old exception is no longer happening
  • TCollisionMatrix no longer returns the same sprite repeated
  • New trigger system
  • Triggers can dispatch more than one method 
  • Map load/saves triggers
  • New balls enemy 
  • New trigger entity
  • New music for level no name
  • CrushWalls fixed
  • When hero is finishing a level, immunity is activated
  • Possible triggers at the moment are: clear and set tiles and attributes, play sound and music and spawn entities
  • When in water and bubbles are shown and new sound is played
  • Triggers used in some levels

Saturday, February 15, 2014

New cloud repository

Since SugarSync insists on making me paying them I've to find alternatives...

All files should be at skydrive

Monday, February 10, 2014

Just another update

Well, just to keep this blog a bit "active" I'm uploading a new version

BTW, SugarSync is already telling me that our deal finishes in 7 days, time to find another place to save the files, but meanwhile here we go SugarSync.

Engine.Find() and Engine.SpritesAt() returns nil if no sprites (some performance gain)
Minor clipping issue solved (only visible with teleporting)
TDummySprite new property Group
New Engine.Find() per group
New Layer.GetItems() per group
New ICamera.GetPoint()
New ISprite.GetPoint()

Music was not resumed after a fight
The under 15 minutes achievement has to be done from the first Level
Hero dies differently...
Shield was not shown when in pause
Some non used graphics removed
Bomb enemy is back with some new explosion (nuclear?)
Bomb now dies with hero shield
All code adapted to Find() and SpriteAt()
Dragon included in level Colors (I think it gets very difficult...)
Spring handling improved
Jumping code harmonized
New falling blocks (crush wall)
New static Play3D() sound that does not need ISprite but TPoint
Time pickup now rather than stop the enemies it just slow them down quite a bit.

Dragon flying around...