Results 1 to 5 of 5

Thread: 10 tons of questions

  1. #1

    10 tons of questions

    It?¢_Ts been about 3 years since I?¢_Tve programmed in Delphi so I?¢_Tm in need of a bit of help. I'm not using anything but Clootie's headers, no delphix, no fulb or bass or any weird wrapper for directx stuff.

    (Hail goes to Clootie, omg you are so freaking amazing with all the directx headers)

    So I have a pretty good working asteroids clone. Not to bad. But now it?¢_Ts getting hard to do things that I?¢_Tm not finding any information on tutorials or even C examples.

    Collision Detection:
    I keep reading up on using pixel precise collision detection, and I completely get it. I can easily create a rect of the overlapping sprites. My code already knows which sprites need to check to see if they collide. However, I can't find any examples of exactly how to implement it. Do I actually blt the two images? If so I need to blt them as bitmasks right? How do I create bitmasks of images? Once that?¢_Ts all done, I need to read through all the pixels, I found some code to do that, but if I'm using bitmasks, what?¢_Ts it actually going to look like? I mean I?¢_Tm not reading 8/16/24/32 bits of color. Also what does the blt command look like for xor'ing it to the screen?

    I'm using dXdisplay.CreateFullScreenDisplay(Handle, Width, Height, 16) to create my DirectX Display(surface). How do i specify the refresh rate?

    Any source, links and/or help would be greatly appreciated!

  2. #2

    10 tons of questions

    One thing I like to do when I'm using per-pixel collision detection is to have MyBitMask1: array[1..sprite.width, 1..sprite.height] of boolean for all sprites. You can fill these arrays programatically like this:

    if sprite.pixels[I, J] = MyColorKey then
    MyBitMask1[I, J] := true;

    obviously you wouldn't use the pixels property because that would be way too slow. But speed doesn't matter all that much as the arrays are only filled once upon program initialization.

    Then use bounding-box collision to see if two sprites collide, get the overlapping-rect and do this:

    Code:
    CollisionTest: Boolean;
    ..
    begin
      CollisionTest := false;
      for J := OverlapRect.Top to OverlapRect.Bottom do
      begin
        for I := OverlapRect.Left to OverlapRect.Right do
        begin
           if MyBitMask1[I, J] and MyBitMask2[I, J] then
           begin
             CollisionTest := true;
             Break;
           end;
        end;
      end;
      if CollisionTest then
      ...
    end;
    obviously that code would have to be adjusted...

    Hope that helps.
    Ask me about the xcess game development kit

  3. #3

    10 tons of questions

    OMG why thats like a billion times easier then what i was thinking. What was i thinking, blt'ing images, then checking pixel by pixel... wow. I'm preloading all my images/surfaces into a buffer, then whenever some is needed i just create a new object(x/y coords) linked to the surface to draw. 1 Surface drawn more then once.

    Since I preload all my bitmaps using tpicture, its a simple task of creating the bitmasks of the tpicture.tbitmaps.tcanvas.pixels. Oh talk about easy. Wow Thanks a TON!

    Now if anyone has an example of setting the refresh rate of a full screen surface, i'd be set.

  4. #4

    10 tons of questions

    Inside "CreateFullScreenDisplay" procedure calls
    &nbsp&nbsphr := m_pDD.SetDisplayMode( dwWidth, dwHeight, dwBPP, 0, 0 );
    So if you clone this procedure (CreateFullScreenDisplay) you can modify it to something like this:
    &nbsp&nbsphr := m_pDD.SetDisplayMode( dwWidth, dwHeight, dwBPP, MyNewRefreshRate, 0 );
    There are only 10 types of people in this world; those who understand binary and those who don't.

  5. #5

    10 tons of questions

    Sweeeeeeeeet. I found some code somewhere that enumerates all the hardwares resolutions and the refresh rates available for those resolutions.

    This has been the most useful forum I have ever encountered.

    EAP

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
  •