| View previous topic :: View next topic |
| Author |
Message |
xiyuno Newbie cheater
Reputation: 0
Joined: 09 Dec 2007 Posts: 17 Location: hey
|
Posted: Sun Oct 04, 2009 11:01 am Post subject: Making game in Delphi |
|
|
Im making a game from a tutorial, im not finished with it, bcoz it says somethings wrong..
| Code: | unit FleeProsjekt;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Enemy: TShape;
EnemyTimer: TTimer;
Player: TShape;
Panel1: TPanel;
Start: TButton;
Score: TLabel;
LevelTimer: TTimer;
Label1: TLabel;
ScoreTimer: TTimer;
procedure EnemyTimerTimer(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure StartClick(Sender: TObject);
procedure LevelTimerTimer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.EnemyTimerTimer(Sender: TObject);
Var
Overlay: TRect;
begin
// Simple AZ
If Enemy.Left < player.left then Enemy.Left := Enemy.Left + Level.Tag;
If Enemy.Left > player.left then Enemy.Left := Enemy.Left - Level.Tag;
If Enemy.Top < player.Top then Enemy.Top := Enemy.Top + Level.Tag;
If Enemy.Top > player.Top then Enemy.Top := Enemy.Top - Level.Tag;
// This is the collision detection code.
If intersectRect(Overlay, player.BoundsRect, Enemy.BoundsRect)then begin
// The enemy Caught the player.
EnemyTimer.Enabled := False;
LevelTimer.Enabled := False;
ScoreTimer.Enabled := False;
Showmessage('You lost');
Start.Enabled := True;
end;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
If EnemyTimer.Enabled = True then begin
Player.Left := X - Player.Width div 2;
Player.Top := Y - Player.Height div 2;
end;
end;
procedure TForm1.StartClick(Sender: TObject);
begin
EnemyTimer.Enabled := True;
// reset the game elements
Enemy.Left := 8;
Enemy.Top := 8;
Player.Left := 392;
Player.Top := 240;
Level.Tag := 1;
Level.Caption := '1';
// Start the game timers
Start.Enabled := False;
LevelTimer.Enabled := True;
ScoreTimer.Enabled := True;
end;
procedure TForm1.LevelTimerTimer(Sender: TObject);
begin
Level.Tag := Level.Tag + 1;
Level.Caption := IntToStr(Level.tag);
end;
end.
|
It says that theres something wrong here, but i cant see it.
// Simple AZ
If Enemy.Left < player.left then Enemy.Left := Enemy.Left + Level.Tag;
If Enemy.Left > player.left then Enemy.Left := Enemy.Left - Level.Tag;
If Enemy.Top < player.Top then Enemy.Top := Enemy.Top + Level.Tag;
If Enemy.Top > player.Top then Enemy.Top := Enemy.Top - Level.Tag;
_________________
Oh yeah? Yeah. Oh yeah? Yeah. Oh yeah? Yeah.
Oh yeah? Yeah. Oh yeah? God damn yeah! |
|
| Back to top |
|
 |
NothingToShow Grandmaster Cheater Supreme
Reputation: 0
Joined: 11 Jul 2007 Posts: 1579
|
Posted: Sun Oct 04, 2009 11:22 am Post subject: |
|
|
| What are the errors? |
|
| Back to top |
|
 |
xiyuno Newbie cheater
Reputation: 0
Joined: 09 Dec 2007 Posts: 17 Location: hey
|
Posted: Sun Oct 04, 2009 11:24 am Post subject: |
|
|
[Error] FleeProsjekt.pas(95): ')' expected but identifier 'tag' found
[Error] FleeProsjekt.pas(95): Missing operator or semicolon
those _________________
Oh yeah? Yeah. Oh yeah? Yeah. Oh yeah? Yeah.
Oh yeah? Yeah. Oh yeah? God damn yeah! |
|
| Back to top |
|
 |
NothingToShow Grandmaster Cheater Supreme
Reputation: 0
Joined: 11 Jul 2007 Posts: 1579
|
Posted: Sun Oct 04, 2009 11:29 am Post subject: |
|
|
I'd assume the 95 indicates that it's on line 95, which is:
| Code: | | Level.Caption := IntToStr(Level.tag); |
|
|
| Back to top |
|
 |
xiyuno Newbie cheater
Reputation: 0
Joined: 09 Dec 2007 Posts: 17 Location: hey
|
|
| Back to top |
|
 |
NoManchesPuto I post too much
Reputation: 0
Joined: 24 Jan 2009 Posts: 2820
|
Posted: Mon Oct 05, 2009 8:04 pm Post subject: |
|
|
| xiyuno wrote: | Thank you, I'm very new to Delphi. I started Yesterday  |
Wow doing quite, well I could assist you if you need it. I've created several AQWorlds Trainers in Pascal (Delphi). |
|
| Back to top |
|
 |
|