Tuesday, July 5, 2011

GDI+ Game Programming Series - Part 6 - Terrain Collision

[Watch in 720p High Definition]


  1. Hello. I'm beginner in Visual Basic 2010, but I used to create some programs in VB6. Recently decided to make my own RPG game, so I've seen all your game tutorials and downloaded part6 source code. And there is a problem - on my computer your game runs really slow (Ticks=0to2 and TPS=2). There is a message in 'Immediate Window':
    'A first chance exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll'.
    Am I missing something? Any help welcome because now my game is 'on hold'.
    Many thanks for great tutorials.

  2. Hello, Konrad13x!

    :-( I've noticed this on some other machines as well. I think that there may be a setting in my source files that is causing it to not operate properly on some other machines, or possibly the conversion from 64bit to 32bit.

    Try creating a new project on your machine and copying just the source text from my program to your new application. I'm curious if this will fix it.

    The "First chance exceptions" are pretty normal, so I don't think that is it.

    I hope this helps!

  3. I did what you suggested, but program is still running slow. I try it on two machines with Vista 32bit and 64bit.

  4. That is strange... :-(

    Can I ask what your tile sizes are, and how many you're painting in your X/Y loop?

  5. As I said before, I'm new to VB10. So basically I downloaded your 'tutorial no. 6' and run it. I didn't change anything - tile size is 32 and map 20x15.

  6. I was curious so I've just checked yours other tutorials one by one right from beginning.

    The 'Visual Basic Game Programming Tutorial - Part 3 - Graphics and Tile Mapping' is the first 'slow one'.

    As a final check I opened 'updated tutorial no3' ("Rad Marvin" one) and used: map, tille set, title size from 'slow one'. Even when I increased map dimension to 30x30 whole program runs fine.

  7. I'm thinking that your CPU may be bogging down. Are you on a dual-core or quad-core machine?

    What I would try doing next is dropping your window size and instead of using 20x15 tiles, try half of that for a total of 320x256 pixels.

    The window may appear small, but then you can adjust your monitor resolution to its lowest setting. This should make the game screen appear significantly larger and should also give you a notable increase in your TPS.

    I actually have some code for adjusting your resolution automatically, then returning it back to normal when you close the game window.

    This might help you a lot. 640x480 seems to be an awful lot for GDI+ to handle on some machines. My work machine handles it fine, but my home computer bogs down like yours.

  8. Thank you for reply.
    I'm using Intel dual-core E8400 3.6GHz, 8GB RAM and Vista64.

    Because I'm doing turn based RPG/strategy so don't have to re-draw map continously, but only do that when key/mouse/button is pressed.

    I decided to use your 'game tutorial 3' as a backbone - did some modifications, adapted code from yours recent tutorials.

    Now I'm pretty happy with the result: set window size to 1280x800 and draw 19x15 rectangles using 50pixels tiles.

    Movement speed is ok, 'in-game editor' is working fine, game window refresh itself ok as well.

    Thank you again.

  9. Konrad13x, I have wonderful news! :-D The VB/XNA barrier has finally come crashing down.

    Kalamus1 did an adaptation of my code to XNA, and directed me to a new tutorial on how to begin with XNA on VB.

    That miserable 22 TPS (or 0-1 in your case) has shot up to an astounding 3900TPS, with XNA!

    This is using my code, but scrapping the GDI out and replacing it with XNA calls.

    You can check out the source from his link: http://dl.dropbox.com/u/8339371/XNAGameTest.zip

    You have pretty good hardware, so I would expect similar results for you.

    The XNA 4 Refresh SDK from Microsoft is available, here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27153

    It IS required to use XNA with VB.

    To see the tutorials that we are using, go here:

    I wish you luck! :-D



Please be respectful. Thank you!