Thread: Moving a bitmap around the screen -- SMOOTHLY

  1. #16
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Two things for clarity;


    1. PeekMessage() will return imediately from the msg que, GetMessge() will wait in the que until a message arrives.

    So PeekMessage() is used in (game) loops where the main task is not just getting user input.


    2. GetAsyncKeyState() gets the current state of the key. The message may not yet have been posted to the que so beware you do not process a second time.

    GetKeyboardState() will get all the keys. and record the results into an array. the array can then be indexed by the VK_ key codes ie

    Code:
    BYTE     byteKeyArray[256];
    
    GetKeyboardState(&byteKeyArray);
    UpdateShip(byteKeyArray[VK_UP], byteKeyArray[VK_DOWN], ect );
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  2. #17
    Registered User
    Join Date
    Jan 2003
    Posts
    7
    One NASTY flaw in all your code is your window procedure, it uses the break; command instead of return 0;. If your window procedure doesn't return anything, which it won't for trapped messages, things can get messy. Instead of this:

    switch (message)
    {
    case WM_PAINT:
    // Paint
    break;
    case WM_DESTROY:
    PostQuitMessage (0);
    break;
    default:
    return DefWindowProc (hwnd, message, wParam, lParam);
    }

    Try this:

    switch (message)
    {
    case WM_PAINT:
    // Paint
    return 0;
    case WM_DESTROY:
    PostQuitMessage (0);
    return 0;
    }
    return DefWindowProc (hwnd, message, wParam, lParam);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Feedback: Functional Specification Wording
    By Ragsdale85 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2006, 04:56 PM
  2. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10:18 PM
  3. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  4. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  5. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM