home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
FFILLY
/
PLA010
/
PLA010.TFY
< prev
next >
Wrap
Text File
|
1996-12-11
|
2KB
|
92 lines
#info INAM "惑星の運動 - 楕円軌道"
#info ICMT "飽きるまで眺めよう。右クリックで終了します。"
#info ISBJ "惑星の公転シュミレートだよん。"
#info IART "もりきゅう"
#info ICOP "もりきゅう"
#info ICOP "Copy Right (c) 1996 もりきゅう"
#info VIDO "640x400; 256"
#info GRPC "もりきゅう,VZF07161@niftyserve.or.jp"
#define WHITE 0xffffff
#include "MakeWin.tfy"
int xCenter, yCenter;
real DT;
main()
{
int pSun, cSun, xSun, ySun;
int i, count, CWDLen;
str IniName, BmpName, sBuff;
real PX, PY, VX, VY;
IniName = "Planet.ini";
SetPaintColor(WHITE);
CapTitle(" 惑星の運動 - 楕円軌道 ");
MakeMainWin("Space.bmp");
pSun = LoadPic("Sun.bmp");
xCenter = PicWidth(pMain) / 2;
yCenter = PicHeight(pMain) / 2;
DT = 0.08;
xSun = xCenter - PicWidth(pSun) / 2;
ySun = yCenter - PicHeight(pSun) / 2;
cSun = PutCast(pSun, pMain, xSun, ySun, WHITE);
count = GetIniInt("Planet", "Count", 0, IniName);
for( i=0 ; i<count ; i=i+1 ) {
sBuff = GetIniStr("Planet", StrPrint("Pla%.2ld", i), "", IniName);
BmpName = SubStr(sBuff, 0, 12);
PX = StrtoReal( SubStr(sBuff, 12, 5) );
PY = StrtoReal( SubStr(sBuff, 17, 5) );
VX = StrtoReal( SubStr(sBuff, 22, 5) );
VY = StrtoReal( SubStr(sBuff, 27, 5) );
SetPlanet(BmpName, PX, PY, VX, VY);
}
}
SetPlanet(str BmpName, real PX, real PY, real VX, real VY)
{
int xPla, yPla;
int xpos, ypos;
int pPla, cPla;
real AX, AY;
pPla = LoadPic(BmpName);
xPla = xCenter + RealtoInt(PX * 50.0);
yPla = yCenter - RealtoInt(PY * 50.0);
xpos = xpos - PicWidth(pPla) / 2;
ypos = ypos - PicHeight(pPla) / 2;
cPla = PutCast(pPla, pMain, xpos, ypos, WHITE);
AX = -PX / Pow( Pow(PX, 2.0) + Pow(PY, 2.0), 1.5);
AY = -PY / Pow( Pow(PX, 2.0) + Pow(PY, 2.0), 1.5);
mes( TIME ) {
step(2) {
VX = VX + AX * DT;
VY = VY + AY * DT;
PX = PX + VX * DT;
PY = PY + VY * DT;
xPla = xCenter + RealtoInt(PX * 50.0);
yPla = yCenter - RealtoInt(PY * 50.0);
xpos = xPla - PicWidth(pPla) / 2;
ypos = yPla - PicHeight(pPla) / 2;
MoveCast(cPla, pPla, xpos, ypos);
DrawCircle(pBack, xPla-1, yPla-1, xPla+1, yPla+1, 0, 0);
AX = -PX / Pow( Pow(PX, 2.0) + Pow(PY, 2.0), 1.5);
AY = -PY / Pow( Pow(PX, 2.0) + Pow(PY, 2.0), 1.5);
}
}
}