📄 sample7.dpr
字号:
program sample7;
//////////////////////////////////////////////////////////////////////
//
// 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, SysUtils, Dialogs;
var TheText : PText;
BlueArrow,
RedArrow : PBmap;
aBall : PEntity;
procedure CheckForBtnActions;
begin
end;
procedure CreateText;
const TheStrings : Array[0..1] of string = ('Hitting Enter pushes the ball',
'Hit Esc to Quit the Program');
var TheFont : PFont_;
begin
TheFont := font_create('font1_red.pcx'); // create a font
TheText := txt_create(_VAR(2),_VAR(1)); // create a text with 2 strings
// setting the layer = 1
TheText.font := TheFont; // assign 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
end;
procedure HitBall;
var v : PVector;
begin
if aBall = Nil then Exit;
// Create a speed vector and rotate it in camera direction.
v := _VEC(150,0,0);
vec_rotate(v,PAngle(@ev.camera.pan));;
// Add a vertical speed to give the ball an upwards kick.
v.z := _VAR(75);
// Now apply the speed to the ball
phent_addvelcentral(aBall,v);
end;
procedure SetBallPhysics;
begin
if phent_settype(aBall,_VAR(PH_RIGID),_VAR(PH_BOX)) = 0 then Exit;
phent_setmass(aBall,_VAR(0.1),_VAR(PH_SPHERE));
phent_setfriction(aBall,_VAR(10.0));
phent_setelasticity(aBall,_VAR(90.0),_VAR(10.0));
phent_setdamping(aBall,_VAR(0.0),_VAR(0.0));
phent_addvelcentral(aBall,_vec(2,2,0));
ph_setgravity(_vec(0,0,-100));
end;
procedure CreateABall;
begin
aBall := ent_create('ball.mdl',_VEC(-115,180,192),Nil);
aBall.scale_x := _VAR(0.5);
aBall.scale_y := _VAR(0.5);
aBall.scale_z := _VAR(0.5);
SetBallPhysics;
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 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.camera.arc := _VAR(120);
BlueArrow := bmap_create('arrow_blue.pcx'); //needed for clicking on entities
RedArrow := bmap_create('arrow_red.pcx');
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.mouse_map := BlueArrow;
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^ := @HitBall;
ev.fps_min^ := _VAR(16);
ev.fps_max^ := _VAR(60);
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;
CreateABall;
// here is the engine main loop
while engine_frame <> 0 do
begin
MoveMouse;
CheckForBtnActions;
end;
engine_close();
end;
begin
Main;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -