| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1892 人关注过本帖
标题:求助一个问题 关于方向键操纵的
取消只看楼主 加入收藏
fpyyyy
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-1-11
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
求助一个问题 关于方向键操纵的
想要使目标人物用方向键左右移动 检查没有问题 但是小人仍旧没法使用方向键 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();






}
搜索更多相关主题的帖子: include 左右 
2016-01-11 09:31
快速回复:求助一个问题 关于方向键操纵的
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025732 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved