首頁
程式語言
工具下載
學習範例
技術專區
相關書籍
原始碼程式範例
好站相報
技術論壇
易尋網
ASP空間租賃
汽車追蹤的第一個家
弘光科技大學
南開技術學院
巨匠電腦
買賣購物網
Life Light
遠距醫療網
清境民宿珂之幄
原始程式碼
#include <stdio.h> #include <conio.h> #include <graphics.h> #include <dos.h> #include <stdlib.h> void initframe(void); void shotbomb(void); void shuttle(int x, int y); void blackshuttle(int x, int y); void moveright(int x, int y); void moveleft(int x, int y); void moveup(int x, int y); void movedown(int x, int y); int bomb[20][2]; int xx = 320, yy = 400; void main(void) { int driver, mode; driver = VGA; mode = VGAHI; initgraph(&driver, &mode, ""); initframe(); //line(100,100,200,200); shuttle(xx,yy); //blackshuttle(x,y); int n; int key1,key2; while(1) { if (kbhit()) { key1 = getch(); if (key1 == 27) { exit(0); } if (key1 == 0) { key2 = getch(); // up key if (key2 == 72) { if (yy > 75) { moveup(xx,yy); } } // down key if (key2 == 80) { if (yy < 444) { movedown(xx,yy); } } // left key if (key2 == 75) { if (xx > 75) { moveleft(xx,yy); } } if (key2 == 77) { if (xx < 564) { moveright(xx,yy); } } } if (key1 == 32) { for (n=0;n<20;n++) { if (bomb[n][0] == 0) { sound(400); delay(20); nosound(); bomb[n][0] = xx; bomb[n][1] = yy - 30; break; } } } } shotbomb(); delay(10); } //getch(); closegraph(); } void shuttle(int x, int y) { setcolor(LIGHTGRAY); moveto(x,y-25); lineto(x-5,y-15); lineto(x-5,y+20); lineto(x+5,y+20); lineto(x+5,y-15); lineto(x, y-25); setfillstyle(1,LIGHTGRAY); floodfill(x,y,LIGHTGRAY); bar(x-15,y+5,x+15,y+15); fillellipse(x-15,y+10,6,20); fillellipse(x+15,y+10,6,20); setfillstyle(1,LIGHTRED); bar(x-1,y-30,x+1,y-25); } void blackshuttle(int x, int y) { setcolor(BLACK); moveto(x,y-25); lineto(x-5,y-15); lineto(x-5,y+20); lineto(x+5,y+20); lineto(x+5,y-15); lineto(x, y-25); setfillstyle(1,BLACK); floodfill(x,y,BLACK); bar(x-15,y+5,x+15,y+15); fillellipse(x-15,y+10,6,20); fillellipse(x+15,y+10,6,20); setfillstyle(1,BLACK); bar(x-1,y-30,x+1,y-25); } void moveup(int x,int y) { blackshuttle(x,y); yy = yy - 5; sound(800); delay(10); nosound(); shuttle(x,yy); } void movedown(int x,int y) { blackshuttle(x,y); yy = yy + 5; sound(800); delay(10); nosound(); shuttle(x,yy); } void moveleft(int x,int y) { blackshuttle(x,y); xx = xx - 5; sound(800); delay(10); nosound(); shuttle(xx,y); } void moveright(int x,int y) { blackshuttle(x,y); xx = xx + 5; sound(800); delay(10); nosound(); shuttle(xx,y); } void initframe(void) { int i,j; setcolor(LIGHTBLUE); rectangle(50,30,589,479); settextstyle(3,0,3); //moveto(55,2); //outtext("SCORE:"); outtextxy(55,2,"SCORE:"); setcolor(YELLOW); outtextxy(205,2,"0"); for (i=0;i<=19;i++) { for (j=0;j<=1;j++) { bomb[i][j] = 0; } } } void shotbomb(void) { int k; for (k=0;k<20;k++) { if (bomb[k][0] != 0) { if (bomb[k][1] > 40) { setfillstyle(1,BLACK); bar(bomb[k][0]-1, bomb[k][1]-5, bomb[k][0]+1, bomb[k][1]); setfillstyle(1,LIGHTRED); bomb[k][1] = bomb[k][1] - 5; bar(bomb[k][0]-1, bomb[k][1]-4, bomb[k][0]+1, bomb[k][1]); nosound(); } else { setfillstyle(1,BLACK); bar(bomb[k][0]-1, bomb[k][1]-5, bomb[k][0]+1, bomb[k][1]); bomb[k][0] = 0; bomb[k][1] = 0; } } } }
1. 請點選此處複製以上資料
2. 請按
ctrl-c
複製到剪貼簿
3. 切換到ASP的原始內碼區
4. 請按
ctrl-v
貼上所有資料