简体   繁体   中英

sdl c++ keyboard input using bitmap

我必须编写一个程序让我写程序,然后我将在键盘上按的所有字母都可以从位图图像中获取片段,该片段可以响应我所按的字母。我不能仅将SDL_ttf与c ++一起使用SDL_image。

  1. Find a nice bitmap full of ASCII glyphs, like this one .

  2. Load into a SDL_Surface using SDL_image.

  3. In your keyboard handling loop grab the ASCII value when a key is hit.

  4. Use the ASCII value to find the correct 8x8 block in the bitmap to copy from.

  5. Use SDL_Blit with the appropriate src rect (from step 4) and dst x/y to blit to the screen

  6. Increment your dst x value by 8. Wrap if it gets "too large" and then increment your dst y by 8.

  7. BAM! Cheesy graphical text input. Bonus points for handling backspace and/or carriage return.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM