View Full Version : Help please. :)
Vexus
23-09-2004, 02:00 AM
Hello everyone I'm very excited to be here!
I've been with visual basics 6 for 2 years now and its finally about that time to move onto another language and Delphi is that language.
I'm going to start creating games for a hobby. I have some questions that I hope you guys can help me with. This forum is one in a million find.
Delphix is a library full of features for creating 2D games correct?
I have heard its only for versions 3, 4, and 5 thought.
What can I do as I have delphi 7. I've downloaded UnDelphix but I have no Idea how to include it in my project! :(
Can you help me?
Thank you,
Nick
[EDIT: I got it installed. ]
Is there any tutorials that will teach me how to make 2d game? Maybe titles and how to use sprites on them etc.. :P
Thanks
Vexus
23-09-2004, 02:37 AM
Hello again, I am not sure if I did gameprogrammers.net tutorial correctly on making a menu.
Heres my code :) please check it over I am pretty sure I did some stuff wrong.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DXDraws, DXSounds, DXSprite, DXClass, DXInput;
type
TForm1 = class(TForm)
DXDraw1: TDXDraw;
DXInput1: TDXInput;
DXTimer1: TDXTimer;
DXSpriteEngine1: TDXSpriteEngine;
DXSound1: TDXSound;
DXWaveList1: TDXWaveList;
DXImageList1: TDXImageList;
TGameState = (gsStart, gsMenu, gsReset, gsGame, gsEndGame, gsGameOver, gsInstructions, gsEnd); //I GET AN ERROR HERE about '='
private
{ Private declarations }
public
{ Public declarations }
end;
var
var Form1 : TForm1;
Points : word;
GameState : TGameState;
GameCounter : Integer;
MenuChoice : byte;
MenuImage : TDirectDrawSurface;
SelectorImage : TDirectDrawSurface;
implementation
{$R *.dfm}
procedure doStart;
begin
// do the init stuff here, like loading images
menuImage:=TDirectDrawSurface.Create(Form1.DXDraw1 .DDraw);
menuImage.LoadFromGraphic(Form1.DXImageList1.Items .Items[16].picture.Graphic);
SelectorImage :=TDirectDrawSurface.Create(Form1.DXDraw1.DDraw);
SelectorImage.LoadFromGraphic(Form1.DXImageList1.I tems.Items[17].picture.Graphic);
SelectorImage.TransparentColor:=clblack;
menuChoice := 1;
GameState := gsMenu;
SelectorImage.LoadFromGraphic(Form1.DXImageList1.I tems.Items[17].picture.Graphic);
InstructionImage :=TDirectDrawSurface.Create(Form1.DXDraw1.DDraw);
InstructionImage.LoadFromGraphic(Form1.DXImageList 1.Items.Items[18].picture.Graphic);
menuChoice := 1;
GameState := gsMenu;
end;
procedure doMenu;
begin
// do menu stuff here
Form1.DXDraw1.surface.Draw(0,0,menuImage.clientrec t,menuImage,false);
Form1.DXDraw1.surface.Draw(56,147+(menuChoice-1)*36,
selectorImage.clientrect,selectorImage,true);
end;
procedure doInstructions;
begin
Form1.DXDraw1.surface.Draw(0,0,InstructionImage.cl ientrect,InstructionImage,false);
end;
procedure doReset;
begin
// put the things before the game starts here
Form1.DXDraw1.surface.Canvas.Font.Color:=clred;
Form1.DXDraw1.surface.Canvas.Brush.Style:=bsclear;
GameState := gsGame;
end;
procedure doGame;
begin
// put the game stuff in here
end;
procedure doEndGame;
begin
// do stuff here like freeing sprites
end;
procedure doGameOver;
begin
// do gameover stuff here like showing gameover message
end;
procedure doEnd;
begin
// do end stuff here like freeing images and all
Form1.DXTimer1.Enabled:=false;
menuImage.Free;
SelectorImage.Free;
instructionImage.Free;
// and finally close the game
Application.Terminate;
end;
procedure ProcessGamestate;
begin
case GameState of
gsStart : doStart;
gsMenu : doMenu;
gsInstructions :doInstructions;
gsReset : doReset;
gsGame : doGame;
gsEndGame : doEndGame;
gsGameOver: doGameOver;
gsEnd : doEnd;
end;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
inc(GameCounter);
try
ProcessGamestate;
except
dxtimer1.Enabled:=false;
messagedlg('An error has occurred',mterror,[mbok],0);
end;
dxdraw1.Flip;
end;
procedure TForm1.DXDraw1Initialize(Sender: TObject);
begin
Form1.DXTimer1.Enabled:=true;
GameState:=gsStart;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Width:=350;
Form1.Height:=350;
form1.Position:=poScreenCenter;
randomize;
end;
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if key = vk_escape then
begin
case GameState of
gsMenu : GameState := gsEnd;
gsInstructions : GameState := gsMenu;
gsGame : GameState := gsEndGame;
gsGameOver : GameState := gsEndGame;
end;
end;
if (key = vk_return) and (GameState = gsMenu) then
begin
case menuChoice of
1 : GameState := gsReset;
2 : GameState := gsInstructions;
3 : GameState := gsEnd;
end;
end;
if (key = vk_up) and (GameState = gsMenu) then
begin
if menuChoice = 1 then menuChoice := 3 else dec(menuChoice);
end;
if (key = vk_down) and (GameState = gsMenu) then
begin
if menuChoice = 3 then menuChoice := 1 else inc(menuChoice);
end;
end;
end.
Hi Vexus, welcome to DGDev(future home of PGD) . DelphiX/UnDelphiX is a great starters suite for learning to make games in Delphi alone. I'm sure that for the first few projects you'll find that it works great for what you have planned to make. However in due timeas you get into more and more complex things, you'll notice it has many restrictions.
DelphiX was developed by Hori, as you well may know, but he had stopped working on the project sometime around 2001. It is basically just a set of visual components that allow functionality of the DirectX API(DirectDraw, DirectSound, Direct3D, DirectInput, etc) and use them in your standard Delphi project. Since then a few people wanting to still use it on versions of Delphi after Delphi 5(and with newer versions of DirectX beyond DirectX 7) worked on a project called UnDelphiX, which really is just DelphiX with many improvements including the use of DirectX some 8.1 features and modified to run on Delphi 7. It is hosted on turbo.gamedev.net and can be easily installed by simply opening the dpk file and hitting the 'Install' button(thanks to it's most recent contributor).
If that doesn't do it, well I'd suggest having a good look around turbo and making sure you have the right version of UNDelphiX and/or you are going about it the right way. I hope that helps somewhat.
All that said, please keep in mind that DelphiX/UnDelphiX is not theonly game library package out there to help you make games. It really is only one of many. After you have had enough time to get to learn the basics and some of the more advanced things in programming you may want to consider things like OpenGL API(2D and 3D), SDL(for graphics), alternative input APIs, working with 3D, faster graphics effects(alpha blending, rotation, streching/zooming/scaling, particle effects, etc, etc) alternative sound libs(OpenAL, SDL, etc), cross-platform(DirectX is Windows only and games will not be easily ported to Linux or Mac OS, etc), and a huge assortment of other issues that mean migrating to other libraries and suites.
Best of luck and if you have any more questions just feel free to ask. ;) Lots of knowlagable people at this site.
cairnswm
23-09-2004, 06:58 AM
There are games with source on my web page - select the public link
Traveler
23-09-2004, 08:25 AM
Thanks for mentioning my tutorial Vexus.
You can find more at www.gameprogrammer.net (http://www.gameprogrammer.net)
Useless Hacker
23-09-2004, 12:49 PM
type
TForm1 = class(TForm)
DXDraw1: TDXDraw;
DXInput1: TDXInput;
DXTimer1: TDXTimer;
DXSpriteEngine1: TDXSpriteEngine;
DXSound1: TDXSound;
DXWaveList1: TDXWaveList;
DXImageList1: TDXImageList;
TGameState = (gsStart, gsMenu, gsReset, gsGame, gsEndGame, gsGameOver, gsInstructions, gsEnd); //I GET AN ERROR HERE about '='
private
{ Private declarations }
public
{ Public declarations }
end;
The TGameState definition should be outside the class definition, i.e.:
type
TGameState = (gsStart, gsMenu, gsReset, gsGame, gsEndGame, gsGameOver, gsInstructions, gsEnd); //I GET AN ERROR HERE about '='
TForm1 = class(TForm)
DXDraw1: TDXDraw;
DXInput1: TDXInput;
DXTimer1: TDXTimer;
DXSpriteEngine1: TDXSpriteEngine;
DXSound1: TDXSound;
DXWaveList1: TDXWaveList;
DXImageList1: TDXImageList;
private
{ Private declarations }
public
{ Public declarations }
end;
P.S. For the love of God, change your signature to 'bear with me' before people start stripping off!
Vexus
23-09-2004, 02:34 PM
lol thank you guys heres another game i'm working on can you tell me why when I start the game it asks for these?
like: TClientSocket compnent missing or something then it does all the TWMImages below :(
any ideas?
TFrmMain = class(TDxForm)
DXDraw1: TDXDraw;
WTiles: TWMImages;
WObjects1: TWMImages;
WSmTiles: TWMImages;
WHumImg: TWMImages;
WProgUse: TWMImages;
CSocket: TClientSocket;
Timer1: TTimer;
MouseTimer: TTimer;
WMonImg: TWMImages;
DWinMan: TDWinManager;
WHairImg: TWMImages;
WBagItem: TWMImages;
WWeapon: TWMImages;
WStateItem: TWMImages;
WDnItem: TWMImages;
WaitMsgTimer: TTimer;
SelChrWaitTimer: TTimer;
WMagic: TWMImages;
CmdTimer: TTimer;
WNpcImg: TWMImages;
WMagIcon: TWMImages;
WChrSel: TWMImages;
MinTimer: TTimer;
WMon2Img: TWMImages;
WMon3Img: TWMImages;
WMMap: TWMImages;
WMon4Img: TWMImages;
DXSound: TDXSound;
WMon5Img: TWMImages;
WMon6Img: TWMImages;
WEffectImg: TWMImages;
WObjects2: TWMImages;
WObjects3: TWMImages;
WObjects4: TWMImages;
WObjects5: TWMImages;
WObjects6: TWMImages;
WObjects7: TWMImages;
WMon7Img: TWMImages;
WMon8Img: TWMImages;
WMon9Img: TWMImages;
WMon10Img: TWMImages;
WMon11Img: TWMImages;
WMon12Img: TWMImages;
WMon13Img: TWMImages;
WMon14Img: TWMImages;
WMon15Img: TWMImages;
WMon16Img: TWMImages;
SpeedHackTimer: TTimer;
WMon17Img: TWMImages;
WMon18Img: TWMImages;
WMagic2: TWMImages;
WProgUse2: TWMImages;
Should I use delphix DXWImagelist or something? And load these say WProgUse2.bmp? it accepts .bmp >_>
Thanks again.
Vexus
23-09-2004, 04:46 PM
I found the Class / compnent in WIL.pas
So any idea why it won't read this class or how do I make it installed as a compnent.. ugh im confused lol
TWMImages = class (TComponent)
private
FFileName: string;
FImageCount: integer;
FLibType: TLibType;
FDxDraw: TDxDraw;
FDDraw: TDirectDraw;
FMaxMemorySize: integer;
procedure LoadAllData;
procedure LoadAllDataBmp;
procedure LoadIndex (idxfile: string);
procedure LoadDxImage (position: integer; pdximg: PTDxImage);
procedure LoadBmpImage (position: integer; pbmpimg: PTBmpImage);
procedure FreeOldMemorys;
function FGetImageSurface (index: integer): TDirectDrawSurface;
procedure FSetDxDraw (fdd: TDxDraw);
procedure FreeOldBmps;
function FGetImageBitmap (index: integer): TBitmap;
protected
//MemorySize: integer;
lsDib: TDib;
memchecktime: longword;
public
ImgArr: PTDxImageArr;
BmpArr: PTBmpImageArr;
IndexList: TList;
//BmpList: TList;
Stream: TFileStream;
//MainSurfacePalette: TDirectDrawPalette;
MainPalette: TRgbQuads;
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
procedure Initialize;
procedure Finalize;
procedure ClearCache;
procedure LoadPalette;
procedure FreeBitmap (index: integer);
function GetImage (index: integer; var px, py: integer): TDirectDrawSurface;
function GetCachedImage (index: integer; var px, py: integer): TDirectDrawSurface;
function GetCachedSurface (index: integer): TDirectDrawSurface;
function GetCachedBitmap (index: integer): TBitmap;
procedure DrawZoom (paper: TCanvas; x, y, index: integer; zoom: Real);
procedure DrawZoomEx (paper: TCanvas; x, y, index: integer; zoom: Real; leftzero: Boolean);
property Images[index: integer]: TDirectDrawSurface read FGetImageSurface;
property Bitmaps[Index: Integer]: TBitmap read FGetImageBitmap;
property DDraw: TDirectDraw read FDDraw write FDDraw;
published
property FileName: string read FFileName write FFileName;
property ImageCount: integer read FImageCount;
property DxDraw: TDxDraw read FDxDraw write FSetDxDraw;
property LibType: TLibType read FLibType write FLibType;
property MaxMemorySize: integer read FMaxMemorySize write FMaxMemorySize;
end;
Useless Hacker
23-09-2004, 09:24 PM
Where did you get that unit (WIL.pas) from? It isn't part of the standard DelphiX library as far as I am aware...
Vexus
23-09-2004, 09:49 PM
Sorry I didn't make myself clear.
This game client requires components and to register them you have to find out where they are in the code and install them.. I did it so far.. but i'm stuck on other problems.
Have you got any way of fast communication like MSN or AIM? Maybe I can send you the source so you could look it over if its not to much trouble. :)
Thanks,
Nick
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.