import "ecere" #define NUMLEVELS 11 #define DIMX 16 #define DIMY 16 #define MAXTIME (5*60) #define TIME2 (4*60) #define TIME1 (2*60) #define TIMEBAR gray #define TIMEFILL darkBlue #define NOTHING 0 #define PLAYER 1 #define BOMB5 2 #define BOMB3 3 #define BOMB1 4 #define BOMBD 5 #define DESACTIV 6 #define BLOCK 7 #define STATE_MENU 0 #define STATE_GAME 1 #define STATE_CREDITS 2 #define STATE_ENDSCREEN 3 #define STATE_PASSWORD 4 static char passwords[NUMLEVELS+1][5] = { "","1111","2222","3333","4444","5555","6666", "7777","8888","9999","AAAA","BBBB" }; BombApp app; class Bomb : Window { borderStyle = sizable, hasMaximize = true, hasMinimize = true, hasClose = true; text = "Bomb Squad", clientSize = Size { 640,400 }; bool fullScreen; char board[DIMY][DIMX]; Bitmap gfx[8]; Bitmap mainBitmap {}; Bitmap credits {}; Bitmap endScreen {}; Bitmap password {}; Size mapSize; Point player; double startTime, secPassed; int level; int state; bool DelayExpired() { int x,y, b; double currentTime = GetTime(); secPassed = currentTime - startTime; if(secPassed >= TIME2)b=BOMB1; else if(secPassed >= TIME1)b=BOMB3; else b=BOMB5; for(y=0; y= MAXTIME) { state = STATE_MENU; SetPalette(true); timer.Stop(); } Update(null); return true; } Timer timer { this, Seconds { 1 }, DelayExpired = DelayExpired }; EditBox passEdit { this, textHorzScroll = true, text = "Password", anchor = Anchor { left = 0.03, top = 0.05, right = 0.84, bottom = 0.80 }, autoCreate = false }; Bitmap buffer {}; bool IsDone() { bool lost = false; int x,y; for(y=0; y=DIMX)||(player.y+dy>=DIMY)) return true; if(board[player.y+dy][player.x+dx]==BLOCK) return true; if((board[player.y+dy][player.x+dx]==BOMB5) ||(board[player.y+dy][player.x+dx]==BOMB3) ||(board[player.y+dy][player.x+dx]==BOMB1) ||(board[player.y+dy][player.x+dx]==BOMBD)) { if((player.x+dx*2<0)||(player.y+dy*2<0)||(player.x+dx*2>=DIMX)||(player.y+dy*2>=DIMY)) return true; if((board[player.y+2*dy][player.x+2*dx]!=DESACTIV)&& (board[player.y+2*dy][player.x+2*dx]!=NOTHING)) return true; if(board[player.y+dy][player.x+dx]==BOMBD) board[player.y+dy][player.x+dx]=DESACTIV; else board[player.y+dy][player.x+dx]=NOTHING; if(board[player.y+2*dy][player.x+2*dx]==DESACTIV) board[player.y+2*dy][player.x+2*dx]=BOMBD; else { int b; if(secPassed >= TIME2)b=BOMB1; else if(secPassed >= TIME1)b=BOMB3; else b=BOMB5; board[player.y+2*dy][player.x+2*dx]=(byte)b; } } player.x+=dx; player.y+=dy; if(IsDone()) { if(level == NUMLEVELS) { state = STATE_ENDSCREEN; SetPalette(true); } else { char string[80]; sprintf(string, "Password to level %d is: %s",level+1,passwords[level+1]); timer.Stop(); MessageBox { text = "Congratulations! You win!", contents = string }.Modal(); LoadLevel(level + 1); } } Update(null); } return true; } } class BombApp : GuiApplication { Bomb bomb {}; void Main() { app = this; GuiApplication::Main(); } }