Page 1 of 5 123 ... LastLast
Results 1 to 10 of 45

Thread: DELPHIX Problems. Need help with multiple problems

  1. #1

    DELPHIX Problems. Need help with multiple problems

    Windows XP, SP1a, DelphiX, Borland delphi 4 and 7, Pentium 4 2.8 GHz, Geforce 2 MMX400 64 MB, 512 MB DDR 3200

    1. Delphix timer seems to reach only a maximum FPS of 64 on my computer, 100 on my cousins (even though we are using pentium 4 processors). It si very strange but the bug disappears as soon as I open certain programs like DXDIAG from Run. Sometimes the bug is more provailent when delphi itself is not running...very strange. Really need help with this (furthermore all high precision timers won't reach above 64 FPS on my computer). I am thinking it is a problem with the OS me and my cousin are using?

    2. I need to add images to TDXimagelist at runtime?

    3. I need to change the background and 1 or 2 sprites SIZE and see the change reflected on screen. I jave tried putting image.patternheight:=image.patternheight-10; at nearly every point in the program but no luck at all . In other words I need to see say my character "grow" or "shrink".

    4. If I have Vsync on the FPS changes too, and it seems to chane depending on screen frequency of the computer in question as would be expected. Unfortunately this also changes the gameplay speed depending on each computer. How can I ensure the game will be the same on all computers? I.e. Charcter sprites moving at same speed etc etc etc.

    5. How do I reference other Sprites from inside another sprites DoMove? I need to say x:= [insert other sprites x position here]. Or do I simply have to do it the hard way and use a global variable?

    Thanks for any help, I really am stuck!

    Seifer Almasy

  2. #2

    DELPHIX Problems. Need help with multiple problems

    Can't really help you with the first question. My first thoughts are vsync, but you mentioned that in your 4th question, so that's probably not it either.

    2: something like this
    Code:
    procedure TForm1.BitBtn1Click(Sender: TObject);
    var
     Item: TPictureCollectionItem;
     picture : TPicture;
    begin
     picture := TPicture.Create;
     picture.LoadFromFile('c:\windows\Zapotec.bmp');
     try
        Item := TPictureCollectionItem.Create(DXImageList1.Items);
        Item.Picture.Graphic := picture.Graphic;
    
        doneLoading := true;
     finally
       picture.Free;
     end;
    end;
    
    procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
    begin
       if doneLoading then
       begin
          dximagelist1.Items.Items[0].Draw(dxdraw1.Surface,10,10,0);
       end;
       dxdraw1.Flip;
    end;
    3: change draw procedure into
    Code:
    if doneLoading then
       begin
          dximagelist1.Items.Items[0].StretchDraw(dxdraw1.Surface, rect(10,10,200,200), 0);
       end;
    4: look into timebased movement, instead of framebased.

    5: Easiest way would indeed be to use a global var.
    Code:
    activeSpriteList[1].X  := activeSpriteList[0].X
    Hope that helps.

  3. #3
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    DELPHIX Problems. Need help with multiple problems

    Question 2:-

    I've not read Travellers code, but the key thing I found was to finalize the TDXDraw component that the TDXImageList is linked to, load the images, build the colour tables and assign them to the TDXDraw.surface (IIRC) and the initialize the TDXDraw.

    I had this problem during the competition and this was the only way I could make it work.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  4. #4

    DELPHIX Problems. Need help with multiple problems

    I will give these suggestions so far a try and report back. THANKS!

  5. #5

    DELPHIX Problems. Need help with multiple problems

    No.5, yes that is a nice idea. I have implemented a record array, is that what you intended me to use?

    I have figured out no.2. You see I am using the sprite engine, not the draw surface

    code was simple and I should have figured it out:

    dximagelist1.Items[2].picture.LoadFromFile('c:\1.bmp');

    -------

    Unfortunately, the resize is also needed for use with the domove part of the sprite in question. I havent got it to worj yet

    Although it works well for dxdraw on the surface, I have no idea how to get it working with the sprite engine. maybe I have to destroy the sprite and then recreate each time?

    Any ideas? And maybe athena can supply some code?

  6. #6

    DELPHIX Problems. Need help with multiple problems

    I have implemented a record array, is that what you intended me to use?
    What you want to use is up to you. I found it quite easy to use arrays.

    dximagelist1.Items[2].picture.LoadFromFile('c:\1.bmp');
    This assumes you already have reserved an dximagelist item. But yeah, that works as well.

    maybe I have to destroy the sprite and then recreate each time?
    Depending how often this is going to happen, it would slow down your game a lot.

    I'm not sure what you want, but I'd stay away from the TBackground class, and write your own. It's quite easy to draw a tilemap.

    Could you show some code where you're having problems with?

  7. #7

    DELPHIX Problems. Need help with multiple problems

    Difficult to supply code because I don't have any code for the thing in question. I have mnaged to get the game area shrinking properly thanks to your help and by not using tbackground

    Unfortunately The enemy has to be a sprite and thus making him grow from 25 pixels * 25 pixels to 40 * 40 is proving difficult. I would have thought it as easy as height:=height+1; but it seems that delphix only takes this into consideration in the create and not domove of course I could probably animate the growth if not for the fact people are allowed to upload their freinds photo to replace the default enemy picture

    I was rather hoping hori had programmed a special method for this like DoSize hehe but looks like not.

    On other things, I might be able to get away with vsunc and use a permanent 100 fps (only problem being there is some weird phenomina that makes it run at 64 fps (if above an interval of 10) regardless when program is not running from within delphi)

    2b. Is it possible with that draw instead of stretch it centres the image?

    3b. And a very big favour I have to ask you. I really need to get to the bottom off this timer problem. I have uploaded with source and exe a simple test to see if DXtimer is the fault of me or the timer. When you recieve it, you can open the exe, report to me whether it is achieving 1000 ms resolution. If I could be bolder I would like you to then compile the source on your end and then send me back the exe. This will enable me to find out more about the nature of this problem. If you could do that that would be neat!

    http://www.uploading.com/?get=J6DJ9LM3

    Above is the link to the file.

  8. #8

    DELPHIX Problems. Need help with multiple problems

    2b. Is it possible with that draw instead of stretch it centres the image?
    It is: add a trackbar and dximagelist component to your form and c/p the following code. Set trackbar position to say 100 and add an image to the imagelist.
    Code:
    procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
    begin
        dxdraw1.Surface.Fill(0);
        dximagelist1.Items.Items[0].StretchDraw(dxdraw1.Surface, rect(100-trackbar1.Position,100-trackbar1.Position,200+trackbar1.Position,200+trackbar1.Position), 0);
        dxdraw1.Flip;
    end;
    3b: done. Getting 1000ms almost right at startup. Compiled it too, but with the same result.
    I doubt it'll be different on your pc but here's the rarfile.

  9. #9

    DELPHIX Problems. Need help with multiple problems

    Very good. You have answered 1 major question also but this is a serious problem now.

    It is not the compiled exe that matters nor is it delphi or delphix. It is some other factor and no matter what, other peoples delphi apps are not going to run properly on mine or my cousins computer. This means that there will be others like me where the delphi apps will be fundamentally flawed

    How very bizarre....Threaded timers and delphix timer are not running at anwhere near 1ms on certain machines? And if so it may be because directx in Xp, or XP itself is somehow changing the way thread timers operate. Obviously someone needs to look into this issue. I cannot understand why it would be that the timer does not run at the desired speed.

    There is something very wrong here...I have also checked at a mates house, again XP, again nowhere near 1ms.

    I have ran some tests and it seems the following:

    Intervals 1-10 are defaulting to 64 FPS, 11-20 to another fixed FPS and so on....the rates they are fixed at are also not remaining constant. For instance on my cousins machines the 1-10 are defaulting to 100 FPS and then following the same pattern mentioned above. I can't be the only one woth this problem?

    Somone mentioned none NT based machines may be the cause? Is there anyway to make delphi believe it is running on an NT machine (i doubt it), or even better if noone has any idea why this is happening, maybe someone could supply a way of making a timer that can achieve a constant 100 FPS. Which is the best way to do it and have you got any example code?

    ----

    Also, when I said centre and not stretch I meant the actual image as it shrinks stretch draw strteches the image to FIT the size of the height,width. I was wondering weather there was a way to let the image resize but the picture get its ends chopped off, if you see what I mean


    http://www.uploading.com/?get=VXBP9UV9

    That should make it clearer

  10. #10

    DELPHIX Problems. Need help with multiple problems

    Why is it so important to have a timer that runs on 100fps?
    IMO all that matters is how fluent a game runs. And you can have that even at 30fps.

    If I understand you correctly, what you are looking for is a crop function, not a resize. You can do so by drawing a portion of the image. When drawing the surface, dont use clientrect, but your own defined rect.
    ie not
    Code:
    DXDraw1.Surface.Draw(0,0, yourImageSurface.ClientRect, yourImageSurface, false);
    but
    Code:
    DXDraw1.Surface.Draw(0,0, rect(10,10,50,50), yourImageSurface, false);

Page 1 of 5 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •