游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3913|回复: 0

关于TV3D 6.5 在Delphi中使用

[复制链接]

5

主题

12

帖子

16

积分

新手上路

Rank: 1

积分
16
发表于 2009-6-8 05:09:00 | 显示全部楼层 |阅读模式
忙活了几个小时,终于在国外wiki那里找到一篇关于delphi安装tv3d6.5的介绍。
费力搞定后
第一个codedemo:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,TV3D65_TLB ;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
    TV:TVEngine ;
    Scene:TVScene ;
    Input:TVInputEngine ;
    Globals:TVGlobals ;

    procedure AppIdle(sender:TObject ;var done:Boolean  );
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
    TV := CoTVEngine.Create ;
    TV.SetDebugMode(True ,true ,True ,True);
    TV.SetDebugFile(ExtractFilePath(Application .ExeName ) + 'ErrLog.Log');

    TV.Init3DWindowed(Form1 .Handle ,True );
    TV.GetViewport.SetAutoResize(True );
    TV.DisplayFPS(True,-1);
    TV.SetAngleSystem(TV_ANGLE_DEGREE );

    Scene := CoTVScene.Create ;
    Globals := CoTVGlobals.Create ;
    Input := CoTVInputEngine.Create ;

    Input.Initialize(True ,True );

    Application.OnIdle := AppIdle;
end;

procedure tform1.AppIdle(sender : TObject; var done : boolean);
begin
    if Form1.Focused then
    begin
      done:=False;
      TV.Clear(False);
      Scene.RenderAll(True,True );
      TV.RenderToScreen ;

      if Input.IsKeyPressed(TV_KEY_W) then ShowMessage('UP!');
      if Input.IsKeyPressed(TV_KEY_S) then ShowMessage('Down!');
      if input.IsKeyPressed(TV_KEY_A) then ShowMessage('Lift!');
      if input.IsKeyPressed(TV_KEY_D) then ShowMessage('Right!');
      if input.IsKeyPressed(TV_KEY_ESCAPE) then
      begin
        ShowMessage('QuitGame!');
        Close();
        end;
        Application.ProcessMessages;
      end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
TV := nil;

end;

end.
实际上就是tv3d自带的模版,只是为了自己测试。
对了 那个dll需要regsvr32下
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-20 01:07

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表