能力值:
(RANK:1060 )
|
-
-
26 楼
; =============== S U B R O U T I N E =======================================
; return (2831.425 > x > 28.575) && (2831.425 > y > 28.575); // ugly bug!!!
; int __stdcall cgame_continuable(float x, float y)
cgame_continuable proc near ; CODE XREF: cgame_moveball+53p
; cfuck_init+Fp
t = dword ptr -4
x = dword ptr 4
y = dword ptr 8
push ecx
fld [esp+4+x]
xor ecx, ecx
fld ds:const_28_575
mov edx, 1
fcom st(1) ; t = x > 28.575 ? 1 : 0;
mov [esp+4+t], edx
fnstsw ax
fstp st(1)
test ah, 5
jnp short __0
mov [esp+4+t], ecx
__0: ; CODE XREF: cgame_continuable+1Ej
fild [esp+4+t]
fcomp ds:const_2831_425
fnstsw ax
test ah, 5 ; if (2831.425 < t)
jp short __cleanup ; return false;
fld [esp+4+y]
mov [esp+4+x], edx ; u = y > 28.575 ? 0 : 1;
fcompp st(1), st
fnstsw ax
test ah, 41h
jz short __1
mov [esp+4+x], ecx
__1: ; CODE XREF: cgame_continuable+42j
fild [esp+4+x]
fcomp ds:const_1121_425
fnstsw ax
test ah, 5 ; if (1121.425 < u)
jp short __exit ; return false;
mov al, dl ; return true;
pop ecx
retn 8
; ---------------------------------------------------------------------------
__cleanup: ; CODE XREF: cgame_continuable+31j
fstp st
__exit: ; CODE XREF: cgame_continuable+57j
xor al, al
pop ecx
retn 8
cgame_continuable endp
; ---------------------------------------------------------------------------
|
能力值:
( LV15,RANK:2473 )
|
-
-
27 楼
想观摩一下tba类里面几个函数怎么写的
|
能力值:
( LV2,RANK:10 )
|
-
-
28 楼
输入16位的时候才能出来haha u lost....这是故意地不?
|
能力值:
(RANK:410 )
|
-
-
29 楼
是这个?没看明白:(
bool tba::cbp(zb zb1)
{
if (BALL_RADIUS<zb1.x<(TABLE_9BALL_WIDTH-BALL_RADIUS))
if (BALL_RADIUS<zb1.y<(TABLE_9BALL_HEIGHT-BALL_RADIUS))
return true;
return false;
}
刚学vc,第一次写类,帮指点下吧,看哪里写的不好,有没有uglybug什么的。不全贴了,贴两个主要的,看和你们逆的
差多少。
class tba
{
public:
table_9ball table1;
ball ball1[16];//母球0,子球1-15
public:
tba(void);
~tba(void);
// 在台球桌上放球
bool pb(int ballno,zb zb1);
//检测球位置合法性
bool cbp(zb zb1);
//检测碰撞
bool cc(int ballno);
//球距
float zbdis(zb zb0,zb zb1);
//球角
float zbdir(zb zb1, zb zb2);
//球移动ballmove
bool bm(int ballno);
//球落袋?checkwin
bool cw(int ballno);
};
//球碰撞?
bool tba::cc(int ballno)
{
int i;
float speed1,speed2;
float speed3,speed4;
float zbdis1,zbdir1;
for(i=0;i<2;i++)
{
if( i!=ballno)
{
zbdis1=zbdis(ball1[ballno].position,ball1[i].position);
if(zbdis1<2*BALL_RADIUS)
{
zbdir1=zbdir(ball1[i].position,ball1[ballno].position);
speed1=ball1[ballno].speed*cos((zbdir1-ball1[ballno].direction)*PI_360);
speed2=ball1[i].speed*cos((zbdir1-ball1[i].direction)*PI_360);
speed3=ball1[ballno].speed*sin((zbdir1-ball1[ballno].direction)*PI_360);
speed4=ball1[i].speed*sin((zbdir1-ball1[i].direction)*PI_360);
if((speed1-speed2)>=0)
{
ball1[ballno].speed=speed3*ATTAU;//垂直方向传递给子球,水平方向衰减
ball1[ballno].direction=90.00+zbdir1;
ball1[i].speed=sqrt((speed1-speed2)*(speed1-speed2)*ATTAU+speed4*speed4);
ball1[i].direction=zbdir1+atan(speed4/(speed1-speed2))*360.00/6.28;
}
else
{
/*
ball1[ballno].speed=sqrt((speed1-speed2)*(speed1-speed2)*ATTAU+speed3*speed3);
ball1[ballno].direction=zbdir+atan((speed1-speed2)/speed3)*360.00/6.28;
ball1[i].speed=speed4*ATTAU;
ball1[i].direction=90.00-zbdir;
*/
}
if(ball1[ballno].speed<FRIC)
ball1[ballno].speed=0.0;
if(ball1[i].speed<FRIC)
ball1[i].speed=0.0;
}
}
}
return true;
}
//球移动
bool tba::bm(int ballno)
{
float tmpspeed;
float tmpdirection;
float tmpx0,tmpx1;
float tmpy0,tmpy1;
tmpspeed=ball1[ballno].speed;
tmpdirection=ball1[ballno].direction;
//移动失败
if(tmpdirection<0)
{
tmpdirection=360.0+tmpdirection;
ball1[ballno].direction=tmpdirection;
}
if (!cbp(ball1[ballno].position)||tmpspeed<=0||tmpdirection<0)
return false;
tmpx0=ball1[ballno].position.x;
tmpy0=ball1[ballno].position.y;
tmpx1=tmpspeed*cos(tmpdirection*PI_360)+tmpx0;
tmpy1=-tmpspeed*sin(tmpdirection*PI_360)+tmpy0;
ball1[ballno].position.x=tmpx1;
ball1[ballno].position.y=tmpy1;
if (ball1[ballno].speed>FRIC)
ball1[ballno].speed=ball1[ballno].speed-FRIC;
else
ball1[ballno].speed=0.00;
return false;
}
//checkwin 球落袋?
bool tba::cw(int ballno)
{
float zbdis0,zbdis1,zbdis2,zbdis3;
zbdis0=zbdis(ball1[ballno].position,table1.hole0);
zbdis1=zbdis(ball1[ballno].position,table1.hole1);
zbdis2=zbdis(ball1[ballno].position,table1.hole2);
zbdis3=zbdis(ball1[ballno].position,table1.hole3);
if (zbdis0<2*BALL_RADIUS)
return true;
if (zbdis1<2*BALL_RADIUS)
return true;
if (zbdis2<2*BALL_RADIUS)
return true;
if (zbdis3<2*BALL_RADIUS)
return true;
return false;
}
恩,是这样。
|
能力值:
(RANK:410 )
|
-
-
30 楼
最开始的目标比较宏伟,呵呵。与最终实现的crackme差的很远。。。
原计划,是15个球都有,还要处理边框碰撞,和子球间相互碰撞,本想设一个球位固定的开局,然后母球一杆全收,不过写不出来的了,也怕搞的太复杂没人玩。。。
|
能力值:
( LV15,RANK:2473 )
|
-
-
31 楼
bool tba::cbp(zb zb1)果然是这样写的,严重bug
|
能力值:
(RANK:1060 )
|
-
-
32 楼
正确写法:
bool tba::cbp(zb zb1)
{
return ( (zb1.x > BALL_RADIUS) &&
(zb1.x < TABLE_9BALL_WIDTH-BALL_RADIUS) &&
(zb1.y > BALL_RADIUS) &&
(zb1.y < TABLE_9BALL_HEIGHT-BALL_RADIUS) );
}
|
能力值:
(RANK:410 )
|
-
-
33 楼
多谢两位指点,我去研究下。
|
能力值:
( LV15,RANK:2473 )
|
-
-
34 楼
自己传入不同的参数调试一下
|
能力值:
(RANK:410 )
|
-
-
35 楼
明白了, 多谢
|
能力值:
(RANK:410 )
|
-
-
36 楼
写法也很好,比我的if要简洁。
|
|
|