📄 dropnuke.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>
#define VIDEO 0x10 //Video interrupt
#define COLS 80 //Screen width
#define ROWS 25 //Screen rows
#define BOTTOM_ROW 24 //Bottom Row
#define CENTER_COL 39 //Center column
#define BOMB 162 //bomb character
void pause(int seconds);
void cls(void);
void locate(int col,int row);
void delay(int duration);
void main()
{
int drop;
cls();
locate(CENTER_COL-3,BOTTOM_ROW);
printf("REDMOND");
locate(0,0);
printf("Press Enter to drop nuclear weapon:");
getch();
//This loop drops the bomb down to the city, slowly
for(drop=0;drop<BOTTOM_ROW;drop++)
{
locate(CENTER_COL,drop);
printf("%c",BOMB);
pause(1); //pause one second
if(kbhit())
{
goto cancel;
}
}
locate(CENTER_COL-3,BOTTOM_ROW);
printf("BOOM!!!\n");
exit(0); //quit here
cancel:
locate(0,24);
printf("You saved the town!\n");
getch(); //read in kbhit char.
}
void pause(int seconds)
{
delay(seconds*1000); //Borland Compilers
}
void cls(void)
{
union REGS regs;
regs.h.ah=0x06; //call function 6, scroll window
regs.h.al=0x00; //clear screen
regs.h.bh=0x07; //make screen "blank" color
regs.h.ch=0x00; //Upper left row
regs.h.cl=0x00; //Upper left column
regs.h.dh=ROWS-1; //Lower right row
regs.h.dl=COLS-1; //Lower right column
int86(VIDEO,®s,®s);
locate(0,0); //"Home" the cursor
}
void locate(int col,int row)
{
union REGS regs;
regs.h.ah=0x02; //video function 2, move cursor
regs.h.bh=0x00; //video screen (always 0)
regs.h.dh=row; //cursor's row position
regs.h.dl=col; //cursor's col position
int86(VIDEO,®s,®s);
}
#include <time.h>
void delay(int duration)
{
clock_t done;
done = duration + clock();
while( done > clock() )
;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -