Results 1 to 9 of 9

Thread: Machina Engine - Game Engine

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Here are some news:
    First of all, now I'm using XML as language for data-files(which can be encrypted). The engine is faster and more flexible because of this.

    Second, part of the physics engine is already working:

    • Force;
    • Velocity;
    • Acceleration;
    • Friction;


    Sprites can be used already. Also, they can be rotated, and be animated.

    The next step is to implement the physics with different types of collision:

    • Option to use multiple masks of collision for a same sprite;
    • With different masks of collision in the same sprite, the collision can be treat differently according with the part collided;
    • Default masks like rectangle mask, circle mask, etc;


    ...and implement the Momentum(Conservation of Linear Momentum).

    This small video show these features:


    And you can see the code of the game-using the game engine- here:

    Code:
    type
      TBaseMainChar    = class(TBaseObject)
      public
         procedure    OnKeyPress(BSender: TBase; var BKeyBoard : TMsgKeyBoard);
        constructor    Create; override;
      end;
    
    procedure    TBaseMainChar.OnKeyPress(BSender: TBase; var BKeyBoard : TMsgKeyBoard);
    var
      BBaseObject    : TBaseObject;
    begin
      BBaseObject    := TBaseObject(BSender);
      if VK_Up in BKeyBoard then
      begin
        BBaseObject.ApplyForce(0.6,    BBaseObject.FRotationZ);
      end;
      if VK_DOWN in BKeyBoard then
      begin
        BBaseObject.FAcceleration    := 0;
      end;
      if VK_Left in BKeyBoard then
      begin
        BBaseObject.FRotationZ    := BBaseObject.FRotationZ - 2;
      end;
      if VK_RIGHT in BKeyBoard then
      begin
        BBaseObject.FRotationZ    := BBaseObject.FRotationZ + 2;
      end;
    end;
    
    constructor    TBaseMainChar.Create;
    begin
      inherited Create;
      FOnKeyDown    := nil;
      Self.FOnKeyPress    := OnKeyPress;
      Self.FOnKeyUp    := nil;
    end;
    
    begin
      FApplicationGame    := TApplicationGame.Create;
      FApplicationGame.FFrameProcessType    := FPT_CONSTANT; // There are 3 kinds of loops;
      FApplicationGame.CreateForm('FFormName',    'Form Title', True);
    
      //---------------------------------------------\\
      //Register TBaseObject class into memory:
      //---------------------------------------------\\
      New(FClassRegistry);
      FClassRegistry.FClassName    := 'TBaseObject';
      FClassRegistry.FClassReference    := TBaseObject;
      FApplicationGame.FManagerClassReference.Add(FClassRegistry);
      //---------------------------------------------\\
      //Register TBaseMainChar class into memory:
      //---------------------------------------------\\
      New(FClassRegistry);
      FClassRegistry.FClassName    := 'TBaseMainChar';
      FClassRegistry.FClassReference    := TBaseMainChar;
      FApplicationGame.FManagerClassReference.Add(FClassRegistry);
      FApplicationGame.LoadDataFile('\MainData.dat');
      FApplicationGame.LoadAllResourceFiles;
      FApplicationGame.LoadAllSprites;
      FApplicationGame.Run;
    end.
    Small, i'snt?
    Last edited by FelipeFS; 12-06-2012 at 05:11 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •