Archived

This topic is now archived and is closed to further replies.

Octiron

Need help with PowerDraw...

Recommended Posts

Hi, I''m yet another newbie that comes in here to bug you with help requests. I''m (giving my best go at) writing a game in Delphi6 (Personal) using the PowerDraw components and I''m having a little trouble at two points. That''s why I''m coming here to stand on my knees and beg you for help. Anyway, this is what I need help for: First, I want to render a 640x480 image as a background (menu and interface) but I can''t figure out how to. Second, how do I detect if the player is using the Up, Down and Enter keys? Thank you in advance.

Share this post


Link to post
Share on other sites
BTW, on the second question... I use a Timer component set to an interval of 100 to detect if the player is pressing the keys. I just lack the code to test for the right ones.

Share this post


Link to post
Share on other sites
I''m not familiar with PowerDraw, so I can''t answer your PowerDraw question... but here''s some ideas about your keyproblem...:


1. You could just use OnKeyDown or OnKeyUp (Form Event).
There are virtual key-codes declared as constants

VK_ESCAPE, VK_LEFT, VK_RIGHT, etc.

so

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
case Key of
VK_ESCAPE: Close;
VK_DOWN: Next_Menu_Item;
VK_UP: Previous_Menu_Item;
end;
end;

This works well for menus, but I don''t recommend it for in-game keyboard input.

So if speed is what you need (hey, that rhymes), then go with DirectInput...It''s a bit much to explain how DirectInput works, but the keyboard part of it isn''t very complicated.

Share this post


Link to post
Share on other sites
Greetz

First of all, if you''re a starter, I personally wouldn''t recommend starting with PowerDraw, since it requires you to know at least basics of Direct3D8.

For rendering images there''re some examples included with PowerDraw (btw, don''t forget to get the latest version at http://cshine.cjb.net/powerdraw - there''s VTDb update).

For rendering 640x480 background: although there''re other more efficient ways, the easiest one is: add 640x480 image to VTD file (using VTDTool), specifying 1024x1024 as texture size (you''ll be wasting a lot of memory though) and 640x480 as pattern width&height.
In your application, load the VTD and render your image, as shown in examples.
Most hardware needs texture size to be a power of 2, that''s why you have to put 1024x1024 (1024x512 might work on some hardware too) size.

Other ways of rendering background - load 256x256 image and resize it in real-time to 640x480 (what we actually do in Abyss of Infinity).

As for keyboard, Harry Hunt gave you pretty good example. You might want use PowerInput, for this you''ll have to look again at example provided with PowerDraw.

Hope this was somehow useful
Lifepower

Share this post


Link to post
Share on other sites
Thanks guys, you''ve helped me immensely.

I was intending to use the PowerInput component but I had trouble figuring out exactly how to use it.

Hmm, I see how a texture @ 1024x1024 would drain huge amounts of video memory and I would like my game to run on slower systems.

Well, what I think I''ll do is to glue together a background image of smaller tiles (64x64 or 128x128 probably) and rip apart the PowerDraw samples to get an idea of what to do then. I might give DelphiX a go too. I''ll find out.

Thanks again to the both of you!

Share this post


Link to post
Share on other sites
uhm.. hi, i downloaded Powerdraw 2.3 cause i wanted to play around a bit with it.. checking out what i could do with a next game after High Carats.

Well, i could install it but all i get is "Could not initialize Direct3D" with the initialize() call... no matter if i do it my own or if i start one of the examples... No black screen, no resolution change, nothing.

to be 100% sure i reinstalled Direct X 8.1, i have a win98se system with a GF 2 mx

anyone else with this prob?

Zimond.

Share this post


Link to post
Share on other sites
If you get this error, then it means hardware acceleration isn''t supported in this mode. This can be a driver issuse and/or DirectX. I''ve seen this error when starting applications in windowed mode with Windows running in 24-bit resolution. You may start "dxdiag" utility and test Direct3D from there.

Share this post


Link to post
Share on other sites