Class TGame_Form (unit Gameform) |
Inherits from
TForm
the best way to get speed increases is to use the game rules to limit wasted checks
etc. I've used a black background and sprites with a black edge to avoid
transparent copies.
Also bullets are only checked against the sides they are going to
(bonuses can't be avoided, but the linked list approach minimizes
wasted checks
procedure exit_buttonClick(Sender: TObject);
don't want game to continue in background
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
I don't like these at all ---------------------------------------------------------------------------- } { Form } { ----------------------------------------------------------------------------
procedure FormDeactivate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
used in debug
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
force all redraw, not just quick update
procedure FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
enable further processing
procedure FormResize(Sender: TObject);
ALT-TAB
Procedure TGame_Form.
procedure Game_windowPaint(Sender: TObject);
keep top visible
procedure go_buttonClick(Sender: TObject);
procedure New_game_buttonClick(Sender: TObject);
procedure Pause_buttonClick(Sender: TObject);
---------------------------------------------------------------------------- } { Button interface and messages stuff } { ----------------------------------------------------------------------------
procedure Collisionwithbonus;
procedure Confine_cursor(trap:boolean);
procedure Createnewbonus;
procedure Increase_score(num:integer);
procedure initialize;
Public declarations not used any more
procedure layoutsquares(destDC:HDC);
procedure Mainloop;
Why have I done 4 mini loops - mask = 0,1,2,3 - well I wanted to time
individual sections of the code, to see when improvements speeded things
up or not.
procedure move_monsters;
procedure Move_Players_ship;
removed this because it was annoying
if trap then with cursor_pad do begin
tp1 := ClienttoScreen(Point(width div 2,height div 2));
SetCursorPos(tp1.
procedure NewMonsterBullet(monster:TSprite);
procedure NewShipBullet;
hit bonus
procedure redraw_monsters;
procedure Redraw_monster_bullets;
check to see if bullet hit a bonus
procedure Redraw_ship_bullets;
ought to put a little delay in between levels really
procedure Sendmonstershome;
procedure setup_level(lev:integer);
procedure start_game;
procedure stop_game;
during play
exit_button : TButton;
Game_window : TPaintBox;
go_button : TButton;
New_game_button : TButton;
Panel1 : TPanel;
Panel2 : TPanel;
Panel3 : TPanel;
Panel4 : TPanel;
Pause_button : TButton;
procedure exit_buttonClick(Sender: TObject);
don't want game to continue in background
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
I don't like these at all
---------------------------------------------------------------------------- } { Form } { ----------------------------------------------------------------------------
procedure FormDeactivate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
used in debug
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
force all redraw, not just quick update
procedure FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
enable further processing
procedure FormResize(Sender: TObject);
ALT-TAB
Procedure TGame_Form.CMDialogKey(var Message: TCMDialogKey);
begin { this doesn't work the way I want it to - bugger ! } { if Message.CharCode = VK_TAB then begin
{Process the Alt+Tab key here} { showmessage('fderefsd');
Message.result := 1;
exit;
end;
inherited;
end;
procedure Game_windowPaint(Sender: TObject);
keep top visible
procedure go_buttonClick(Sender: TObject);
procedure New_game_buttonClick(Sender: TObject);
procedure Pause_buttonClick(Sender: TObject);
---------------------------------------------------------------------------- } { Button interface and messages stuff } { ----------------------------------------------------------------------------
procedure Collisionwithbonus;
procedure Confine_cursor(trap:boolean);
procedure Createnewbonus;
procedure Increase_score(num:integer);
procedure initialize;
Public declarations
not used any more
procedure layoutsquares(destDC:HDC);
procedure Mainloop;
Why have I done 4 mini loops - mask = 0,1,2,3 - well I wanted to time
individual sections of the code, to see when improvements speeded things
up or not. Each screen update is divided into 4 mini updates, and each can
be timed using the frame-speed counters, the panels are used to display
the cycles of each 'phase' of the clock. I just did it like this at first,
then left it in. - debug
procedure move_monsters;
procedure Move_Players_ship;
removed this because it was annoying
if trap then with cursor_pad do begin
tp1 := ClienttoScreen(Point(width div 2,height div 2));
SetCursorPos(tp1.x,tp1.y);
tp1 := ClienttoScreen(Point(0,0));
SetRect(tr,tp1.x,tp1.y,tp1.x+width,tp1.y+height);
ClipCursor(@tr);
end
else
procedure NewMonsterBullet(monster:TSprite);
procedure NewShipBullet;
hit bonus
procedure redraw_monsters;
procedure Redraw_monster_bullets;
check to see if bullet hit a bonus
procedure Redraw_ship_bullets;
ought to put a little delay in between levels really
procedure Sendmonstershome;
procedure setup_level(lev:integer);
procedure start_game;
procedure stop_game;
during play
exit_button : TButton;
Game_window : TPaintBox;
go_button : TButton;
New_game_button : TButton;
Panel1 : TPanel;
Panel2 : TPanel;
Panel3 : TPanel;
Panel4 : TPanel;
Pause_button : TButton;