📄 sample2.dpr
字号:
program sample2;
//////////////////////////////////////////////////////////////////////
//
// 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;
procedure CreateText;
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
str_cpy(TheText.Astring^,'Hit Enter to Toggle Screen Mode');
Inc(TheText.Astring); // increment the pointer to next string
str_cpy(TheText.Astring^,'Hit Space to Toggle Window Cursor');
Inc(TheText.Astring); // increment the pointer to next string
str_cpy(TheText.Astring^,'Hit ESC to Quit the Program');
Dec(TheText.Astring); // Reset the pointer to beginning
Dec(TheText.Astring); // Need to Dec as many Inc statements
// this is very important to do
// or run-time error occurs!!!
// the following statement could be used instead of the previous
// two Dec statements. The previous two Dec statements were used to
// clearly show that the pointer needs moved back exactly the same number
// of times it was moved forward!!
//Dec(TheText.Astring,_INT(TheText.strings)-1);
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(2) then // window mode
video_switch(0,0,_VAR(1)) // set to full screen
else
begin
video_window(_vec(0,0,0),_vec(0,0,0),_VAR(1),nil); // set to no border
// video_window(ev.nullvector,ev.nullvector,_VAR(1),nil); // set to no border
video_set(0,0,0,_VAR(2)); // set to window mode
video_window(_vec(0,0,0),_vec(0,0,0),_VAR(48),nil); // set to title bar with system menu
// video_window(ev.nullvector,ev.nullvector,_VAR(48),nil); // set to title bar with system menu
end;
end;
procedure ToggleMousePointer;
var I : Integer;
begin
I := _INT(ev.mouse_pointer^);
//0=always off
Inc(I); //1=hand OR off if mouse_map set and mouse_mode activated
if I > 4 then I := 0; //2=arrow OR like #1
//3=crosshair OR like #1
ev.mouse_pointer^ := _VAR(I); //4=hourglass OR like #1
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_space^ := @ToggleMousePointer;
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 + -