TempleOSCD_140715.ISO
This commit is contained in:
1 parent
7ef616a20e
commit
64f679eeb9
1095 files changed
+24814
-221011
No files matched your search
+117
-102
@@ -2,30 +2,30 @@ AcctRegSetDftEntry("TempleOS/TimeOut","I64 best_score=0;\n");
|
||||
AcctRegExeBranch("TempleOS/TimeOut");
|
||||
|
||||
#define MAP_HEIGHT 4096
|
||||
#define SHOT_LEN 10
|
||||
#define SHOT_SPEED 5
|
||||
#define BULLET_LEN 10
|
||||
#define BULLET_SPEED 5
|
||||
|
||||
#define MAX_SHOTS 128
|
||||
class Shot
|
||||
#define MAX_BULLETS 128
|
||||
class Bullet
|
||||
{
|
||||
I64 x,y,dx,dy,dx2,dy2;
|
||||
Bool dead,pad[7];
|
||||
} s[MAX_SHOTS];
|
||||
I64 shots_fired;
|
||||
|
||||
} b[MAX_BULLETS];
|
||||
I64 bullets_fired;
|
||||
|
||||
I64 x,y,dx,dy,scroll_y,finish_line;
|
||||
F64 é;
|
||||
F64 t0,tf,snd_shot_timeout,snd_death_timeout;
|
||||
F64 t0,tf,snd_bullet_timeout,snd_death_timeout;
|
||||
|
||||
#define PHASES_GROUPS 10
|
||||
#define MAX_ENEMY (PHASES_GROUPS*100)
|
||||
#define MAX_FRIENDLY (PHASES_GROUPS*20)
|
||||
#define MAX_MAN (MAX_FRIENDLY+MAX_ENEMY)
|
||||
#define HACK_DIST 5
|
||||
class Man
|
||||
{
|
||||
I64 x,y;
|
||||
F64 corpse_timeout;
|
||||
I64 x,y,closest_d;
|
||||
F64 é,hack_phase,corpse_timeout;
|
||||
Bool friendly,dead,pad[6];
|
||||
} m[MAX_MAN];
|
||||
|
||||
@@ -43,17 +43,23 @@ $BG,14$
|
||||
|
||||
$SP,"<2>",BI=2$
|
||||
|
||||
|
||||
|
||||
$SP,"<3>",BI=3$
|
||||
|
||||
|
||||
|
||||
$SP,"<4>",BI=4$
|
||||
|
||||
|
||||
$SP,"<5>",BI=5$
|
||||
|
||||
CSprite *friendly_imgs[4]={$IB,"<3>",BI=3$,$IB,"<2>",BI=2$,$IB,"<3>",BI=3$,$IB,"<4>",BI=4$};
|
||||
|
||||
$SP,"<6>",BI=6$
|
||||
|
||||
$SP,"<7>",BI=7$
|
||||
|
||||
$SP,"<8>",BI=8$
|
||||
|
||||
$SP,"<9>",BI=9$
|
||||
|
||||
CSprite *enemy_imgs[4]={$IB,"<7>",BI=7$,$IB,"<6>",BI=6$,$IB,"<7>",BI=7$,$IB,"<8>",BI=8$};
|
||||
|
||||
#define LANDSCAPE_TYPES 4
|
||||
|
||||
@@ -62,13 +68,11 @@ $BG,14$
|
||||
|
||||
|
||||
|
||||
$SP,"<6>",BI=6$
|
||||
$SP,"<10>",BI=10$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<7>",BI=7$
|
||||
$SP,"<11>",BI=11$
|
||||
|
||||
|
||||
|
||||
@@ -76,9 +80,7 @@ $BG,14$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<8>",BI=8$
|
||||
$SP,"<12>",BI=12$
|
||||
|
||||
|
||||
|
||||
@@ -94,13 +96,12 @@ $BG,14$
|
||||
|
||||
|
||||
|
||||
|
||||
$SP,"<9>",BI=9$
|
||||
$SP,"<13>",BI=13$
|
||||
|
||||
$BG$
|
||||
|
||||
CSprite *landscape_imgs[LANDSCAPE_TYPES]=
|
||||
{$IB,"<tree>",BI=6$,$IB,"<rock>",BI=7$,$IB,"<mountain>",BI=8$,$IB,"<castle>",BI=9$};
|
||||
{$IB,"<tree>",BI=10$,$IB,"<rock>",BI=11$,$IB,"<mountain>",BI=12$,$IB,"<castle>",BI=13$};
|
||||
|
||||
#define MAX_LANDSCAPE 64
|
||||
class LandScapeItem
|
||||
@@ -109,13 +110,13 @@ class LandScapeItem
|
||||
U8 *img;
|
||||
} ls[MAX_LANDSCAPE];
|
||||
|
||||
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 i,yy;
|
||||
F64 t1;
|
||||
Man *tempm;
|
||||
Shot *temps;
|
||||
Bullet *tempb;
|
||||
CSprite *temps,**_temps;
|
||||
|
||||
for (i=0;i<MAX_LANDSCAPE;i++) {
|
||||
yy=(ls[i].y-scroll_y)&(MAP_HEIGHT-1);
|
||||
@@ -129,11 +130,11 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
GR_WIDTH,(finish_line-scroll_y)&(MAP_HEIGHT-1),0);
|
||||
|
||||
dc->color=LTRED;
|
||||
for (i=0,temps=s;i<MAX_SHOTS;i++,temps++)
|
||||
if (!temps->dead)
|
||||
GrLine(dc,temps->x>>32,temps->y>>32,
|
||||
(temps->x+temps->dx*SHOT_LEN)>>32,
|
||||
(temps->y+temps->dy*SHOT_LEN)>>32);
|
||||
for (i=0,tempb=b;i<MAX_BULLETS;i++,tempb++)
|
||||
if (!tempb->dead)
|
||||
GrLine(dc,tempb->x>>32,tempb->y>>32,
|
||||
(tempb->x+tempb->dx*BULLET_LEN)>>32,
|
||||
(tempb->y+tempb->dy*BULLET_LEN)>>32);
|
||||
for (i=0,tempm=m;i<MAX_MAN;i++,tempm++) {
|
||||
yy=(tempm->y-scroll_y)&(MAP_HEIGHT-1);
|
||||
if (-32<=yy<=Fs->pix_bottom+32) {
|
||||
@@ -141,9 +142,10 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
tS<tempm->corpse_timeout)
|
||||
if (!(RandU16&15)) {
|
||||
if (tempm->friendly)
|
||||
Sprite3(dc,tempm->x,yy,0,$IB,"<dead_friendly>",BI=4$);
|
||||
temps=$IB,"<5>",BI=5$;
|
||||
else
|
||||
Sprite3(dc,tempm->x,yy,0,$IB,"<dead_enemy>",BI=5$);
|
||||
temps=$IB,"<9>",BI=9$;
|
||||
SpriteZ3B(dc,tempm->x,yy,0,temps,tempm->é);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,28 +154,32 @@ U0 DrawIt(CTask *task,CDC *dc)
|
||||
if (-32<=yy<=Fs->pix_bottom+32) {
|
||||
if (!tempm->dead) {
|
||||
if (tempm->friendly)
|
||||
Sprite3(dc,tempm->x,yy,0,$IB,"<friendly>",BI=2$);
|
||||
_temps=friendly_imgs;
|
||||
else
|
||||
Sprite3(dc,tempm->x,yy,0,$IB,"<enemy>",BI=3$);
|
||||
_temps=enemy_imgs;
|
||||
if (tempm->closest_d<HACK_DIST*HACK_DIST)
|
||||
temps=_temps[4*Wrap(tempm->hack_phase+20*tS,0)/(2*ã)];
|
||||
else
|
||||
temps=_temps[0];
|
||||
SpriteZ3B(dc,tempm->x,yy,0,temps,tempm->é);
|
||||
}
|
||||
}
|
||||
}
|
||||
SpriteZ3B(dc,x,y,0,$IB,"<ship>",BI=1$,é);
|
||||
SpriteZ3B(dc,x,y,0,$IB,"<1>",BI=1$,é);
|
||||
|
||||
if (tf) {
|
||||
t1=tf;
|
||||
dc->color=RED;
|
||||
if (game_over && Blink)
|
||||
GrPrint(dc,task->pix_width/2-9*FONT_WIDTH/2,
|
||||
task->pix_height/2,"Game Over");
|
||||
GrPrint(dc,task->pix_width/2-9*FONT_WIDTH/2,task->pix_height/2,"Game Over");
|
||||
} else {
|
||||
t1=tS;
|
||||
if (!enemy_left || !friendly_left)
|
||||
game_over=TRUE;
|
||||
}
|
||||
dc->color=BROWN;
|
||||
GrPrint(dc,0,0,"Enemy:%d Friends:%d Friendly Fire:%d Time:%6.2f Shots:%d",
|
||||
enemy_left,friendly_left,friendly_fire,t1-t0,shots_fired);
|
||||
GrPrint(dc,0,0,"Enemy:%d Friends:%d Friendly Fire:%d Time:%6.2f Bullets:%d",
|
||||
enemy_left,friendly_left,friendly_fire,t1-t0,bullets_fired);
|
||||
GrPrint(dc,0,8,"Total Score:%,d High Score:%,d",
|
||||
total_score,best_score);
|
||||
}
|
||||
@@ -182,14 +188,14 @@ U0 CheckCollisions()
|
||||
{
|
||||
I64 i,x,y;
|
||||
Man *tempm;
|
||||
Shot *temps;
|
||||
Bullet *tempb;
|
||||
CDC *dc2=DCNew(GR_WIDTH,GR_HEIGHT);
|
||||
dc2->color=LTRED;
|
||||
for (i=0,temps=s;i<MAX_SHOTS;i++,temps++)
|
||||
if (!temps->dead)
|
||||
GrLine(dc2,temps->x>>32,temps->y>>32,
|
||||
(temps->x+temps->dx*SHOT_LEN)>>32,
|
||||
(temps->y+temps->dy*SHOT_LEN)>>32);
|
||||
for (i=0,tempb=b;i<MAX_BULLETS;i++,tempb++)
|
||||
if (!tempb->dead)
|
||||
GrLine(dc2,tempb->x>>32,tempb->y>>32,
|
||||
(tempb->x+tempb->dx*BULLET_LEN)>>32,
|
||||
(tempb->y+tempb->dy*BULLET_LEN)>>32);
|
||||
|
||||
dc2->color =ROP_COLLISION;
|
||||
dc2->bkcolor=BLACK;
|
||||
@@ -200,9 +206,9 @@ U0 CheckCollisions()
|
||||
if (0<=x<GR_WIDTH && 0<=y<GR_HEIGHT) {
|
||||
dc2->collision_cnt=0;
|
||||
if (tempm->friendly)
|
||||
Sprite3(dc2,x,y,0,$IB,"<friend>",BI=2$);
|
||||
Sprite3(dc2,x,y,0,$IB,"<2>",BI=2$);
|
||||
else
|
||||
Sprite3(dc2,x,y,0,$IB,"<enemy>",BI=3$);
|
||||
Sprite3(dc2,x,y,0,$IB,"<6>",BI=6$);
|
||||
if (dc2->collision_cnt) {
|
||||
tempm->dead=TRUE;
|
||||
tempm->corpse_timeout=tS+30.0;
|
||||
@@ -227,7 +233,7 @@ U0 Init()
|
||||
I64 i,xx,yy;
|
||||
Man *tempm;
|
||||
|
||||
snd_shot_timeout=snd_death_timeout=0;
|
||||
snd_bullet_timeout=snd_death_timeout=0;
|
||||
Snd(0);
|
||||
|
||||
total_score=0;
|
||||
@@ -269,44 +275,46 @@ U0 Init()
|
||||
tempm->x=xx+64*RandI32/MAX_I32+100;
|
||||
tempm->y=yy+64*RandU32/MAX_I32-64+100;
|
||||
tempm->corpse_timeout=0;
|
||||
tempm->hack_phase=2*ã*Rand;
|
||||
tempm->closest_d=MAX_I64;
|
||||
}
|
||||
for (i=0;i<MAX_SHOTS;i++)
|
||||
s[i].dead=TRUE;
|
||||
for (i=0;i<MAX_BULLETS;i++)
|
||||
b[i].dead=TRUE;
|
||||
friendly_left=MAX_FRIENDLY;
|
||||
enemy_left =MAX_ENEMY;
|
||||
enemy_by_friendly=0;
|
||||
shots_fired=0;
|
||||
bullets_fired=0;
|
||||
friendly_fire=0;
|
||||
t0=tS;
|
||||
tf=0;
|
||||
}
|
||||
|
||||
U0 FireShot()
|
||||
U0 FireBullet()
|
||||
{
|
||||
I64 i,j;
|
||||
F64 a;
|
||||
Shot *temps;
|
||||
for (i=0;i<MAX_SHOTS-1;i++)
|
||||
if (s[i].dead)
|
||||
Bullet *tempb;
|
||||
for (i=0;i<MAX_BULLETS-1;i++)
|
||||
if (b[i].dead)
|
||||
break;
|
||||
temps=&s[i];
|
||||
tempb=&b[i];
|
||||
|
||||
j=x+24.0*Sin(é);
|
||||
temps->x=j<<32;
|
||||
tempb->x=j<<32;
|
||||
|
||||
j=y-24.0*Cos(é);
|
||||
temps->y=j<<32;
|
||||
tempb->y=j<<32;
|
||||
|
||||
temps->dx2=(SHOT_SPEED*Sin(é)+dx)*0x100000000;
|
||||
temps->dy2=-SHOT_SPEED*Cos(é)*0x100000000;
|
||||
a=Arg(temps->dx2,temps->dy2);
|
||||
temps->dx=Cos(a)*0x100000000;
|
||||
temps->dy=Sin(a)*0x100000000;
|
||||
shots_fired++;
|
||||
temps->dead=FALSE;
|
||||
tempb->dx2=(BULLET_SPEED*Sin(é)+dx)*0x100000000;
|
||||
tempb->dy2=-BULLET_SPEED*Cos(é)*0x100000000;
|
||||
a=Arg(tempb->dx2,tempb->dy2);
|
||||
tempb->dx=Cos(a)*0x100000000;
|
||||
tempb->dy=Sin(a)*0x100000000;
|
||||
bullets_fired++;
|
||||
tempb->dead=FALSE;
|
||||
if (!snd_death_timeout) {
|
||||
Snd(1000);
|
||||
snd_shot_timeout=tS+0.0005;
|
||||
snd_bullet_timeout=tS+0.0005;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,9 +334,11 @@ U0 MenMove(I64 phase_group)
|
||||
}
|
||||
}
|
||||
}
|
||||
m[i].closest_d=closest_d;
|
||||
if (closest_d!=MAX_I64) {
|
||||
m[i].x+=4*SignI64(m[closest].x-m[i].x);
|
||||
m[i].y+=4*SignI64(m[closest].y-m[i].y);
|
||||
m[i].é=Arg(m[closest].x-m[i].x,m[closest].y-m[i].y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,15 +355,16 @@ U0 MenMove(I64 phase_group)
|
||||
}
|
||||
}
|
||||
}
|
||||
m[i].closest_d=closest_d;
|
||||
if (closest_d!=MAX_I64) {
|
||||
m[i].x+=4*SignI64(m[closest].x-m[i].x);
|
||||
m[i].y+=4*SignI64(m[closest].y-m[i].y);
|
||||
m[i].é=Arg(m[closest].x-m[i].x,m[closest].y-m[i].y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
U0 MenFight(I64 phase_group)
|
||||
{
|
||||
I64 i,j,d,closest,closest_d;
|
||||
@@ -370,7 +381,8 @@ U0 MenFight(I64 phase_group)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (closest_d<8*8)
|
||||
m[i].closest_d=closest_d;
|
||||
if (closest_d<HACK_DIST*HACK_DIST)
|
||||
if (!(RandU16&1)) {
|
||||
enemy_left--;
|
||||
enemy_by_friendly++;
|
||||
@@ -392,7 +404,8 @@ U0 MenFight(I64 phase_group)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (closest_d<8*8)
|
||||
m[i].closest_d=closest_d;
|
||||
if (closest_d<HACK_DIST*HACK_DIST)
|
||||
if (!(RandU16&1)) {
|
||||
friendly_left--;
|
||||
m[closest].dead=TRUE;
|
||||
@@ -404,7 +417,7 @@ U0 MenFight(I64 phase_group)
|
||||
|
||||
U0 TimeOut()
|
||||
{
|
||||
I64 i,msg_code,p1,p2;
|
||||
I64 i,msg_code,a1,a2;
|
||||
Bool gun_on;
|
||||
|
||||
I64 next_update_jiffy;
|
||||
@@ -433,10 +446,9 @@ U0 TimeOut()
|
||||
" Enemy Killed\t\t+5\n"
|
||||
" Enemy by Friendly\t+10\n"
|
||||
" Friendly Fire\t\t-200\n"
|
||||
" Shots Fired\t\t-1\n"
|
||||
" Bullets Fired\t\t-1\n"
|
||||
" Game Time\t\t-10 per second\n"
|
||||
" Surviving Friendlies\t+500\n"
|
||||
"\n";
|
||||
" Surviving Friendlies\t+500\n\n";
|
||||
|
||||
PressAKey;
|
||||
Fs->text_attr=YELLOW<<4+CYAN;
|
||||
@@ -449,12 +461,12 @@ U0 TimeOut()
|
||||
|
||||
try {
|
||||
while (TRUE) {
|
||||
next_update_jiffy=sys_jiffies+JIFFY_FREQ/100;
|
||||
while (msg_code=ScanMsg(&p1,&p2,
|
||||
next_update_jiffy=cnts.jiffies+JIFFY_FREQ/100;
|
||||
while (msg_code=ScanMsg(&a1,&a2,
|
||||
1<<MSG_KEY_DOWN+1<<MSG_KEY_UP)) {
|
||||
switch (msg_code) {
|
||||
case MSG_KEY_DOWN:
|
||||
switch (p1) {
|
||||
switch (a1) {
|
||||
case CH_SHIFT_ESC:
|
||||
case CH_ESC:
|
||||
goto to_done;
|
||||
@@ -467,9 +479,9 @@ U0 TimeOut()
|
||||
}
|
||||
break;
|
||||
case MSG_KEY_UP:
|
||||
if (p1==CH_SPACE)
|
||||
if (a1==CH_SPACE)
|
||||
gun_on=FALSE;
|
||||
else if (p2.u8[0]==SC_CURSOR_RIGHT||p2.u8[0]==SC_CURSOR_LEFT)
|
||||
else if (a2.u8[0]==SC_CURSOR_RIGHT||a2.u8[0]==SC_CURSOR_LEFT)
|
||||
é=0.0;
|
||||
break;
|
||||
}
|
||||
@@ -479,27 +491,27 @@ U0 TimeOut()
|
||||
snd_death_timeout=0;
|
||||
Snd(0);
|
||||
}
|
||||
} else if (snd_shot_timeout && tS>snd_shot_timeout) {
|
||||
snd_shot_timeout=0;
|
||||
} else if (snd_bullet_timeout && tS>snd_bullet_timeout) {
|
||||
snd_bullet_timeout=0;
|
||||
Snd(0);
|
||||
}
|
||||
|
||||
for (i=0;i<MAX_SHOTS;i++) {
|
||||
if (!s[i].dead) {
|
||||
s[i].x+=s[i].dx2;
|
||||
s[i].y+=s[i].dy2;
|
||||
if (s[i].y<0||s[i].x<0||
|
||||
s[i].x>>32>=Fs->pix_width||
|
||||
s[i].y>>32>=Fs->pix_height)
|
||||
s[i].dead=TRUE;
|
||||
for (i=0;i<MAX_BULLETS;i++) {
|
||||
if (!b[i].dead) {
|
||||
b[i].x+=b[i].dx2;
|
||||
b[i].y+=b[i].dy2;
|
||||
if (b[i].y<0||b[i].x<0||
|
||||
b[i].x>>32>=Fs->pix_width||
|
||||
b[i].y>>32>=Fs->pix_height)
|
||||
b[i].dead=TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
dx=0;
|
||||
if (Bt(key_down_bitmap,SC_CURSOR_LEFT)) {
|
||||
if (Bt(kbd.down_bitmap,SC_CURSOR_LEFT)) {
|
||||
é=-15.0*ã/180.0;
|
||||
dx=-2;
|
||||
} else if (Bt(key_down_bitmap,SC_CURSOR_RIGHT)) {
|
||||
} else if (Bt(kbd.down_bitmap,SC_CURSOR_RIGHT)) {
|
||||
é=15.0*ã/180.0;
|
||||
dx=2;
|
||||
}
|
||||
@@ -533,7 +545,7 @@ U0 TimeOut()
|
||||
case 2:
|
||||
case 6:
|
||||
if (gun_on)
|
||||
FireShot;
|
||||
FireBullet;
|
||||
break;
|
||||
case 1:
|
||||
case 3:
|
||||
@@ -551,12 +563,12 @@ U0 TimeOut()
|
||||
+10*enemy_by_friendly
|
||||
-200*friendly_fire
|
||||
-10*(tS-t0)
|
||||
-shots_fired;
|
||||
-bullets_fired;
|
||||
if (game_over) {
|
||||
tf=tS;
|
||||
Sleep(500);
|
||||
Sleep(750);
|
||||
FlushMsgs;
|
||||
while (!ScanKey(&p1)&&friendly_left) {
|
||||
while (!ScanKey(&a1)&&friendly_left) {
|
||||
total_score+=500;
|
||||
Snd(2000); Sleep(150);
|
||||
Snd(0); Sleep(50);
|
||||
@@ -565,8 +577,8 @@ U0 TimeOut()
|
||||
total_score+=500*friendly_left;
|
||||
if (total_score>best_score)
|
||||
best_score=total_score;
|
||||
if (!p1) p1=GetChar(,FALSE);
|
||||
if (p1==CH_ESC||p1==CH_SHIFT_ESC)
|
||||
if (!a1) a1=GetChar(,FALSE);
|
||||
if (a1==CH_ESC||a1==CH_SHIFT_ESC)
|
||||
goto to_done;
|
||||
gun_on=FALSE;
|
||||
Init;
|
||||
@@ -581,7 +593,8 @@ to_done:
|
||||
MenuPop;
|
||||
AcctRegWriteBranch("TempleOS/TimeOut","I64 best_score=%d;\n",best_score);
|
||||
}
|
||||
| ||||