简体   繁体   中英

Making Width and Height of a character in console equal in terms of pixels (C)

I'm making a program in C (simple snake game).

I'm using window.h and came across an inconvenience.

I'm using COORD's and SetConsoleCursorPosition to move about the cursor. However, moving one y coordinate is almost the same as moving two x coordinates in terms of how many pixels each represents.

For example, this square window has a width of 80 and height of 40 in terms of the cursor position coordinates. Also, you can clearly see the contraction (and therefore reduction of apparent speed of the snake) when moving sidewards in the images below.

Is there any efficient solution to this so that the pixel size of one move in the x direction is the same as one move in the y direction.

Many thanks.

[ 蛇垂直移动 [1]

蛇水平移动

The SetCurrentConsoleFontEx function lets you specify the console font size in the lpConsoleCurrentFontEx 's dwFontSize member. There you can set the font width and height be the same.

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