c++ void SetColor(double r, double g, double b)函数的问题

黄大仙儿 2014-04-13 08:49:30
不太了解c++ 这个是不是也是RGB?那为什么不用int而用double啊?
值有范围吗?下面这种是都行吗?
0.5900, 0.2700, 0.0800
0.1,999,0.1

我是在看python的东西时候,看设置颜色,就是这种
mars_orange = (0.5900, 0.2700, 0.0800)
green_yellow = (0.6784, 1.0000, 0.1843)
不懂为什么用浮点数
看描述看到的是
V.SetColor(float, float, float)
C++: void SetColor(double r, double g, double b)
所以来问问
...全文
333 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2014-04-14
  • 打赏
  • 举报
回复
引用 8 楼 huang369509940 的回复:
[quote=引用 7 楼 zhao4zhong1 的回复:] 猜也能猜到是0~1吧。
关键是我输入什么值它都能显示出来,比如255,0,0或者我上面提到的0.1,999,0.1[/quote] 你不会看看255,0,0和1.0,0.0,0.0显示出来有什么区别?
赵4老师 2014-04-14
  • 打赏
  • 举报
回复
GDI: Color Functions The following functions are used with color. AnimatePalette CreateHalftonePalette CreatePalette GetColorAdjustment GetNearestColor GetNearestPaletteIndex GetPaletteEntries GetSystemPaletteEntries GetSystemPaletteUse HTUI_ColorAdjustment HTUI_DeviceColorAdjustment RealizePalette ResizePalette SelectPalette SetColorAdjustment SetPaletteEntries SetSystemPaletteUse UnrealizeObject UpdateColors GDI+: Color Constructors -------------------------------------------------------------------------------- This topic lists the constructors of the Color class. For a complete class listing, see Color Class. Color::Color(BYTE,BYTE,BYTE,BYTE) Color::Color() Color::Color(BYTE,BYTE,BYTE) Color::Color(ARGB) --------------------------------------------------------------------------------
richyhuang 2014-04-14
  • 打赏
  • 举报
回复
引用 4 楼 huang369509940 的回复:
[quote=引用 1 楼 richyhuang 的回复:] 这个跟c++有关系吗
c++里没这个函数吗?[/quote] 这个是特定环境使用的函数,跟c++本身没有关系,你应该看那种环境编程的.比如dos编程,windows编程
黄大仙儿 2014-04-14
  • 打赏
  • 举报
回复
引用 7 楼 zhao4zhong1 的回复:
猜也能猜到是0~1吧。
关键是我输入什么值它都能显示出来,比如255,0,0或者我上面提到的0.1,999,0.1
赵4老师 2014-04-14
  • 打赏
  • 举报
回复
猜也能猜到是0~1吧。
黄大仙儿 2014-04-13
  • 打赏
  • 举报
回复
引用 3 楼 Indestiny 的回复:
据我观察,浮点数范围为0~1 green_yellow = (0.6784, 1.0000, 0.1843) 就代表rgb颜色#ADFF2F嘛,乘个255就好了 用浮点数而不用定点数可能是因为颜色深度不总是24
颜色深度是什么东西。。
黄大仙儿 2014-04-13
  • 打赏
  • 举报
回复
引用 2 楼 buyong 的回复:
看你这SetColor源代码
没找到、、、
黄大仙儿 2014-04-13
  • 打赏
  • 举报
回复
引用 1 楼 richyhuang 的回复:
这个跟c++有关系吗
c++里没这个函数吗?
奉壹 2014-04-13
  • 打赏
  • 举报
回复
据我观察,浮点数范围为0~1 green_yellow = (0.6784, 1.0000, 0.1843) 就代表rgb颜色#ADFF2F嘛,乘个255就好了 用浮点数而不用定点数可能是因为颜色深度不总是24
buyong 2014-04-13
  • 打赏
  • 举报
回复
看你这SetColor源代码
richyhuang 2014-04-13
  • 打赏
  • 举报
回复
这个跟c++有关系吗
#include #include #include #include #include #include #define G 9.8 /*重力加速度*/ #define PI 3.141593 /*圆周率*/ #define L1 60 /*小屋运动的范围*/ #define T1 100 #define R1 200 #define B1 450 #define AMD1 5 /*修订数*/ #define AMD2 1.78 /*修订数*/ /*鼠标信息宏定义*/ #define WAITING 0xff00 #define LEFTPRESS 0xff01 #define LEFTCLICK 0xff10 #define LEFTDRAG 0xff19 #define RIGHTPRESS 0xff02 #define RIGHTCLICK 0xff20 #define RIGHTDRAG 0xff2a #define MIDDLEPRESS 0xff04 #define MIDDLECLICK 0xff40 #define MIDDLEDRAG 0xff4c #define MOUSEMOVE 0xff08 int Keystate; int MouseExist; int MouseButton; int MouseX; int MouseY; int up[16][16],down[16][16],mouse_draw[16][16],pixel_save[16][16]; void MouseMath()/*计算鼠标的样子*/ { int i,j,jj,k; long UpNum[16]={ 0x3fff,0x1fff,0x0fff,0x07ff, 0x03ff,0x01ff,0x00ff,0x007f, 0x003f,0x00ff,0x01ff,0x10ff, 0x30ff,0xf87f,0xf87f,0xfc3f }; long DownNum[16]={ 0x0000,0x7c00,0x6000,0x7000, 0x7800,0x7c00,0x7e00,0x7f00, 0x7f80,0x7e00,0x7c00,0x4600, 0x0600,0x0300,0x0300,0x0180 }; for(i=0;i<16;i++) { j=jj=15; while(UpNum[i]!=0) { up[i][j]=UpNum[i]%2; j--; UpNum[i]/=2; } while(DownNum[i]!=0) { down[i][jj--]=DownNum[i]%2; DownNum[i]/=2; } for(k=j;k>=0;k--) up[i][k]=0; for(k=jj;k>=0;k--) down[i][k]=0; for(k=0;k<16;k++)/*四种组合方式*/ { if(up[i][k]==0&&down;[i][k]==0) mouse_draw[i][k]=1; else if(up[i][k]==0&&down;[i][k]==1) mouse_draw[i][k]=2; else if(up[i][k]==1&&down;[i][k]==0) mouse_draw[i][k]=3; else mouse_draw[i][k]=4; } } mouse_draw[1][2]=4;/*特殊点*/ } /*鼠标光标显示*/ void MouseOn() { int x=MouseX,y=MouseY; int i,j; int color; for(i=0;i<16;i++)/*画鼠标*/ { for(j=0;j<16;j++) { pixel_save[i][j]=getpixel(x+j,y+i);/*保存原来的颜色*/ if(mouse_draw[i][j]==1) putpixel(x+j,y+i,0); else if(mouse_draw[i][j]==2) putpixel(x+j,y+i,15); } } } /*隐藏鼠标*/ void MouseOff() { int i,j,x,y,color; x=MouseX; y=MouseY; for(i=0;i<16;i++)/*原位置异或消去*/ for(j=0;j<16;j++) { if(mouse_draw[i][j]==3||mouse_draw[i][j]==4) continue; color=getpixel(x+j,y+i); putpixel(x+j,y+i,color^color); putpixel(x+j,y+i,pixel_save[i][j]); } } /*鼠标状态值初始化*/ void MouseReset() { _AX=0x00; geninterrupt(0x33); } /*设置鼠标左右边界 lx:左边界 rx:右边界 */ void MouseSetX(int lx,int rx) { _CX=lx; _DX=rx; _AX=0x07; geninterrupt(0x33); } /*设置鼠标上下边界 uy:上边界 dy:下边界 */ void MouseSetY(int uy,int dy) { _CX=uy; _DX=dy; _AX=0x08; geninterrupt(0x33); } /*设置鼠标当前位置 x:横向坐标 y:纵向坐标 */ void MouseSetXY(int x,int y) { _CX=x; _DX=y; _AX=0x04; geninterrupt(0x33); } /*获取鼠标按下键的信息*/ /*是否按下左键 返回值: 1=按下 0=释放*/ int LeftPress() { _AX=0x03; geninterrupt(0x33); return(_BX&1); } /*是否按下中键 返回值同上 */ int MiddlePress() { _AX=0x03; geninterrupt(0x33); return(_BX&4); } /*是否按下右键 返回值同上 */ int RightPress() { _AX=0x03; geninterrupt(0x33); return(_BX&2); } /*获取鼠标当前位置*/ void MouseGetXY() { _AX=0x03; geninterrupt(0x33); MouseX=_CX; MouseY=_DX; } /*鼠标按键情况,返回0表示只移动,返回1表示左右键同时按下,2表示只按了左键,3表示只按了右键*/ int MouseStatus() { int x,y; int status; int press=0; int i,j,color; status=0;/*默认鼠标没有移动*/ x=MouseX; y=MouseY; while(x==MouseX&&y==MouseY&&status;==0&&press;==0) { if(LeftPress()&&RightPress;()) press=1; else if(LeftPress()) press=2; else if(RightPress()) press=3; MouseGetXY(); if(MouseX!=x||MouseY!=y) status=1; } if(status)/*移动情况才重新显示鼠标*/ { for(i=0;i<16;i++)/*原位置异或消去*/ for(j=0;j<16;j++) { if(mouse_draw[i][j]==3||mouse_draw[i][j]==4) continue; color=getpixel(x+j,y+i); putpixel(x+j,y+i,color^color); putpixel(x+j,y+i,pixel_save[i][j]); } MouseOn();/*新位置显示*/ } if(press!=0)/*有按键的情况*/ return press; return 0;/*只移动的情况*/ } /*定义玩家的结构体*/ struct Ren{ int x,y; int life; int color; int lr;/*1表示左,2表示右。*/ }; /*绘制游戏界面*/ void Desktop() { setcolor(14); line(320,0,320,480); rectangle(L1-20,T1-40,R1+20,B1+10); rectangle(640-(R1+20),(T1-40),640-(L1-20),B1+10); outtextxy(25,20,"P1"); outtextxy(345,20,"P2"); } /*把一个数字n转换成字符串,并存储在a中,带符号+-*/ void numtostr(int n,char a[5]) { int w,e; e=n; n=abs(n); a[3]=(n)+'0'; w=n/10; a[2]=(w)+'0'; w=w/10; a[1]=(w)+'0'; a[4]='\0'; if(e<0) a[0]='-'; else a[0]='+'; } /*把速度和角度装换成字符串输出*/ void AngleSpeed(double s,double angle) { int ss,aa; char zzs[5],zza[5]; int left,top,right,bottom; left=275; top=50; right=left+90; bottom=top+10; ss=(int)(s); aa=(int)((angle)*180/PI); numtostr(ss,zzs); numtostr(aa,zza); setfillstyle(1,15); setcolor(10); bar(left,top,right,bottom); outtextxy(left+5,top+3,zzs); outtextxy((left+right)/2+5,top+3,zza); circle(right-6,top+3,2); } /*实现人机对抗的函数*/ void Fire (int a[4],double *v,double *angle,int n)/*a数组存放对射的两点,v和angle存放机器射击的角度和速度,n表式机器射击的准确度*/ { int t; double vx,vy; double sx,sy; int m; m=12*4/n; randomize(); m=random(m)-m/2; t=20; sx=(double)(a[2]-a[0]); sy=(double)(a[3]-a[1]); vx=sx/(double)(t); vy=(sy-0.5*PI*(double)(t*t))/(double)(t); *angle=atan((-vy)/vx); *v=sqrt(vx*vx+vy*vy); *v=(*v)*(AMD2+0.01*(double)(m)); AngleSpeed(*v,*angle); } /*绘制生命线的函数*/ void LifePicture(int life,int color,int location) { char lm[5]; int l,t,r,b; l=50; t=20; r=l+200; b=t+10; numtostr(life,lm); setfillstyle(1,color); setcolor(15); if(location==1||location==3) { bar(l,t,r,b); setfillstyle(1,4); bar(l,t+(b-t)/4,l+life,t+3*(b-t)/4); setfillstyle(1,color); bar(r+10,t,r+50,b); outtextxy(r+10+5,t+2,lm); } else { l=320+50; r=l+200; bar(l,t,r,b); setfillstyle(1,4); bar(l,t+(b-t)/4,l+life,t+3*(b-t)/4); setfillstyle(1,color); bar(r+10,t,r+50,b); outtextxy(r+10+5,t+2,lm); } } /*绘制小屋的函数*/ void RenPicture(int x,int y,int color) { setcolor(color); setwritemode(1); line(x,y-40,x-10,y-30);/*画头*/ line(x,y-40,x+10,y-30); line(x-10,y-30,x+10,y-30); line(x-5,y-30,x-5,y-10);/*画脖子*/ line(x+5,y-30,x+5,y-10); line(x-20,y-10,x+20,y-10);/*画身子*/ line(x-20,y+10,x+20,y+10); line(x-20,y-10,x-20,y+10); line(x+20,y-10,x+20,y+10); } /*绘制箭的函数*/ void PictureBullets (int wx,int wy,int tx,int ty) { setcolor(RED); line(wx,wy,tx,ty); line(wx-1,wy-1,tx,ty); line(wx+1,wy+1,tx,ty); } /*绘制小屋上箭的函数*/ void InitialArrow (int x,int y,int a[4]) { int addx,addy; addx=(a[2]-a[0])/6; addy=(a[3]-a[1])/6; PictureBullets(x+addx,y+addy,x,y); } /*判断点qx,qy在直线的什么位置*/ int PointPlace(int qx,int qy,int x1,int y1,int x2,int y2)/*返回0表示在直线上,当斜率存在时:1表示在直线的上面,2表示在直线的下面,当斜率不存在时:3表示在左面,4表示在右面*/ { int s; if(x1==x2) { if(qxx1) return 4; else return 0; } else { s=(int)(((double)(y1-y2))/((double)(x1-x2))*((double)(qx-x1))+(double)(y1)); if(qys) return 2; else return 0; } } /*根据两点坐标计算出两点距离和斜率。*/ void DistanceAngle (int twoxy1[4],double *distance,double *angle) { double a,b; if(twoxy1[0]!=twoxy1[2]) { a=(double)((double)((double)twoxy1[3]-(double)twoxy1[1])/(double)((double)twoxy1[0]-(double)twoxy1[2])); *angle=atan(a); if(twoxy1[0]double)((double)(twoxy1[3]-twoxy1[1])*(double)(twoxy1[3]-twoxy1[1])+(double)(twoxy1[2]-twoxy1[0])*(double)(twoxy1[2]-twoxy1[0])); *distance=sqrt(b); } /*由速度角度算sx,sy随时间的变化*/ void RelativePosition(int *sx,int *sy,double v,double angle,double t) { *sx=(int)((v*cos(angle))*t); *sy=(int)((v*sin(angle))*t-0.5*G*t*t); } /*用鼠标画一条直线,把直线的两点坐标放在twoxy数组内。*/ void TwoPoints(int twoxy[4],int dx,int dy) { int i,q=1; int ddx=dx,ddy=dy; double speed=0.0,angle=0.0; twoxy[0]=0; twoxy[1]=0; setcolor(13); line(dx,dy+30,dx,dy-30); line(dx-30,dy,dx+30,dy); setcolor(4); MouseOn();/*显示鼠标*/ setwritemode(1); i=0; while(q) { if(i==1) { MouseOff(); DistanceAngle(twoxy,&speed;,∠); AngleSpeed(speed/AMD1,angle); InitialArrow (ddx,ddy,twoxy); setcolor(4); line(twoxy[0],twoxy[1],twoxy[2],twoxy[3]); MouseOn(); if((twoxy[2]!=MouseX)||(twoxy[3]!=MouseY)) { twoxy[2]=MouseX; twoxy[3]=MouseY; MouseOff(); DistanceAngle(twoxy,&speed;,∠); AngleSpeed(speed/AMD1,angle); InitialArrow (ddx,ddy,twoxy); setcolor(4); line(twoxy[0],twoxy[1],twoxy[2],twoxy[3]); MouseOn(); } } if(MouseStatus()) { sound(1000);/*响声函数*/ delay(10000); nosound(); delay(1000000); delay(1000000); delay(1000000); delay(1000000); if(i==0) { twoxy[0]=MouseX; twoxy[1]=MouseY; twoxy[2]=MouseX; twoxy[3]=MouseY; i=1; } else { MouseOff(); DistanceAngle(twoxy,&speed;,∠); AngleSpeed(speed/AMD1,angle); InitialArrow (ddx,ddy,twoxy); setcolor(4); line(twoxy[0],twoxy[1],twoxy[2],twoxy[3]); setcolor(13); line(dx,dy+30,dx,dy-30); line(dx-30,dy,dx+30,dy); q=0; i=0; } } } } /*发射箭,speed1和speed2控制速度,返回中弹位置*/ int Launch(int lx,int ly,int tx,int ty,int hm,int grade) { double speed1=0.01; int speed2=1000; int a[4]; int xx[2],xy[2]; double s=0.0,angle=0.0,t=0.0; lx=lx;ly=ly-50; if(hm==3) { a[0]=lx; a[1]=ly; a[2]=tx; a[3]=ty; Fire (a,&s,∠,grade); } else { TwoPoints(a,lx,ly); DistanceAngle(a,&s,∠); s=s/AMD1; } RelativePosition(&xx;[0],&xy;[0],s,angle,t-1); RelativePosition(&xx;[1],&xy;[1],s,angle,t); for(t=0.0;ly-xy[1]<480;t=t+speed1) { RelativePosition(&xx;[0],&xy;[0],s,angle,t-1); RelativePosition(&xx;[1],&xy;[1],s,angle,t); if(PointPlace(lx+xx[1],ly-xy[1],tx,ty-40,tx+10,ty-30)==2&&PointPlace;(lx+xx[1],ly-xy[1],tx,ty-40,tx-10,ty-30)==2&&PointPlace;(lx+xx[1],ly-xy[1],tx-10,ty-30,tx+10,ty-30)==1) { sound(4000);/*响声函数*/ delay(10000); nosound(); return 1; } if(PointPlace(lx+xx[1],ly-xy[1],tx-5,ty-30,tx+5,ty-30)==2&&PointPlace;(lx+xx[1],ly-xy[1],tx-5,ty-10,tx+5,ty-10)==1&&PointPlace;(lx+xx[1],ly-xy[1],tx-5,ty-30,tx-5,ty-10)==4&&PointPlace;(lx+xx[1],ly-xy[1],tx+5,ty-30,tx+5,ty-10)==3) { sound(3000);/*响声函数*/ delay(10000); nosound(); return 2; } if(PointPlace(lx+xx[1],ly-xy[1],tx-20,ty-10,tx-20,ty+10)==4&&PointPlace;(lx+xx[1],ly-xy[1],tx+20,ty-10,tx+20,ty+10)==3&&PointPlace;(lx+xx[1],ly-xy[1],tx-20,ty-10,tx+20,ty-10)==2&&PointPlace;(lx+xx[1],ly-xy[1],tx-20,ty+10,tx+20,ty+10)==1) { sound(2000);/*响声函数*/ delay(10000); nosound(); return 3; } if(ly-xy[1]<1) { delay(speed2); continue; } if(lx+xx[1]<1||lx+xx[1]>640-1) { return 0; } PictureBullets (lx+xx[0],ly-xy[0],lx+xx[1],ly-xy[1]); delay(speed2); PictureBullets (lx+xx[0],ly-xy[0],lx+xx[1],ly-xy[1]); } return 0; } /*小屋移动的函数*/ int MoveRen(struct Ren *p) { int a,k=19200,b=0,d; int q=1; randomize(); for(;q;) { if(b==1) { p->lr=3; } RenPicture(p->x,p->y,p->color); if(p->lr==3) { b=1; delay(10000); delay(10000); delay(10000); delay(10000); delay(10000); delay(10000); //sleep(1); d=random(10); if(d==0) k=19200; if(d==1) k=19712; if(d==2) k=18432; if(d==3) k=20480; if(d==4) k=7181; p->lr=1; } else { k=bioskey(0); } RenPicture(p->x,p->y,p->color); switch(k){ case 19200: /*按向左键*/ a=(p->x)-5; if(p->lr==1) { if(a>L1&&ax=a; break; } } else { if(a>640-R1&&a<640-L1) { p->x=a; break; } } break; case 19712: /*按向右键*/ a=(p->x)+5; if(p->lr==1) { if(a>L1&&ax=a; break; } } else { if(a>640-R1&&a<640-L1) { p->x=a; break; } } break; case 18432: /*按向上键*/ a=(p->y)-5; if(p->lr==1) { if(a>T1&&ay=a; break; } } else { if(a>T1&&ay=a; break; } } break; case 20480: /*按向下键*/ a=(p->y)+5; if(a>T1&&ay=a; } break; case 7181: /*enter键的扫描码*/ if(b==1) p->lr=3; q=0; break; case 283: return 0; } } RenPicture(p->x,p->y,p->color); return 1; } /*游戏开始前画面*/ int GameStar()/*返回1表示单人游戏初级,2表示单人游戏中级,3表示单人游戏高级,4表示两人对战,5表示退出游戏*/ { int q,k,h=0; for(;1;) { q=1; cleardevice();/*清屏函数*/ setcolor(15); settextstyle(0,0,5); outtextxy(100,100,"Start Game!"); settextstyle(0,0,1); outtextxy(20,300,"keys used:"); outtextxy(20,300," Arrow keys"); outtextxy(20,310," The left mouse button"); outtextxy(20,320," Enter"); outtextxy(20,330," Esc to Quit!"); setcolor(5); outtextxy(250,400,"One player!"); outtextxy(250,420,"Two players!"); outtextxy(250,440,"Quit!"); setwritemode(1); setcolor(6); rectangle(245,395+h*20,345,415+h*20); for(;q;) { setcolor(6); k=bioskey(0); sound(1000);/*响声函数*/ delay(10000); nosound(); if(k==20480) { rectangle(245,395+h*20,345,415+h*20); h=(h+1)%3; rectangle(245,395+h*20,345,415+h*20); }else if(k==7181) { if(h==0)/*单人游戏,选择等级*/ { cleardevice();/*清屏函数*/ setcolor(2); outtextxy(20,30," Esc to back!"); outtextxy(250,240,"Lower"); outtextxy(250,260,"Middle"); outtextxy(250,280,"Higher"); setcolor(4); rectangle(245,235+h*20,300,255+h*20); for(;q;) { k=bioskey(0); sound(1000);/*响声函数*/ delay(10000); nosound(); if(k==20480) { rectangle(245,235+h*20,300,255+h*20); h=(h+1)%3; rectangle(245,235+h*20,300,255+h*20); }else if(k==7181) { return h+1; }else if(k==283) { h=0; k=1; q=0; break; }else{} } } if(h==1)/*两人对抗*/ return 4; if(h==2)/*退出游戏*/ return 5; }else if(k==283) { return 5; }else {} } } } /*退出游戏画面*/ void GameOver() { cleardevice();/*清屏函数*/ setcolor(14); settextstyle(0,0,6); outtextxy(100,200,"Game Over!"); settextstyle(1,0,1); outtextxy(400,400,"Producer:ChenChen"); outtextxy(400,410," QQ:804620957"); outtextxy(400,420," Time:2010.5.28"); } /*主函数*/ void main() { int gd=DETECT,gm; int q=0,schoose=1; int out=1; int pmc=1; int cla2s=1; struct Ren ren1,ren2; initgraph(&gd;,&gm;,""); /* registerbgidriver(EGAVGA_driver);*/ cleardevice();/*清屏函数*/ MouseMath();/*计算鼠标形状,一开始必须使用,后面就不用了*/ MouseSetY(0,479); MouseSetX(0,649); MouseSetXY(100,100); for(;out;) { pmc=GameStar(); cleardevice();/*清屏函数*/ settextstyle(1,0,1);/*初始化*/ schoose=1; ren2.x=540;ren2.y=320;ren2.life=200;ren2.color=3;ren2.lr=2; if(pmc<4) { ren1.x=640-ren2.x;ren1.y=ren2.y;ren1.life=ren2.life;ren1.color=2;ren1.lr=3; cla2s=pmc; }else if(pmc==4) { ren1.x=640-ren2.x;ren1.y=ren2.y;ren1.life=ren2.life;ren1.color=2;ren1.lr=1; }else { break;} Desktop(); AngleSpeed(0,0); RenPicture(ren1.x,ren1.y,ren1.color); RenPicture(ren2.x,ren2.y,ren2.color); LifePicture(ren1.life,ren1.color,ren1.lr); LifePicture(ren2.life,ren2.color,ren2.lr); for(;ren1.life>0&&ren2;.life>0;schoose++) { if(schoose%2) { RenPicture(ren1.x,ren1.y,ren1.color); if(MoveRen(&ren1;)==0) break; q=Launch(ren1.x,ren1.y,ren2.x,ren2.y,ren1.lr,cla2s); if(q==1) ren2.life=ren2.life-40; if(q==2) ren2.life=ren2.life-20; if(q==3) ren2.life=ren2.life-10; if(ren2.life<0) ren2.life=0; LifePicture(ren2.life,ren2.color,ren2.lr); } else { RenPicture(ren2.x,ren2.y,ren2.color); if(MoveRen(&ren2;)==0) break; q=Launch(ren2.x,ren2.y,ren1.x,ren1.y,ren2.lr,cla2s); if(q==1) ren1.life=ren1.life-40; if(q==2) ren1.life=ren1.life-20; if(q==3) ren1.life=ren1.life-10; if(ren1.life<0) ren1.life=0; LifePicture(ren1.life,ren1.color,ren1.lr); } } if(ren1.lifesettextstyle(0,0,6); setcolor(ren2.color); outtextxy(150,280,"P2 win!"); settextstyle(1,0,1); } else if(ren1.life>ren2.life) { settextstyle(0,0,6); setcolor(ren1.color); outtextxy(150,280,"P1 win!"); settextstyle(1,0,1); } else { settextstyle(0,0,6); setcolor(15); outtextxy(150,280,"Drew!"); settextstyle(1,0,1); } getch(); } GameOver(); getch(); closegraph(); }

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧