Thread: Another game of mine...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    Alright, a couple comments.

    First, the following lines are repeditive in what they do:
    BITMAP *guy = create_bitmap(90, 90)
    guy = load_bmp("cdown.bmp", default_palette);

    The load_bmp function will allocate the memory for the *guy BITMAP, so ya only need to call it.

    Then, at the end of the proggy, don't forget to deallocate it with the destroy_bitmap() function. allegro_exit() may do this for you, but destroying the bitmap is the #1 way to ensure you don't cause a memory leak.

    Now then, the collision detection:
    if ((ex - sx) < 90 && (sy - ey) < 90 && (ey - sy) < 90) ...

    This is a tad confusing, but if I understand correctly, you are trying to say, if the enemy x is within 90 pixels of the sword x and the enemy y is also within 90 pixels of the sword y, then a collision has occured. Here would be the way I would do this:
    if(ex > (sx - 45) && ex < (sx + 45) && ey > (sy - 45) && ey < (sy + 45) ...

    This makes a nice neat box of collision detection, and you aren't worried about negative values and such.

    Hope that helps. (Kind of a late reply, so you may have figured that out already.)

    -Justin

    P.S. Looking good so far. You'll have the next best RPG/Action Adventure going in no time at all. (If you are having a problem with flickering and are running 2K, see this post on some of the quirks of DirectX in full screen.)
    Last edited by Justin W; 12-30-2001 at 06:50 PM.
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open-source Game Project
    By Glorfindel in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 03-24-2009, 01:12 AM
  2. 20q game problems
    By Nexus-ZERO in forum C Programming
    Replies: 24
    Last Post: 12-17-2008, 05:48 PM
  3. Need book to program game into multiplayer...
    By edomingox in forum Game Programming
    Replies: 3
    Last Post: 10-02-2008, 09:26 AM
  4. Try my game
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 09-15-2004, 11:58 AM
  5. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM