📄 sample3.dpr
字号:
program sample3;
//////////////////////////////////////////////////////////////////////
//
// Delphi sample for using the A6_5x Engine (acknex.dll) done by
// Michal Messerschmidt aka LazyDog of Lazy Dog Software
// (www.LazyDogSoftware.com)
//
// SDK Version 6.50.6
//
// tested on Delphi 5,6,7 & 2005
//////////////////////////////////////////////////////////////////////
{$R 'icon.res' 'icon.rc'} // this allows defining your own .ico file
// without the overhead of using the forms unit
// to get to the application.icon. simply change
// the icon.rc file to point to your icon
uses A6Engine, Engine_Library, Dialogs;
const ModeStrings : Array[0..7] of string = ('Default Window Setup',
'no border',
'thin border',
'thick border',
'title bar and border',
'title bar with system menu',
'title bar with system menu and minimize button',
'window moved');
var vwIndex : integer = 0;//3;
WindowText : PText;
procedure FillWindowModeString;
begin
str_cpy(WindowText.Astring^,PChar(ModeStrings[vwIndex]));
end;
procedure CreateText;
const TheStrings : Array[0..2] of string = ('Hit Enter to Toggle Screen Mode',
'Hit Esc to Quit the Program',
'Current window type is:');
var TheText : PText;
TheFont : PFont_;
begin
TheFont := font_create('font1_red.pcx'); // create a font
TheText := txt_create(_VAR(3),_VAR(1)); // create a text with 3 strings
// setting the layer = 1
TheText.font := TheFont; // set the font
TheText.pos_x := _VAR(400); // set the x position
TheText.pos_y := _VAR(147); // set the y position
TheText.flags := _VISIBLE or CENTER_X; // set it visible, centered on x
Txt_Fill(TheText,TheStrings); // fill the text object from array
// txt_fill defined in Engine_Library
WindowText := txt_create(_VAR(1),_VAR(1));
WindowText.font := TheFont;
WindowText.pos_x := _VAR(400);
WindowText.pos_y := _VAR(200);
WindowText.flags := _VISIBLE or CENTER_X;
FillWindowModeString;
end;
procedure MoveMouse;
begin
if ev.mouse_map = Nil then Exit;
if _INT(ev.freeze_mode^) > 1 then Exit; // all functions suspended
if ev.mouse_valid^ = 0 then // makes cursor disappear when
ev.mouse_mode^ := 0 // no longer over the engine window
else
ev.mouse_mode^ := _VAR(1);
if ev.mouse_mode^ > 0 then // move it over the screen
begin
ev.mouse_pos.x := ev.mouse_cursor.x;
ev.mouse_pos.y := ev.mouse_cursor.y;
end;
end;
procedure ToggleWindowMode;
begin
if ev.video_screen^ = _VAR(1) then Exit; // if full screen do nothing
Inc(vwIndex);
if vwIndex > 7 then vwIndex := 1;
case vwIndex of
1 : video_window(_vec(0,0,0),_vec(0,0,0),_VAR(1),'no border');
2 : video_window(_vec(0,0,0),_vec(0,0,0),_VAR(2),'thin border');
3 : video_window(_vec(0,0,0),_vec(0,0,0),_VAR(4),'thick border');
4 : video_window(_vec(0,0,0),_vec(0,0,0),_VAR(16),'title bar and border');
5 : video_window(_vec(0,0,0),_vec(0,0,0),_VAR(48),'title bar with system menu');
6 : video_window(_vec(0,0,0),_vec(0,0,0),_VAR(112),'title bar with system menu and minimize button');
7 : video_window(_vec(0,0,0),_vec(0,0,0),0,'window moved');
end;
FillWindowModeString;
end;
procedure Quit;
begin
sys_exit(''); // quit running and shut down the engine
end;
procedure Main;
begin
if FindDirectX < 9 then
begin
ShowMessage('DirectX 9 is required to run this program');
Exit;
end;
ev := engine_open(''); // commands like -diag can be used here
if ev = Nil then Exit;
add_folder('files'); // point to subdirectory that holds level files
ev.on_close^ := @Quit; // [X] close icon clicked quits program
ev.on_esc^ := @Quit; // ESC key quits program
ev.mouse_mode^ := _VAR(1); // windows cursor is visible
ev.mouse_pointer^ := _VAR(1); // default cursor is hand
ev.video_screen^ := _VAR(2); // default to window mode
ev.video_mode^ := _VAR(7); // default to 800x600
ev.video_depth^ := _VAR(32); // default to 32 bit depth
ev.on_enter^ := @ToggleWindowMode;
level_load('paths.wmb'); // this is loaded from the files subdirectory
engine_frame; // need to wait 2 frames after a level_load
engine_frame; // before creating entities
CreateText; // don't call until engine is running
// here is the engine main loop
while engine_frame <> 0 do
begin
MoveMouse;
end;
engine_close();
end;
begin
Main;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -