求助一个问题 关于方向键操纵的
想要使目标人物用方向键左右移动 检查没有问题 但是小人仍旧没法使用方向键 btw 还有一个问题怎么使小人初始位置设定到(100,750)x_position y_position.
#include <graphics_lib.h>
#include <stdio.h>
#include <conio.h>
int x_position, y_position,x,y;
int main(void)
{
/* Declare two variables for the x and y positions */
/* Limit the range of the move of the stick man */
if (x_position>1400)
(x_position=1400);
if(x_position<80)
(x_position=80);
if(y_position>800)
(y_position=800);
if(y_position<50)
(y_position=50);
/* Open a graphics window */
/* Make it 640 pixels wide by 480 pixels high */
initwindow(1500, 1000);
Kamen_Rider_cyclone();
int key_press;
do
{
key_press=getch();
if(key_press==75)
Kamen_Rider_cyclone(x_position-=5, y_position);
else if(key_press==77)
Kamen_Rider_cyclone(x_position+=5, y_position);
else
Kamen_Rider_cyclone(x, y_position);
}
while
(getch()!=13);
update_display();
/* move the contents of the screen buffer to the display */
update_display();
/* Wait for a key press */
getch();
/* remove the display */
closegraph();
return 0;
}
void Kamen_Rider_cyclone()
{
x_position=x;
y_position=y;
/* draw a circle on the screen buffer
at x_position, y_position
with radius 10 and line thickness 2 */
/* choose green pen colour */
setcolor(GREEN);
/* draw a circle on the screen buffer
at x_position, y_position
with radius 10 and line thickness 2 */
filled_rectangle(0,0,1500,1000,BLACK);
circle(x_position, y_position, 1, 100);
line(x_position, y_position+25, x_position, y_position+125,7);
line(x_position -50, y_position +80, x_position +50, y_position +80,6);
line(x_position, y_position +125, x_position +50, y_position +200,6);
line(x_position, y_position +125, x_position -50, y_position +200,6);
setcolor(WHITE);
line(x_position -75, y_position -50, x_position -15, y_position -10,5);
line(x_position -15, y_position -10, x_position, y_position -30,5);
line(x_position +13, y_position -10, x_position, y_position -30,5);
line(x_position +75, y_position -50, x_position +15, y_position -10,5);
line(x_position, y_position -55, x_position, y_position +50,5);
/* choose red pen colour */
setcolor(RED);
circle(x_position -20, y_position +5, 7, 17);
circle(x_position +20, y_position +5, 7, 17);
line(0, 1000,2000, 1000,100);
/* choose black pen colour */
setcolor(BLACK);
circle(x_position -20, y_position +5, 15, 2);
circle(x_position +20, y_position +5, 15, 2);
line(x_position, y_position -55, x_position, y_position +50,1);
update_display();
}