TempleOSCD_140715.ISO
This commit is contained in:
1 parent
7ef616a20e
commit
64f679eeb9
1095 files changed
+24814
-221011
No files matched your search
+141
-32
@@ -3,7 +3,8 @@
|
||||
F64 game_speed,
|
||||
launch_unit_x1,launch_unit_y1,launch_unit_x2,launch_unit_y2,launch_t,
|
||||
return_unit_x1,return_unit_y1,return_unit_x2,return_unit_y2,return_t,
|
||||
set_é_unit_x1,set_é_unit_y1,set_é_unit_x2,set_é_unit_y2,set_é_t;
|
||||
set_é_unit_x1,set_é_unit_y1,set_é_unit_x2,set_é_unit_y2,set_é_t,
|
||||
next_noise;
|
||||
CTask *main_task;
|
||||
|
||||
#define OT_CARRIER 0
|
||||
@@ -16,6 +17,16 @@ CTask *main_task;
|
||||
#define OF_RETURNING 4
|
||||
#define OF_SHOOTING 8
|
||||
|
||||
#define FIRE_WIDTH 56
|
||||
#define FIRE_HEIGHT 16
|
||||
#define FIRE_X_SCALE 0.5
|
||||
#define FIRE_Y_SCALE 0.5
|
||||
|
||||
#define FIRE_COLORS 16
|
||||
U8 fire_colors[FIRE_COLORS]={
|
||||
YELLOW,YELLOW,LTRED,YELLOW, BLACK,YELLOW,RED,YELLOW,
|
||||
YELLOW,BLACK,YELLOW,LTRED, RED,YELLOW,DKGRAY,YELLOW};
|
||||
|
||||
class Obj
|
||||
{
|
||||
Obj *next,*last;
|
||||
@@ -34,6 +45,7 @@ class Obj
|
||||
death_time,next_action_time;
|
||||
I32 torpedos,max_torpedos;
|
||||
F64 torpedos_range;
|
||||
U8 fire[(FIRE_WIDTH*FIRE_HEIGHT+7)/8];
|
||||
} obj_root;
|
||||
|
||||
class Torpedo
|
||||
@@ -55,7 +67,6 @@ class Squadron : Obj
|
||||
I64 action,dead_mask,total_mask;
|
||||
} *squadrons;
|
||||
|
||||
|
||||
U0 SquadronIns(Obj *o,Obj *pred)
|
||||
{
|
||||
Obj *succ=pred->next_in_squadron;
|
||||
@@ -118,7 +129,6 @@ U0 ObjDel(Obj *tempo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$BG,1$
|
||||
|
||||
|
||||
@@ -148,6 +158,7 @@ CSprite *imgs[NUM_PLAYERS][OT_NUM_TYPES]={{$IB,"<1>",BI=1$,$IB,"<2>",BI=2$,$IB,"
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 i,j,k;
|
||||
F64 d,cur_time=tS;
|
||||
Obj *tempo;
|
||||
Torpedo *tempt;
|
||||
@@ -164,6 +175,17 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
while (tempo!=&obj_root) {
|
||||
if (tempo->flags&OF_ACTIVE && tempo->flags&OF_SHIP) {
|
||||
SpriteZ3B(dc,tempo->x,tempo->y,0,imgs[tempo->player][tempo->type],tempo->é+ã/2);
|
||||
|
||||
k=0;
|
||||
for (j=0;j<FIRE_HEIGHT;j++)
|
||||
for (i=0;i<FIRE_WIDTH;i++)
|
||||
if (Bt(tempo->fire,k++)) {
|
||||
dc->color=fire_colors[ToI64(k+10*tS)&(FIRE_COLORS-1)];
|
||||
GrPlot(dc,tempo->x+FIRE_X_SCALE*(i-FIRE_WIDTH /2+(11*tS+i)%1.7)*Cos(tempo->é)-
|
||||
FIRE_Y_SCALE*(j-FIRE_HEIGHT/2+(12*tS+j)%1.7)*Sin(tempo->é),
|
||||
tempo->y+FIRE_Y_SCALE*(j-FIRE_HEIGHT/2+(19*tS+j)%1.7)*Cos(tempo->é)+
|
||||
FIRE_X_SCALE*(i-FIRE_WIDTH /2+(13*tS+i)%1.7)*Sin(tempo->é));
|
||||
}
|
||||
if (Blink) {
|
||||
dc->color=BLACK;
|
||||
GrLine(dc,tempo->x+5,tempo->y,tempo->x+5+10,tempo->y);
|
||||
@@ -231,11 +253,11 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
if (!num_alive[1]) {
|
||||
dc->color=LTGREEN;
|
||||
GrPrint(dc,task->pix_width>>1 -(FONT_WIDTH*14)/2-task->scroll_x,
|
||||
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Completed");
|
||||
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Completed");
|
||||
} else {
|
||||
dc->color=LTRED;
|
||||
GrPrint(dc,task->pix_width>>1 -(FONT_WIDTH*9)/2-task->scroll_x,
|
||||
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Over");
|
||||
task->pix_height>>1-FONT_HEIGHT/2-task->scroll_y,"Game Over");
|
||||
}
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
@@ -250,6 +272,7 @@ U0 Init()
|
||||
QueInit(&obj_root);
|
||||
QueInit(&torpedo_root);
|
||||
|
||||
next_noise=tS;
|
||||
Fs->scroll_x=0;
|
||||
Fs->scroll_y=0;
|
||||
game_speed=1.0;
|
||||
@@ -387,8 +410,8 @@ Squadron *SquadronLaunch(I64 player,F64 x=MAX_F64,F64 y=MAX_F64)
|
||||
if (player==0) {
|
||||
launch_unit_x1=tempo->x;
|
||||
launch_unit_y1=tempo->y;
|
||||
launch_unit_x2=ipx-main_task->pix_left-main_task->scroll_x;
|
||||
launch_unit_y2=ipy-main_task->pix_top -main_task->scroll_y;
|
||||
launch_unit_x2=ip.pos.x-main_task->pix_left-main_task->scroll_x;
|
||||
launch_unit_y2=ip.pos.y-main_task->pix_top -main_task->scroll_y;
|
||||
launch_t=tS+0.5;
|
||||
}
|
||||
if (tempo->squadron>=0) {
|
||||
@@ -403,7 +426,6 @@ Squadron *SquadronLaunch(I64 player,F64 x=MAX_F64,F64 y=MAX_F64)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Obj *ObjReturn(I64 player,F64 x,F64 y)
|
||||
{
|
||||
Obj *tempo;
|
||||
@@ -456,8 +478,8 @@ Squadron *SquadronSet
|
||||
if (player==0) {
|
||||
set_é_unit_x1=tempo->x;
|
||||
set_é_unit_y1=tempo->y;
|
||||
set_é_unit_x2=ipx-main_task->pix_left-main_task->scroll_x;
|
||||
set_é_unit_y2=ipy-main_task->pix_top -main_task->scroll_y;
|
||||
set_é_unit_x2=ip.pos.x-main_task->pix_left-main_task->scroll_x;
|
||||
set_é_unit_y2=ip.pos.y-main_task->pix_top -main_task->scroll_y;
|
||||
set_é_t=tS+0.5;
|
||||
}
|
||||
if (tempo->squadron>=0) {
|
||||
@@ -538,6 +560,44 @@ U0 AI(I64 player,F64 period)
|
||||
}
|
||||
}
|
||||
|
||||
U0 ShipDammage(Obj *tempo,F64 d)
|
||||
{
|
||||
I64 i,x=Rand*FIRE_WIDTH,y=Rand*FIRE_HEIGHT;
|
||||
tempo->life_percent-=d;
|
||||
while (d>0) {
|
||||
if (!Bts(tempo->fire,y*FIRE_WIDTH+x))
|
||||
d-=500.0/(FIRE_WIDTH*FIRE_HEIGHT);
|
||||
else
|
||||
d-=25.0/(FIRE_WIDTH*FIRE_HEIGHT);
|
||||
i=RandI16&7;
|
||||
x+=gr_x_offsets[i];
|
||||
y+=gr_y_offsets[i];
|
||||
while (x>=FIRE_WIDTH)
|
||||
x-=FIRE_WIDTH;
|
||||
while (x<0)
|
||||
x+=FIRE_WIDTH;
|
||||
while (y>=FIRE_HEIGHT)
|
||||
y-=FIRE_HEIGHT;
|
||||
while (y<0)
|
||||
y+=FIRE_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ShipFix(Obj *tempo,F64 d)
|
||||
{
|
||||
tempo->life_percent+=d;
|
||||
if (tempo->life_percent>=100.0) {
|
||||
tempo->life_percent=100.0;
|
||||
MemSet(tempo->fire,0,sizeof(Obj.fire));
|
||||
return;
|
||||
}
|
||||
while (d>0)
|
||||
if (Btr(tempo->fire,FIRE_WIDTH*FIRE_HEIGHT*Rand))
|
||||
d-=400.0/(FIRE_WIDTH*FIRE_HEIGHT);
|
||||
else
|
||||
d-=20.0/(FIRE_WIDTH*FIRE_HEIGHT);
|
||||
}
|
||||
|
||||
U0 Combat(F64 period)
|
||||
{
|
||||
F64 d;
|
||||
@@ -566,11 +626,14 @@ U0 Combat(F64 period)
|
||||
} else if (tempo->ship_guns>0 && d<tempo->ship_guns_range) {
|
||||
tempo->flags|=OF_SHOOTING;
|
||||
if (Rand<125.0*period) {
|
||||
tempo1->life_percent-=tempo->ship_guns*Rand*period;
|
||||
ShipDammage(tempo1,tempo->ship_guns*Rand*period);
|
||||
if (Rand<10.0*period)
|
||||
tempo1->fuel*=0.75*Rand+0.25;
|
||||
}
|
||||
Noise(100,75,200);
|
||||
if (tS>next_noise) {
|
||||
Noise(100,75,200);
|
||||
next_noise=tS+0.1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (tempo->air_guns>0 && d<tempo->air_guns_range) {
|
||||
@@ -580,7 +643,10 @@ U0 Combat(F64 period)
|
||||
if (Rand<10.0*period)
|
||||
tempo1->fuel*=0.75*Rand+0.25;
|
||||
}
|
||||
Noise(25,500,2000);
|
||||
if (tS>next_noise) {
|
||||
Noise(25,500,2000);
|
||||
next_noise=tS+0.025;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -606,11 +672,10 @@ U0 Combat(F64 period)
|
||||
|
||||
#define ANIMATE_FREQ 50
|
||||
U0 AnimateTask(I64)
|
||||
{ //Preemption is off after Spawn
|
||||
{//Preemption is off after Spawn
|
||||
Obj *tempo;
|
||||
Torpedo *tempt,*tempt1;
|
||||
F64 d,period;
|
||||
I64 cnt=0;
|
||||
|
||||
while (TRUE) {
|
||||
period=GAME_SPEED_SCALE*game_speed/ANIMATE_FREQ;
|
||||
@@ -639,7 +704,7 @@ U0 AnimateTask(I64)
|
||||
if (tS>tempt->timeout) {
|
||||
tempo=tempt->target;
|
||||
if (Rand<0.333333) {
|
||||
tempo->life_percent-=150*Rand*Rand;
|
||||
ShipDammage(tempo,150*Rand*Rand);
|
||||
if (Rand<0.333333)
|
||||
tempo->fuel*=0.75*Rand+0.25;
|
||||
}
|
||||
@@ -683,7 +748,7 @@ U0 AnimateTask(I64)
|
||||
if (tempo->flags&OF_RETURNING)
|
||||
tempo->dé+=Wrap(Arg(tempo->host->x-tempo->x,tempo->host->y-tempo->y)-(tempo->é+tempo->dé),-ã);
|
||||
} else if (tempo->type==OT_CARRIER)
|
||||
tempo->life_percent=Min(100.0,tempo->life_percent+2.5*period);
|
||||
ShipFix(tempo,2.5*period);
|
||||
}
|
||||
tempo=tempo->next;
|
||||
}
|
||||
@@ -694,21 +759,22 @@ U0 AnimateTask(I64)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U0 FlatTops()
|
||||
{
|
||||
I64 p1,p2;
|
||||
I64 a1,a2;
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->text_attr=BLUE<<4+WHITE;
|
||||
WinMax;
|
||||
WinBorder;
|
||||
WordStat;
|
||||
DocCursor;
|
||||
DocClear;
|
||||
PopUpOk("$$GREEN$${Left-Mouse}$$FG$$\t\tChange Course\n"
|
||||
"$$GREEN$${Right-Mouse}$$FG$$\t\tLaunch Squadron\n"
|
||||
"$$GREEN$${Right-Double-Mouse}$$FG$$\tReturn Squadron\n"
|
||||
"$$GREEN$${Ctrl-Left Grab}$$FG$$\tScroll Screen\n");
|
||||
Preempt(OFF),
|
||||
WinBorder;
|
||||
WordStat;
|
||||
|
||||
MenuPush(
|
||||
"File {"
|
||||
" Abort(,CH_SHIFT_ESC);"
|
||||
@@ -720,18 +786,15 @@ U0 FlatTops()
|
||||
" Slower(,'-');"
|
||||
"}"
|
||||
);
|
||||
WinMax;
|
||||
Fs->win_inhibit|=WIF_IP_L|WIF_IP_R;
|
||||
Fs->win_inhibit|=WIF_SELF_IP_L|WIF_SELF_IP_R;
|
||||
Init;
|
||||
DocCursor;
|
||||
DocClear;
|
||||
Fs->draw_it=&DrawIt;
|
||||
Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs);
|
||||
try {
|
||||
while (TRUE)
|
||||
switch(GetMsg(&p1,&p2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_UP|1<<MSG_IP_R_D_UP)) {
|
||||
switch(GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_UP|1<<MSG_IP_R_UP|1<<MSG_IP_R_D_UP)) {
|
||||
case MSG_KEY_DOWN:
|
||||
switch (p1) {
|
||||
switch (a1) {
|
||||
case '\n':
|
||||
CleanUp;
|
||||
Init;
|
||||
@@ -748,13 +811,13 @@ U0 FlatTops()
|
||||
}
|
||||
break;
|
||||
case MSG_IP_L_UP:
|
||||
SquadronSeté(0,p1,p2);
|
||||
SquadronSeté(0,a1,a2);
|
||||
break;
|
||||
case MSG_IP_R_UP:
|
||||
SquadronLaunch(0,p1,p2);
|
||||
SquadronLaunch(0,a1,a2);
|
||||
break;
|
||||
case MSG_IP_R_D_UP:
|
||||
SquadronReturn(0,p1,p2);
|
||||
SquadronReturn(0,a1,a2);
|
||||
break;
|
||||
}
|
||||
nv_done:
|
||||
@@ -767,8 +830,54 @@ nv_done:
|
||||
}
|
||||
|
||||
FlatTops;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Maybe use this in the future $SP,"<7>",BI=7$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
| ||||