Chapter 4 programming classroom of sisheng long Shen Lu

Source: Internet
Author: User
Run dixq.netrp2.html first. The main. cpp of the project is the "Basic Framework of the program to be written every time" mentioned in the game programming classroom. Then click compile to run the program. ----------------------------------------

Http://dixq.net/rp/2.html first run a look. The main. cpp of the project is the "Basic Framework of the program to be written every time" mentioned in the game programming classroom. Then click compile to run the program. ----------------------------------------

Http://dixq.net/rp/2.html

Run the command first. The main. cpp of the project is the "Basic Framework of the program to be written every time" mentioned in the game programming classroom. Then click compile to run the program.

------------------------------------------------------------------

---- Main. cpp changes ------

# Define GLOBAL_INSTANCE # include ".. /include/GV. h "int Key [256]; int GetHitKeyStateAll_2 (int token []) {char GetHitKeyStateAll_Key [256]; GetHitKeyStateAll (GetHitKeyStateAll_Key); for (int I = 0; I <256; I ++) {if (GetHitKeyStateAll_Key [I] = 1) GetHitKeyStateAll_InputKey [I] ++; else GetHitKeyStateAll_InputKey [I] = 0;} return 0 ;} int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstanc E, LPSTR lpCmdLine, int nCmdShow) {ChangeWindowMode (TRUE); // zookeeper contains multiple zookeeper if (DxLib_Init () =-1 | SetDrawScreen (DX_SCREEN_BACK )! = 0) return-1; // initialize and set the dual buffer screen while (ProcessMessage () = 0 & ClearDrawScreen () = 0 & GetHitKeyStateAll_2 (Key) = 0 & Key [KEY_INPUT_ESCAPE] = 0) {// notify message manager ← clear the screen ← Save the Key and enter the Escape Key. The ESC Key is not pressed. // here !! ScreenFlip ();} DxLib_End (); return 0 ;}

Note:

Here is a simple code description for beginners and those who don't want to study code like me.

It is mainly used to save the function of key input. First, the main function calls the above function. The input parameter is the defined global variable array Key [256].

In the above function, a char array is defined and then transmitted to the system function GetHitKeyStateAll_Key to obtain the key status.

Then, traverse the char array and compress it to the int array. Then, compress the corresponding keys in the int array ++. If the keys are not pressed, the keys are cleared. (After that, although the two arrays seem to be a bit around)


Okay, the window will be called up. Press ESC and it will exit.

So far, if you are doing well, the preparation is complete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.