PDA

View Full Version : My First Published Pascal Game



yassersoft
26-11-2009, 01:31 PM
Hello Community this is my first game developped on Delphi7. I was very quick beacuse of time (i wanted to use this game on th e contest, but i don¬Ąt know where or who sendit). Maybe with more time and new ideas i could make something better.OK There is:

http://www.2shared.com/file/9460332/6dc441f4/Basket.html

Stoney
26-11-2009, 03:44 PM
Nice little game. :)
I remember one of my first Delphi games I made was quite similar.

There is one issue though: The images are flickering, put

DoubleBuffered := true;

in your FormCreate - procedure to solve that.

If you mean the PGD Annual Arcadia-Contest go to http://www.pgdannual.com/, register, login in and submit your game. I've noticed if you want to compete you need to implement the "Insert coin"-rule.

yassersoft
17-12-2009, 01:44 PM
OW sorry I get that link too late. I think i will wait next contest. So, Can I keep still uploading my proyects here?

yassersoft
01-02-2010, 08:53 PM
Stoney:
Last time you advice me about the flickering of my images. I had do what you suggested me but I think the flickering is still there. Look this is teh code




unit main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;

type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Timer1Timer(Sender: TObject);
private
mike:TBitmap;
mike_pos:TPOint;
start_pos:TPoint;
gravedad,jumpspeed:integer;
jumping:Boolean;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
mike:=TBitmap.Create;
mike.LoadFromFile('migue.bmp');
gravedad:=2;
jumpspeed:=-25;
jumping:=False;
mike_pos.X:=20;
mike_pos.Y:=ClientHeight-mike.Height;
start_POs.X:=Mike_Pos.X;
start_POs.Y:=ClientHeight-mike.Height;

end;

procedure TForm1.FormPaint(Sender: TObject);
begin
DoubleBuffered:=True;
Canvas.Draw(mike_pos.X,mike_pos.Y,mike);

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
mike.Free;
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_SPACE then
jumping:=True;
if key=VK_LEFT then
dec(mike_pos.X,10);
if key=VK_RIGHT then
inc(mike_pos.X,10);

end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Canvas.Brush.Color:=clWhite;
Canvas.Rectangle(0,0,ClientWidth,ClientHeight);
Canvas.Draw(mike_pos.X,mike_pos.Y,mike);
if jumping then
begin
inc(jumpspeed,gravedad);
mike_pos.Y:=mike_pos.Y+jumpspeed;
Canvas.Brush.Color:=clWhite;
Canvas.Rectangle(0,0,ClientWidth,ClientHeight);
Canvas.Draw(mike_pos.X,mike_pos.Y,mike);
if mike_pos.Y>start_pos.Y then
begin
jumping:=False;
mike_pos.Y:=start_pos.Y;
Canvas.Draw(mike_pos.X,mike_pos.Y,mike);
jumpspeed:=-25;
end;
end;
end;

end.


And here is the example:

http://www.2shared.com/file/11058299/9de9f943/Miguel.html

Stoney
02-02-2010, 11:14 AM
You should put the DoubleBuffered-Line in the FormCreate-procedure, not in the FormPaint-procedure. Try:


procedure TForm1.FormCreate(Sender: TObject);
begin
DoubleBuffered:=True;
[...Rest of the code...]
end;

You can use [ pascal ] [ /pascal ] or [ code ] [ /code ] - Tags to show the code formatted.

For future games you might want to take a look into SDL/DirectX/OpenGL or engines based on those graphic libraries like Andorra2D, Asphyre, Phoenix, etc.
Canvas is good for starters, but the performance is going the get slower and slower the more and more images you are drawing on the screen.