Using C-ish code in FreePascal

I really like the pascal syntax and I really like C# syntax, so how can I mix those two together? I wrote a parser which can manage that task.

The following snippet looks like a mixture between C#, C++, Objective-C and JavaScript:

namespace testunit;

@interface

using
  SysUtils;

type
  MyClass : class {
  private
    fMyString: String;

    void addMyself();
  public
    function addThat(): int;
  published
    property MyString: String get fMyString;
  }

@implementation

  void MyClass::addMyself();
  {
  	if (fMyString == "") then
  	{
  	  fMyString = "This is my string.";
  	}
  	else
  	{
  	  fMyString = "This is my new string.";
  	}
  }

  function MyClass::addThat(): int;
  {

  }

@end

Read More

ElysionLegacy C++ code snippet

This blog has been pretty Object Pascal… well, until now. Here is a little code snippet of the ElysionLegacy package looks like in C++. As you can see except for the C-ish part, the API is quite the same as in the Object Pascal version and I will try my best to keep it that way.
As it progresses more and more I have to say it was a good step to move (T)elSurface into a singleton, even though it costed a bit performance. Not to worry, the frame rate is currently capped at 60 FPS by standard, 200 FPS at maximum.
It’s still in an experimental stage and the singleton may change a little bit, but the basic methods are already implemented.

#include <stdio.h>
#include "ElysionLegacy.h"

int main(int argc, char* argv[])
{
    elSprite* Sprite = new elSprite();

    elSurface::getInstance()->Initialize(640, 480, 32, false);

Sprite->LoadFromFile("/Path/to/mech.bmp");
Sprite->setPosition(makeP2D(10, 10));

while (elSurface::getInstance()->Run())
    {
elSurface::getInstance()->BeginScene();

Sprite->Draw();

elSurface::getInstance()->EndScene();
}

elSurface::getInstance()->Finalize();

    return 0;
}
Read More

Object Pascal, we need to talk…

Object Pascal, this is gonna be hard. You see, I have known you for a very long time, about 10 years to be precise, and all these years you have been my number one, my only number one. (Allright, there were Basic and Visual Basic before you came along, but that was more like an experiment if you know what I mean.) We had so much fun together.

Read More