📄 disp.c
字号:
}
}
Spr_Print( SFont,"Score",PANEL_XBASE,PANEL_YBASE,PROPORTIONAL,HORIZ,SPLIT_PAGE );
Spr_Print( SFont,"Level",PANEL_XBASE,PANEL_YBASE+12,PROPORTIONAL,HORIZ,SPLIT_PAGE );
Display_Score();
Spr_Printi( SFont,Cfg.level,PANEL_XBASE+48,PANEL_YBASE+12,2,8,HORIZ,SPLIT_PAGE );
Spr_Print( SFont,"Shields",PANEL_XBASE1,PANEL_YBASE,PROPORTIONAL,HORIZ,SPLIT_PAGE );
Spr_Print( SFont,"Neutron",PANEL_XBASE1,PANEL_YBASE+12,PROPORTIONAL,HORIZ,SPLIT_PAGE );
Display_Shields();
Display_Neutron();
Spr_Print( SFont,"Time",PANEL_XBASE2,PANEL_YBASE,PROPORTIONAL,HORIZ,SPLIT_PAGE );
Spr_Print( SFont,":",PANEL_XBASE2+48,PANEL_YBASE,PROPORTIONAL,HORIZ,SPLIT_PAGE );
Display_Time();
fadein( &Pal,0 );
}
void Display_Score ( void )
{
rect( PANEL_XBASE+48,PANEL_YBASE,PANEL_XBASE+95,PANEL_YBASE+7,CONTROL_PANEL_COLOUR,FILL,SPLIT_PAGE );
Spr_Printl( SFont,Cfg.score,PANEL_XBASE+48,PANEL_YBASE,6,8,HORIZ,SPLIT_PAGE );
}
void Display_Shields( void )
{
rect( PANEL_XBASE1+63,PANEL_YBASE,PANEL_XBASE1+78,PANEL_YBASE+7,CONTROL_PANEL_COLOUR,FILL,SPLIT_PAGE );
Spr_Printi( SFont,Cfg.shield_cnt,PANEL_XBASE1+63,PANEL_YBASE,2,8,HORIZ,SPLIT_PAGE );
}
void Display_Time ( void )
{
int m=Cfg.time/60;
if ( Last_Mins != m )
{
rect( PANEL_XBASE2+32,PANEL_YBASE,PANEL_XBASE2+47,PANEL_YBASE+7,CONTROL_PANEL_COLOUR,FILL,SPLIT_PAGE );
Spr_Printi( SFont,Last_Mins=m,PANEL_XBASE2+32,PANEL_YBASE,2,8,HORIZ,SPLIT_PAGE );
}
rect( PANEL_XBASE2+52,PANEL_YBASE,PANEL_XBASE2+77,PANEL_YBASE+7,CONTROL_PANEL_COLOUR,FILL,SPLIT_PAGE );
Spr_Printi( SFont,Cfg.time%60,PANEL_XBASE2+52,PANEL_YBASE,2,8,HORIZ,SPLIT_PAGE );
}
void Display_Title_Screen( void )
{
int i, key;
Fade_Screen( MODE_320x200x256 );
Draw_Fractal_Background( 0 );
COPY_PAGE( 0,1 );
COPY_PAGE( 0,2 );
fadein( &Pal,0 );
initialise_objects( 14,&Selective_Replace,&Colour_Cycle_Switcher );
for ( i=0; i<7; i++ )
{
add_object( i,Toon_Logo[LogoIndex1[i]],0,LOGO_TL_X+30*i,-32 );
add_object( i+7,Toon_Logo[LogoIndex2[i]],0,LOGO_BL_X+30*i,201 );
}
ZERO( Logo_Control );
Logo_Control[i=0]=Logo_Control[7]=1;
Timers[5]=LOGO_DELAY;
CONSUME_KEYS;
do
{
update_objects( 0,0,2 );
if ( (key=inkey(0)) ) Process_Keystroke( key );
Cycle_Fractal_Colours();
if ( !Timers[5] )
{
if ( i>=8 ) break;
if ( ++i>6 )
{
add_object( 0,Toon_Nucleus,0,((VS.mx-Nucleus_Logo.w)>>1)-6,(VS.my-Nucleus_Logo.h)>>1 );
Timers[5] = 72;
}
else
{
Logo_Control[i]=Logo_Control[i+7]=1;
Timers[5] = (i<6)?LOGO_DELAY:LOGO_DELAY*3;
}
}
if ( Demo_Exited ) break;
}
while ( uppercase((char)key)=='P' || !key );
CONSUME_KEYS;
remove_objects();
}
void Draw_Edged_Box( int x1, int y1, int x2, int y2, int sun, int shdw, int fill, int page )
{
line( x1,y1,x2,y1,sun,page );
line( x1,y1,x1,y2,sun,page );
line( x1+1,y2,x2,y2,shdw,page );
line( x2,y2,x2,y1+1,shdw,page );
rect( x1+1,y1+1,x2-1,y2-1,fill,FILL,page );
line( x1+4,y1+3,x2-4,y1+3,shdw,page );
line( x1+4,y1+3,x1+4,y2-3,shdw,page );
line( x1+5,y2-3,x2-4,y2-3,sun,page );
line( x2-4,y2-3,x2-4,y1+4,sun,page );
}
void Draw_Fractal_Background( int page )
{
int x, y;
for ( y=0; y<=VS.my; y+=Fractal.h )
for ( x=0; x<=VS.mx; x+=Fractal.w )
putspr( &Fractal,x,y,OWRTE,page );
}
void End_Of_Level_Bonus( void )
{
char *title="Bonus!", *equals="=", *msgs[2]={ "End Of Level!",NULL };
int ht=SFont[' '].h, wth=240, x1, y1, x2, y2, i, j, total, speedy=FALSE, cnt, pts;
CONSUME_KEYS;
Show_Error_Message( msgs,SFX_LEVEL_START,2,IPage );
x2 = (x1=(VS.mx+1-wth-6)>>1) + wth + 5;
y2 = (y1=(VS.my+1-ht*11-6)>>1) + ht*11 + 5;
Draw_Edged_Box( x1,y1,x2,y2,WHITE,GREY,L_GREY,IPage );
x2 = x1 + ((wth-Spr_Strlen(SFont,title))>>1);
Spr_Print( SFont,title,x2,y1+5,PROPORTIONAL,HORIZ,IPage );
line( x2-1,y1+ht+5,x2+Spr_Strlen(SFont,title),y1+ht+5,WHITE,IPage );
line( x2-2,y1+ht+6,x2+Spr_Strlen(SFont,title)+1,y1+ht+6,GREY,IPage );
CONSUME_KEYS;
Sfx( SFX_BONUS_PICKUP );
Spr_Print( SFont,"Level Completion",x1+11,y1+ht*3+5,PROPORTIONAL,HORIZ,IPage );
Spr_Print( SFont,equals,x1+22*8+3,y1+ht*3+5,PROPORTIONAL,HORIZ,IPage );
Spr_Printi( SFont,total=PTS_END_OF_LEVEL_BONUS,x1+24*8+3,y1+ht*3+5,5,8,HORIZ,IPage );
speedy = (inkey(0)!=0);
for ( i=0; i<2; i++ )
{
if ( !speedy )
{
waitticks( 9 );
speedy = (inkey(0)!=0);
}
CONSUME_KEYS;
if ( i==0 )
{
y2 = y1+ht*5+5;
cnt = Cfg.rays;
pts = PTS_NEUTRON_LEFT;
}
else
{
y2 = y1+ht*7+5;
cnt = Cfg.shield_cnt;
pts = PTS_SHIELD_LEFT;
}
if ( !cnt ) pts=0;
Spr_Print( SFont,(i==0)?"Remaining Neutrons":"Remaining Shields",x1+11,y2,PROPORTIONAL,HORIZ,IPage );
Spr_Printi( SFont,cnt,x1+19*8+3,y2,2,8,HORIZ,IPage );
Spr_Print( SFont,equals,x1+22*8+3,y2,PROPORTIONAL,HORIZ,IPage );
x2 = x1 + 24*8 + 3;
for ( j=0; j<=cnt; j++ )
{
if ( cnt==0 || j<cnt )
{
if ( !speedy ) Sfx( SFX_BONUS_PICKUP );
rect( x2,y2,x2+40,y2+ht,L_GREY,FILL,IPage );
Spr_Printi( SFont,(j+1)*pts,x2,y2,5,8,HORIZ,IPage );
if ( !speedy )
{
waitticks( 1 );
speedy = (inkey(0)!=0);
}
}
CONSUME_KEYS;
}
total += cnt*pts;
}
if ( !speedy ) Sfx( SFX_BONUS_PICKUP );
y2 = y1 + ht*9 + 5;
Spr_Print( SFont,"Total Bonus",x1+11,y2,PROPORTIONAL,HORIZ,IPage );
Spr_Printi( SFont,total,x1+24*8+3,y2,5,8,HORIZ,IPage );
Cfg.score += (long)total;
CONSUME_KEYS;
i = (speedy)?1:5;
Wait_For_Event( i );
}
void Fade_Screen( int mode )
{
PALETTE p;
if ( allocpal(&p,VGA_PALETTE)==NULL ) Terminate( ERR_MALLOC );
getpals( &p );
fadeout( &p,0 );
memset( p.pal,BLACK,VGA_PALETTE_SIZE );
setmode( mode );
setpals( &p );
freepal( &p );
}
int Particle_Hit_Shield( PARTICLE *p, int wth, int ht )
{
int j, ave_sr, ave_pr, theta, ac, px, py, nx, ny, vx, vy, rx, ry, x1, y1, x2, y2, m1, m2, factor;
SHIELD *s;
unsigned int dx, dy, d;
ave_pr = (wth+ht)>>2;
ave_pr -= ave_pr>>3;
for ( j=MAX_SHIELDS, s=Cfg.shields; j; j--, s++ )
{
if ( s->active )
{
ave_sr = (s->rx+s->ry)>>1;
dx = (s->x >= p->x) ? s->x-p->x : p->x-s->x;
dy = (s->y >= p->y) ? s->y-p->y : p->y-s->y;
if ( dx<=(ave_sr+ave_pr) && dy<=(ave_sr+ave_pr) ) /* Prevents overflow for pseudoroot */
{
d = RootTable[dx*dx+dy*dy];
m1 = p->x+p->vx-s->x; m1=ABS(m1);
m2 = p->y+p->vy-s->y; m2=ABS(m2);
m1 = RootTable[ m1*m1+m2*m2 ];
if ( (ave_sr<=d && d<=ave_sr+ave_pr && m1<d) || (ave_sr>=d && ave_sr-ave_pr<=d && m1>d) )
{
/* Determine angle of incidence & therefore reflection */
if ( d>=ave_sr )
{
Cfg.score += PTS_SHIELD_HIT;
Update_Score = TRUE;
}
vx = p->vx*5; /* Velocity vector */
vy = p->vy*5;
nx = (px=p->x)-s->x; /* Point of incidence & normal vector */
ny = (py=p->y)-s->y;
m1 = RootTable[ nx*nx+ny*ny ];
m2 = RootTable[ vx*vx+vy*vy ];
factor = (m2*100)/m1;
ac = (int) (((long)(nx*(-vx)+ny*(-vy))*(long)TRIG_TAB_FACTOR)/((long)(m1*m2)));
if ( (theta=PseudoACos(ac)%360)<5 )
{
rx = -vx;
ry = -vy;
}
else
{
rx = (nx*PseudoCos(theta) - ny*PseudoSin(theta))/TRIG_TAB_FACTOR;
ry = (nx*PseudoSin(theta) + ny*PseudoCos(theta))/TRIG_TAB_FACTOR;
rx = (rx*factor)/100;
ry = (ry*factor)/100;
x1 = px-vx;
y1 = py-vy;
x2 = px+rx;
y2 = py+ry;
if ( ABS(x1-x2)<=3 && ABS(y1-y2)<=3 )
{
theta = 180-theta;
rx = ((-nx)*PseudoCos(theta) - (-ny)*PseudoSin(theta))/TRIG_TAB_FACTOR;
ry = ((-nx)*PseudoSin(theta) + (-ny)*PseudoCos(theta))/TRIG_TAB_FACTOR;
rx = (rx*factor)/100;
ry = (ry*factor)/100;
}
}
if ( (p->vx=rx/5)==0 ) p->vx=(rx>0)?1:-1;
if ( (p->vy=ry/5)==0 ) p->vy=(ry>0)?1:-1;
/* If at single speed, energize them to avoid being caught in rasp fashion */
if ( ABS(p->vx)==1 && ABS(p->vy)==1 )
{
p->vx += (p->vx>0)?1:-1;
p->vy += (p->vy>0)?1:-1;
}
Sfx( SFX_SHIELD_HIT );
return( TRUE );
}
}
}
}
return( FALSE );
}
void Play_Demo( void )
{
static int ftype;
NUCLEUS *n;
int i, dx, dy;
if ( Target_Nuc==-1 || Cfg.nuclei[Target_Nuc].mass==0 )
{
for ( Target_Nuc=-1, i=0, n=Cfg.nuclei; i<MAX_NUCLEI && Target_Nuc==-1; i++, n++ )
{
if ( n->mass )
{
if ( (Lev->rogue_particles || Lev->rogue_beams) && !(n->n_fired || n->s_fired) )
{
Target_Nuc = i;
ftype = (n->s_fired) ? L_BUTTON:R_BUTTON;
}
else
{
if ( Lev->mass_meltdown && n->mass+4>=Lev->critical_mass && !n->s_fired )
{
Target_Nuc = i;
ftype = R_BUTTON;
}
else
{
if ( Lev->time_meltdown && !n->n_fired )
{
Target_Nuc = i;
ftype = L_BUTTON;
}
}
}
}
}
}
if ( Target_Nuc != -1 )
{
n = Cfg.nuclei+Target_Nuc;
dx = n->cx - MouseX;
dy = n->cy - MouseY;
if ( ABS(dx) > 3 ) dx=(dx<0)?-3:3;
if ( ABS(dy) > 3 ) dy=(dy<0)?-3:3;
mousepos( MouseX+=dx,MouseY+=dy );
dx = MouseX - n->cx;
dy = MouseY - n->cy;
if ( ABS(dx)<4 && ABS(dy)<4 )
{
if ( SyringeDir==0 )
{
if ( ftype==L_BUTTON )
{
if ( Cfg.rays )
{
n->n_fired=TRUE;
MouseB =ftype;
}
}
else
{
if ( Cfg.shield_cnt )
{
n->s_fired=TRUE;
MouseB =ftype;
}
}
Target_Nuc=-1;
}
}
}
}
int Play_Level( void )
{
int i, key=0;
long score;
unsigned int *t;
PARTICLE *p;
NUCLEUS *n;
SHIELD *s;
BEAM *b;
char *msgs[2]={ "Get Ready!",NULL };
Meltdown = NO_MELTDOWN;
do
{
Lev = Levels + Cfg.level - 1;
if ( !Cfg.briefed )
{
Show_Experiment_Guide();
Cfg.briefed=TRUE;
if ( Demo_Mode && Demo_Exited ) break;
}
Fade_Screen( MODE_320x200x256 );
Draw_Fractal_Background( 0 );
fadein( &Pal,0 );
CONSUME_KEYS;
Show_Error_Message( msgs,SFX_LEVEL_START,2,0 );
if ( Demo_Mode && Demo_Exited ) break;
Last_Mins = Target_Nuc = -1;
Display_Panel();
COPY_PAGE( 0,1 );
COPY_PAGE( 0,2 );
initialise_objects( MAX_OBJECTS,&Selective_Replace,&Colour_Cycle_Switcher );
mousepos( I_MouseX=MouseX=VS.mx>>1,I_MouseY=MouseY=VS.my>>1 );
SyringeOffset=SyringeDir=0;
add_object( SYRINGE_TOON_BASE_PRI,Toon_Syringe,SyringeBase=5,MouseX,MouseY );
if ( Demo_Mode )
{
add_object( DEMO_TOON_BASE_PRI,Toon_Demo,0,(VS.mx-Demo_Icons[0].w)>>1,(VS.my-Demo_Icons[0].h)>>1 );
Demo_Timer=360;
}
for ( i=0; i<Lev->count; i++ )
add_object( PARTICLE_TOON_BASE_PRI+i,Toon_Particle[Cfg.particles[i].type],0,Cfg.particles[i].x,Cfg.particles[i].y );
for ( i=0, n=Cfg.nuclei; i<MAX_NUCLEI; i++, n++ )
if ( n->mass ) add_object( COUNTER_TOON_BASE_PRI+i,Toon_Counter,n->cframe,n->cx-3,n->cy-2 );
for ( i=0, s=Cfg.shields; i<MAX_SHIELDS; i++, s++ )
if ( s->active ) add_object( SHIELD_TOON_BASE_PRI+i,Toon_Shield,s->frame,s->x,s->y );
for ( i=0, b=Cfg.beams; i<MAX_BEAMS; i++, b++ )
if ( b->active ) add_object( BEAM_TOON_BASE_PRI+i,Toon_Beam,b->frame,b->x,b->y );
for ( i=0, p=Cfg.rogues; i<MAX_ROGUE_PARTICLES; i++, p++ )
if ( p->rogue ) add_object( ROGUE_TOON_BASE_PRI+i,Toon_Rogue_Particle,p->frame,p->x,p->y );
Experiment_Timer = 18;
Game_Paused = Neutron_Fired = Update_Score = FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -