int msg_drop (int n, int msg, int z) { int sh=kindtable[obj_drop]*256; int c; objtype *pobj; pobj=&(objs[n]); switch (msg) { case msg_update: if (pobj->state==0) { if (++pobj->counter>=60) { pobj->counter=0; addobj (obj_drop,pobj->x,pobj->y+2,0,2); objs[numobjs-1].state=1; }; } else { if (!justmove(n,pobj->x,pobj->y+pobj->yd+2)) { c=((pobj->y+pobj->yd+2)&0xfff0)+16-pobj->yl; if ((c==pobj->y)||(!justmove(n,pobj->x,c))) { addobj (obj_splash,pobj->x-11,pobj->y+2,0,0); killobj (n); }; }; if ((pobj->yd+=2)>12) pobj->yd=12; }; return (1); case msg_draw: if (pobj->state==0) { drawshape (&gamevp,sh+12+pobj->counter/20,pobj->x,pobj->y); } else drawshape (&gamevp,sh+11,pobj->x,pobj->y); break; case msg_touch: if (z==0) hitplayer (n,0); }; return (0); };
static void drawview(int nexts, int nextc) { clearview(); if (nexts == 21 || nexts == 23) drawshape(nexts, nextc, VIEWX-1, VIEWY); else if (nexts >=24) drawshape(nexts, nextc, VIEWX+1, VIEWY); else drawshape(nexts, nextc, VIEWX, VIEWY); flush(); }
int msg_mines (int n, int msg, int z) { // space mines int sh, x, y; switch (msg) { case msg_update: objs[n].count = (objs[n].count + 1)&3; return (1); case msg_draw: sh = 0xf00 + 18 + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); break; case msg_touch: switch (objs[z].kind) { case obj_player: if (class_cnt(class_shield)==0) { p_hit (2); snd_play (1,5); x = objs[n].x - 11; y = objs[n].y - 9; addobj (obj_explode3, x, y, 0, 0); explosion (objs[n].x, objs[n].y, 5); text ("You hit an enemy space mine!",0); killobj (n); }; break; case obj_shield: addobj (obj_explode2, objs[n].x, objs[n].y, 0, 0); explosion (objs[n].x, objs[n].y, 5); text ("Your shield was destroyed by a space mine",0); killobj (n); killobj (z); snd_play (1,5); }; }; return (0); };
int msg_explode4 (int n, int msg, int z) { int sh; switch (msg) { case msg_update: objs[n].count = (objs[n].count + 1)&7; if (objs[n].count3==0) { switch (random(6)) { case 0: objs[n].count3 = 1; break; case 1: objs[n].count3 = 2; break; case 2: objs[n].count3 = 3; break; case 3: objs[n].count3 = 4; break; case 4: objs[n].count3 = 5; break; case 5: objs[n].count3 = 6; }; }; if (++objs[n].count2 >= 30) killobj (n); if (++objs[n].yd > 6) objs[n].yd = 6; move_obj (n, objs[n].x+objs[n].xd, objs[n].y+objs[n].yd); if (objs[n].y+objs[n].yl>=scrn_y) objs[n].yd=-objs[n].yd; return (1); case msg_draw: if (objs[n].count3==1) sh = 0x1000 + objs[n].count/2; if (objs[n].count3==2) sh = 0x1004 + objs[n].count/2; if (objs[n].count3==3) sh = 0x1008 + objs[n].count/2; if (objs[n].count3==4) sh = 0x100c + objs[n].count/2; if (objs[n].count3==5) sh = 0x1010 + objs[n].count/2; if (objs[n].count3==6) sh = 0x1014 + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int main(){ int gd = DETECT, gm; initgraph(&gd, &gm, ""); int x1, x2, x3, x4, y1, y2, y3; x1 = 100, x2 = 400, x3 = 250, x4 = 350, y1 = 100, y2 = 200, y3 = 50; int dx = 2; int radius = 20; int centre_x1 = 150, centre_x2 = 360; int centre_y1 = 220, centre_y2 = 220; for(int i = 0; i < 50; i++){ drawshape(x1,x2,x3,x4,y1,y2,y3); // The is for the body of the truck circle(centre_x1,centre_y1,radius); // For wheel1 of the truck circle(centre_x2,centre_y2,radius); // For wheel2 of the truck delay(100); cleardevice(); // For deleting this truck centre_x1 += dx; centre_x2 += dx; x1 += dx; x2 += dx; x3 += dx; x4 += dx; } delay(2000); return 0; }
int msg_stars (int n, int msg, int z) { // stars--just for looks! int sh; switch (msg) { case msg_draw: sh = 0xe00 + random (8); drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (1); };
int msg_laser (int n, int msg, int z) { // enemy laser weapon switch (msg) { case msg_update: if (objs[n].count2++ > 2) killobj (n); return (1); case msg_draw: drawshape (&gamevp, 0x600, objs[n].x, objs[n].y); break; }; return (0); };
int msg_bonus3 (int n, int msg, int z) { // apple--shields switch (msg) { case msg_update: objs[n].y += objs[n].yd; if (objs[n].y > scrn_y) killobj(n); return (1); case msg_draw: drawshape (&gamevp, 0x1201, objs[n].x, objs[n].y); }; return (0); };
int msg_bonus5 (int n, int msg, int z) { // strawberry--wingmen switch (msg) { case msg_update: objs[n].y += objs[n].yd; if (objs[n].y > scrn_y) killobj(n); return (1); case msg_draw: drawshape (&gamevp, 0x1203, objs[n].x, objs[n].y); }; return (0); };
int msg_falling (int n, int msg, int z) { // falling star--just for looks! switch (msg) { case msg_update: objs[n].x += objs[n].xd; objs[n].y += objs[n].yd; if (objs[n].y >= scrn_y) killobj(n); return (1); case msg_draw: drawshape (&gamevp, 0xe01, objs[n].x, objs[n].y); }; return (0); };
int msg_bonus4 (int n, int msg, int z) { // banana--points switch (msg) { case msg_update: objs[n].y += objs[n].yd; if (objs[n].y > scrn_y) killobj(n); return (1); case msg_draw: drawshape (&gamevp, 0x1202, objs[n].x, objs[n].y); }; return (0); };
int msg_bonus2 (int n, int msg, int z) { // spinach--invincibility switch (msg) { case msg_update: objs[n].y += objs[n].yd; if (objs[n].y > scrn_y) killobj(n); return (1); case msg_draw: drawshape (&gamevp, 0x1200, objs[n].x, objs[n].y); }; return (0); };
int16_t msg_explode2 (int16_t n, int16_t msg, int16_t z) { int16_t sh; switch (msg) { case msg_update: if (objs[n].count++ >= 14) killobj (n); return (1); case msg_draw: sh = 0xf0a + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int msg_explode3 (int n, int msg, int z) { int sh; switch (msg) { case msg_update: if (objs[n].count++ >= 12) killobj (n); return (1); case msg_draw: sh = 0xf00 + 21 + objs[n].count/4; drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int msg_explode5 (int n, int msg, int z) { int sh; switch (msg) { case msg_update: if (objs[n].count2++ >= 20) killobj (n); return (1); case msg_draw: sh = 0xd04 + random(5); drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int msg_jump2 (int n, int msg, int z) { int sh; switch (msg) { case msg_update: if (objs[n].count++ >= 13) killobj (n); return (1); case msg_draw: sh = 0x1800 + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int msg_splash (int n, int msg, int z) { int sh=kindtable[obj_splash]*256+15; objtype *pobj; pobj=&(objs[n]); switch (msg) { case msg_update: if (++pobj->counter>=28) killobj (n); break; case msg_draw: drawshape (&gamevp,sh+pobj->counter/2,pobj->x,pobj->y); break; case msg_touch: if (z==0) hitplayer (n,0); }; return (0); };
int msg_max (int n, int msg, int z) { // max shields int sh; switch (msg) { case msg_update: objs[n].count = (objs[n].count + 1)&7; objs[n].y += objs[n].yd; if (objs[n].y > scrn_y) killobj(n); return (1); case msg_draw: sh = 0x160f + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int msg_bonus1 (int n, int msg, int z) { // pulsar--gives missiles int sh; switch (msg) { case msg_update: objs[n].count = (objs[n].count + 1)&7; objs[n].y += objs[n].yd; if (objs[n].y > scrn_y) killobj(n); return (1); case msg_draw: sh = 0x1600 + 80 + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int msg_ejected (int n, int msg, int z) { int sh; switch (msg) { case msg_update: objs[n].count = (objs[n].count + 1)&3; if (++objs[n].count2 >= 20) killobj (n); if (++objs[n].yd > 12) objs[n].yd = 12; move_obj (n,objs[n].x+objs[n].xd,objs[n].y+objs[n].yd); return (1); case msg_draw: sh = 0x1403 + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int msg_spinner (int n, int msg, int z) { // enemy bullet int sh, dx, dy; switch (msg) { case msg_update: objs[n].count = (objs[n].count + 1)&7; seekplayer (n, &dx, &dy); objs[n].x += dx*2; objs[n].y += objs[n].yd; objs[n].yd++; if (objs[n].y >= scrn_y) killobj (n); return (1); case msg_draw: sh = 0x503 + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); break; }; return (0); };
int msg_shield (int n, int msg, int z) { int sh; switch (msg) { case msg_update: if (objs[n].count2 >= 240) objs[n].count = (objs[n].count + 1)&3; move_obj (n, objs[0].x-2, objs[0].y-2); if (++objs[n].count2==340) killobj (n); return (1); case msg_draw: sh = 0x804 + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); break; case msg_touch: switch (objs[z].kind) { case obj_enemy1: case obj_enemy2: case obj_enemy3: case obj_enemy4: case obj_enemy5: case obj_enemy6: case obj_enemy7: case obj_enemy8: case obj_enemy9: case obj_enemya: case obj_enemyb: case obj_enemyc: case obj_enemyd: case obj_enemye: case obj_enemyf: case obj_enemyg: case obj_enemyh: case obj_enemyi: case obj_enemyj: case obj_enemyk: snd_play (1,7); if (objs[z].count3 < 1) { killobj (z); } else { objs[z].xd = -objs[z].xd; objs[z].yd = -objs[z].yd; }; break; case obj_bullet2: case obj_spinner: case obj_laser: snd_play (1,7); explosion (objs[z].x, objs[z].y, 5); killobj (z); }; }; return (0); };
int msg_jump1 (int n, int msg, int z) { int sh; switch (msg) { case msg_update: if (objs[n].count++ >= 28) { killobj (n); objs[0].y = scrn_y - 22; objs[0].count2 = 0; text (k_msg2, 1); }; return (1); case msg_draw: sh = 0x1800 + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int msg_triple (int n, int msg, int z) { // triple fire power int sh; switch (msg) { case msg_update: objs[n].count = (objs[n].count + 1)&7; if (objs[n].x > scrn_x) killobj(n); if (objs[n].count2++ == 20) { objs[n].yd = -objs[n].yd; objs[n].count2 = 0; }; objs[n].x += objs[n].xd; objs[n].y += objs[n].yd; return (1); case msg_draw: sh = 0xd00 + objs[n].count/2; drawshape (&gamevp, sh, objs[n].x, objs[n].y); }; return (0); };
int msg_score (int n, int msg, int z) { int c,sh; char score[12]; objtype *pobj; pobj=&(objs[n]); switch (msg) { case msg_update: if ((--pobj->counter<0)||(!onscreen(n))) killobj (n); else { pobj->x+=pobj->xd; pobj->y+=pobj->yd; pobj->yd--; return (1); }; break; case msg_draw: fontcolor (&gamevp,2+(pobj->counter&3),-1); itoa (pobj->state,score,10); for (c=0;score[c];c++) { drawshape (&gamevp,0x0300+score[c]-48,pobj->x+4*c,pobj->y); }; }; return (0); };
void wprint (vptype *vp, int16_t x, int16_t y, int16_t font, char *text) { int16_t fontx; int16_t c; if ((curhi!=vp->vphi)||(curback!=vp->vpback)) { fontcolor (vp, vp->vphi, vp->vpback); }; switch (font) { case 1: fontx=8; break; // 8x8 case 2: fontx=6; break; // 6x6 default: fontx=0; }; if (fontx!=0) { for (c=0; c<strlen(text); c++) { drawshape (vp,(font<<8)+(text[c]&0x7f),x+fontx*c,y); // (font<<8) left shift twice = font*8*8 }; }; };
void FXGLCircle::draw(FXGLViewer* viewer) { #ifdef HAVE_GL_H // If we need lighting, set that up otherwise render directly if((options & STYLE_SURFACE) && !viewer->doesTurbo()) FXGLShape::draw(viewer); else{ glPushAttrib(GL_CURRENT_BIT|GL_POINT_BIT|GL_LINE_BIT); glPushMatrix(); // Object position glTranslatef(position[0],position[1],position[2]); drawshape(viewer); // Restore attributes and matrix glPopMatrix(); glPopAttrib(); } #endif }
int msg_pushblock (int n, int msg, int z) { switch (msg) { case msg_update: if (cando (n,objs[n].x,objs[n].y+1, f_playerthru|f_notstair)==(f_playerthru|f_notstair)) { if ((objs[n].yd+=2)>12) objs[n].yd=12; if (trymove(n,objs[n].x+objs[n].xd,objs[n].y+objs[n].yd)!=1) { trymove(n,objs[n].x,((objs[n].y+objs[n].yd-1)&0xfff0)+ (16-kindyl[obj_pushblock])); objs[n].xd=0; }; }; break; case msg_draw: // drawshape (&gamevp,0x1f38,objs[n].x,objs[n].y); break; drawshape (&gamevp,info[stldr1].sh,objs[n].x,objs[n].y); break; case msg_touch: if (z==0) { if (cando (n,objs[n].x+objs[z].xd*8,objs[n].y,f_playerthru)) { objs [n].x+=objs[z].xd*8; }; }; }; return(1); };
void wait (void) { int x, y; int c,q; clrpal (); setpagemode (1); for (x=0; x<20; x++) { for (y=0; y<12; y++) { drawshape (&mainvp,0x7501+x+y*20,x*16,y*16); }; }; fontcolor (&mainvp,71,-1); wprint (&mainvp,168,8,1,"THE SECRET CHAMBER"); // fontcolor (&mainvp,7,-1); // wprint (&mainvp,79,194,2,"-Press Any Key to Continue-"); pageflip (); setpagemode (0); fadein (); do { gamecount++; checkctrl0(0); for (c=64; c<80; c++) { q=64+((c+gamecount)&15); setcolor (c,vgapal[q*3+0],vgapal[q*3+1],vgapal[q*3+2]); }; } while ((key==0)&&(fire1==0)&&(fire2==0)&&(dx1==0)&&(dy1==0)); };
void design (void) { int updflag=0; int dx,dy,tempx,n; int lastcell=1; int tempint; int drawmode=0; char tempstr[32]; char tempfname[32]; char tempstr2[12]; char tempstr3[32]; int new_col=0; int bc_x=0,bc_y=0,bc_w=0,bc_h=0; // Block copy x,y and width,height int tx,ty; disy=0; designflag=1; gamecount=0; tempstr[0]='\0'; tempfname[0]='\0'; setorigin(); dx=objs[0].x/16; dy=objs[0].y/16; drawboard(); fontcolor (&statvp,1,0); clearvp (&statvp); do { if (drawmode) { setboard (dx,dy,lastcell); drawcell (dx,dy); updflag=1; } fontcolor (&statvp,3,0); // memory usage wprint (&statvp,248,1,2," "); ultoa (coreleft(),tempstr3,10); wprint (&statvp,290-(1+strlen(tempstr3)*6),1,2,tempstr3); tempstr3[0]='\0'; fontcolor (&statvp,1,0); wprint (&statvp,248,21,2, "# objs: "); fontcolor (&statvp,3,0); wprint (&statvp,296,21,2,itoa(numobjs,tempstr2,10)); drawshape (&gamevp,0x0100,dx*16+4,dy*16+4); do { checkctrl(0); } while ((dx1==0)&&(dy1==0)&&(key==0)&&(updflag==0)); updflag=0; modboard(dx,dy); upd_objs(0); refresh(0); purgeobjs(); if ((dx1!=0)||(dy1!=0)) { dx+=dx1*(1+fire1*(scrnxs/2-1)); dy+=dy1*(1+fire1*(scrnys/2-1)); if (dx<0) dx=0; if (dx>=boardxs) dx=boardxs-1; if (dy<0) dy=0; if (dy>=boardys) dy=boardys-1; if ((dx*16)<gamevp.vpox) { gamevp.vpox-=scrnxs*8; if (gamevp.vpox<0) gamevp.vpox=0; drawboard(); }; if ((dx*16)>=(gamevp.vpox+16*scrnxs-16)) { gamevp.vpox+=scrnxs*8; if (gamevp.vpox>=(16*(boardxs-scrnxs)+8)) gamevp.vpox=16*(boardxs-scrnxs)+8; drawboard(); }; if ((16*dy)<gamevp.vpoy) { gamevp.vpoy-=scrnys*8; if (gamevp.vpoy<0) gamevp.vpoy=0; drawboard(); }; if ((16*dy)>=(gamevp.vpoy+16*(scrnys-1))) { gamevp.vpoy+=scrnys*8; if (gamevp.vpoy>=(16*(boardys-scrnys+1))) gamevp.vpoy=(boardys-scrnys+1)*16; drawboard(); }; }; switch (toupper(key)) { case k_f1: // Mark top left corner of block bc_x=dx; bc_y=dy; break; case k_f2: // Mark bottom right corner of block and copy // block of tile numbers into temp array bc_array if(dx<bc_x) break; // 0-width or negative width rectangle (can't do that) if(dy<bc_y) break; // 0-height or negative height rectangle (can't do that) bc_w=(dx-bc_x)+1; bc_h=(dy-bc_y)+1; if((bc_w>normxs)||(bc_h>normys)) { // Too big!! bc_w=0; bc_h=0; break; }; for(ty=0; ty<bc_h; ty++) { for(tx=0; tx<bc_w; tx++) { bc_array[(ty*bc_w)+tx]=board(bc_x+tx,bc_y+ty); }; }; break; case k_f3: for(ty=0; ty<bc_h; ty++) { for(tx=0; tx<bc_w; tx++) { setboard(dx+tx, dy+ty, bc_array[(ty*bc_w)+tx]); }; }; updflag=1; break; case k_f4: do { upd_colors (); gamecount++; checkctrl0(0); } while (key==0); break; case enter: clearvp (&statvp); wprint (&statvp,2,1,1,"Put:"); fontcolor (&statvp,6,0); winput (&statvp,2,11,1,tempstr,16); strupr (tempstr); for (tempint=0; tempint<numinfotypes; tempint++) { if (strcmp (tempstr,info[tempint].na)==0) { lastcell=tempint; setboard(dx,dy,tempint); shm_want[(info[tempint].sh>>8)&0x3f]=1; shm_do(); break; }; }; updflag=1; break; case 9: drawmode=!drawmode; break; // tab case 'K': lastcell=board(dx,dy); break; case ' ': setboard(dx,dy,lastcell); updflag=1; break; case 'I': pl.score=1000; printhi (1); pl.score=0; break; case 'V': if (pl.numinv==0) addinv (inv_hero); else { pl.numinv=0; init_inv(); }; pl.score=0; pl.level=0; break; case 'H': tempint=board(dx,dy); tempx=dx; while (board(tempx,dy)==tempint) { setboard(tempx,dy,lastcell); drawcell (tempx,dy); tempx--; }; tempx=dx+1; while (board(tempx,dy)==tempint) { setboard(tempx,dy,lastcell); drawcell (tempx,dy); tempx++; }; break; case 'O': updflag=objdesign(dx,dy); break; // Object Mgmt case 'U': for (n=0; n<numobjs; n++) { // if (((kindflags[objs[n].objkind]&f_inside)==0)&& // (objs[n].inside!=NULL)) { // objs[n].inside=NULL; // sound(240); // delay(500); // nosound(); // }; setobjsize (n); }; break; case 'Z': infname ("Clear?",tempfname); if (toupper(tempfname[0])=='Y') { init_brd(); init_objs(); drawboard(); }; break; case 'L': infname ("Load:",tempfname); if (tempfname[0]!='\0') { loadboard (tempfname); setorigin(); dx=objs[0].x/16; dy=objs[0].y/16; drawboard(); }; break; case 'Y': // Disalign Y clearvp (&statvp); wprint (&statvp,2,1,1,"Dis Y:"); itoa (disy,tempstr,10); winput (&statvp,2,11,1,tempstr,16); disy=atoi (tempstr); strupr (tempstr); break; case 'N': infname ("New board?",tempfname); if (toupper (tempfname[0])=='Y') { zapobjs(); init_brd(); }; break; case 'S': infname ("Save:",tempfname); if (tempfname[0]!='\0') saveboard (tempfname); break; case 'C': clearvp (&statvp); wprint (&statvp,2,1,1,"New Color:"); fontcolor (&statvp,6,0); itoa (new_col,tempstr,10); winput (&statvp,2,11,1,tempstr,16); new_col=atoi (tempstr); switch (new_col) { case 0: setcolor (250,0,0,0); setcolor (251,0,0,0); break; // reset all case 1: setcolor (251,0,0,0); break; // reset #251 case 2: setcolor (250,0,0,32); // dk. blue sky setcolor (251,0,0,32); break; case 3: // lt. blue sky setcolor (176,8,16,25); setcolor (177,8,20,29); setcolor (178,12,24,33); setcolor (179,16,28,41); setcolor (180,20,32,45); setcolor (181,24,40,49); setcolor (182,28,44,57); setcolor (183,36,48,60); setcolor (250,36,48,60); setcolor (251,36,48,60); break; case 4: // yellow sky setcolor (176,32,0,0); setcolor (177,40,0,0); setcolor (178,52,0,0); setcolor (179,60,0,0); setcolor (180,60,28,0); setcolor (181,60,40,0); setcolor (182,60,52,0); setcolor (183,60,60,0); setcolor (250,60,60,0); setcolor (251,60,60,0); break; case 5: // emerald sky setcolor (176,0,12,12); setcolor (177,0,18,17); setcolor (178,0,25,23); setcolor (179,0,32,27); setcolor (180,0,39,32); setcolor (181,0,46,35); setcolor (182,0,53,38); setcolor (183,0,60,40); setcolor (250,0,60,40); setcolor (251,0,60,40); break; case 6: setcolor (250,32,32,24); // olive green setcolor (251,32,32,24); break; case 7: // violet sky setcolor (176,13,5,22); setcolor (177,18,8,27); setcolor (178,23,13,33); setcolor (179,29,19,39); setcolor (180,35,25,45); setcolor (181,42,32,51); setcolor (182,49,40,57); setcolor (183,57,50,63); setcolor (250,57,50,63); setcolor (251,57,50,63); break; case 8: setcolor (250,23,23,23); // factory grey setcolor (251,23,23,23); break; case 9: setcolor (250,12,23,63); // royal blue setcolor (251,12,23,63); break; case 10: setcolor (250,20,20,23); // factory grey v3 setcolor (251,20,20,23); break; }; }; } while (key!=escape);