Results 1 to 12 of 12

Thread: #include <windows.h> failure...KeyState

  1. #1

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking #include <windows.h> failure...KeyState

    Hi
    Just having a slight problem writing a simple Snake game (just in command view, with cout<< etc.

    I have most of the game finished, but i got to trying to get input.

    The game was working fine until i added GetAsyncKeyState, and added: #include <windows.h>. Then the game still compiled, just as soon as it opened it threw an error.
    Any suggestions?
    Is there any way i can get Keyboard input without using windows.h, and without having to wait for the input?
    Thanks
    sql_lall

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    What error? What's the code? What's the debugger saying?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking hmm..

    hmm... u see, thats the problem. It doesn't give much info about the error.

    The debugger says nothing...the program compiles well with no problems. Just that as soon as i add #include <windows.h>, and compile and execute the program, a msgbox comes up saying "Error, log created". I think its a Dr. Watson error, if that helps.

    However, i don't have the code here atm, will post later when i run it again
    sql_lall

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Have you actually used a debugger on the app?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking ok...

    here's the error i get:

    "snake.exe has generated and will be closed by Windows. You will need to restart the program.
    An error log is being created"

    The bad thing is that i am making int on a school computer, so:
    1) I can't access debugging
    2) I can't access the error log

    attached is the .cpp file...
    Attached Files Attached Files
    sql_lall

  6. #6
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    Compiled and ran fine for me (except I couldn't move the snake, but I didn't check to see why, or if I was pressing the right buttons)
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    And what does it look like with GetAsyncKeyState added?


    BTW, since system() creates a new process, it is awfully slow in computer terms. Maybe you can find an alternative.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking hmmm..

    Check the PauseClock() funciton....

    Thats where there's a pause to have correct frame-rate, and any input is received...

    The GetAsyncKeyState funciton is there too...

    oh, and sunburnt, it doesn't fully work yet, but when it does i'll post it again uf u want me too. U see, this is for a tutorial i will be running, so any flaws in my code (when finished) it would be good if other picked them up
    sql_lall

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Oh, right...


    I remember many problems with GetAsyncKeyState in console programs. Very many. The never got resolved. Sorry, don't know how to help you there.

    It definitly shouldn't crash though...


    There is something you can do with input buffers which doesn't block, let me try it out and get back to you.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking almost resolved

    ok, i think it must be something to do with the school's network restrictions. I got it working fine at home, but the same error pops up whenever i the same code at school.

    Probably not allowed to #include <windows.h>, cos i could be hacking, not that I know how...

    Is there any other way to get key input? I've seen stuff like kbhit() and getchar(), but never in a working program....
    sql_lall

  11. #11
    Junior Member
    Join Date
    Aug 2003
    Location
    /dev/null
    Posts
    19
    this is the fault of schools/colleges being totaly retarded and not actualy alowing you to use anything that is even remotly usefull.. they will block out ANYTHING that will allow you to make a decent prog, but anything that you wont normaly use... they allow...

    some at the college i go to
    goto cliff
    :cliff
    jmp 0xFFFFFFFF

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Could simply be a faulty windows.h too, or faulty include libs. That actually sounds very probable.


    Unfortunatly the thing I tried did not work.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width