/**************************************************************************** PARAMETERS: dc - Display dc trans - Turn on/off transparent blitting REMARKS: Demo showing how to use memory dc's to store sprites and to use blit them from the memory dc to the display dc. ****************************************************************************/ ibool systemBlit( MGLDC *dc, ibool trans) { color_t transparent; palette_t pal[256]; int oldCheckId; MGLDC *memdc; /* Display title message at the top of the window. */ if (trans) mainWindow(dc,"System Memory 8bpp Transparent Blit Demo"); else mainWindow(dc,"System Memory 8bpp Blit Demo"); statusLine("Press any key to continue, ESC to Abort"); /* Create a memory device context */ if ((memdc = MGL_createMemoryDC(bmpWidth,bmpHeight,bmpDepth,&bmpPF)) == NULL) MGL_fatalError(MGL_errorMsg(MGL_result())); /* Load a bitmap into the memory device context. The palette gets * loaded into the memory device context as well. */ if (!MGL_loadBitmapIntoDC(memdc,IMAGE_NAME,0,0,true)) MGL_fatalError(MGL_errorMsg(MGL_result())); /* Set the display device context with the palette from the * memory device context. */ MGL_getPalette(memdc,pal,MGL_getPaletteSize(memdc),0); MGL_setPalette(dc,pal,MGL_getPaletteSize(memdc),0); MGL_realizePalette(dc,MGL_getPaletteSize(memdc),0,true); oldCheckId = MGL_checkIdentityPalette(false); /* Get transparent color from pixel (0,0) */ MGL_makeCurrentDC(memdc); transparent = MGL_realColor(dc,MGL_getPixelCoord(0,0)); MGL_makeCurrentDC(dc); /* Copy image from image in memory to the screen. */ while (!checkEvent()) { if (trans) MGL_srcTransBltCoord(dc,memdc,0,0,bmpWidth,bmpHeight,MGL_random(maxx-bmpWidth),MGL_random(maxy-bmpHeight),transparent,MGL_REPLACE_MODE); else MGL_bitBltCoord(dc,memdc,0,0,bmpWidth,bmpHeight,MGL_random(maxx-bmpWidth),MGL_random(maxy-bmpHeight),MGL_REPLACE_MODE); } /* Remove all device contexts from memory. */ MGL_destroyDC(memdc); MGL_checkIdentityPalette(oldCheckId); MGL_setDefaultPalette(dc); return pause(); }
ibool polyDemo(MGLDC *dc) /**************************************************************************** * * Function: polyDemo * Parameters: dc - Device context * * Description: Display a random pattern of polygons on the screen with * random fill styles. * ****************************************************************************/ { int i,maxx,maxy,val; fxpoint_t poly[MAXPTS]; /* Space to hold polygon data */ mainWindow(dc,"MGL_fillPolygon Demonstration"); statusLine("Press any key to continue, ESC to Abort"); maxx = MGL_maxx(); maxy = MGL_maxy(); while (!checkEvent()) { /* Define a random polygon */ for (i = 0; i < MAXPTS; i++) { poly[i].x = MGL_randoml(MGL_TOFIX(maxx)); poly[i].y = MGL_randoml(MGL_TOFIX(maxy)); } MGL_setColor(randomColor()); MGL_setBackColor(randomColor()); if ((val = MGL_random(3)) == 0) { MGL_setPenStyle(MGL_BITMAP_TRANSPARENT); MGL_setPenBitmapPattern(0,&bitpat[MGL_random(NUMPATS)+1]); MGL_usePenBitmapPattern(0); } else if (val == 1) { MGL_setPenStyle(MGL_BITMAP_OPAQUE); MGL_setPenBitmapPattern(0,&bitpat[MGL_random(NUMPATS)+1]); MGL_usePenBitmapPattern(0); } else { MGL_setPenStyle(MGL_BITMAP_SOLID); } MGL_fillPolygonFX(MAXPTS,poly,sizeof(fxpoint_t),0,0); } defaultAttributes(dc); return pause(); }
/**************************************************************************** PARAMETERS: dc - Display dc trans - Turn on/off transparent blitting REMARKS: Demo showing how to use offscreen dc's to store sprites and to use hardware acceleration to blt them from the offscreen dc to the display dc. ****************************************************************************/ ibool offscreenBlit( MGLDC *dc, ibool trans) { MGLDC *offdc; color_t transparent; palette_t pal[256]; /* Display title message at the top of the window. */ if (trans) mainWindow(dc,"Offscreen Memory Accelerated Transparent Blit Demo"); else mainWindow(dc,"Offscreen Memory Accelerated Blit Demo"); statusLine("Press any key to continue, ESC to Abort"); if ((offdc = MGL_createOffscreenDC(dc,bmpWidth,bmpHeight)) == NULL) { gprintf("Hardware accelerated blit not available."); } else { /* Load a bitmap into the offscreen device context */ if (!MGL_loadBitmapIntoDC(offdc,IMAGE_NAME,0,0,true)) MGL_fatalError(MGL_errorMsg(MGL_result())); /* Set the display device context with the palette from the * offscreen device context. */ if (MGL_getBitsPerPixel(dc) <= 8) { MGL_getPalette(offdc,pal,MGL_getPaletteSize(offdc),0); MGL_setPalette(dc,pal,MGL_getPaletteSize(offdc),0); MGL_realizePalette(dc,MGL_getPaletteSize(offdc),0,true); } /* Get transparent color from pixel (0,0) */ MGL_makeCurrentDC(offdc); transparent = MGL_getPixelCoord(0,0); MGL_makeCurrentDC(dc); /* Copy image from offscreen video memory to the screen. */ while (!checkEvent()) { if (trans) MGL_srcTransBltCoord(dc,offdc,0,0,bmpWidth,bmpHeight,MGL_random(maxx-bmpWidth),MGL_random(maxy-bmpHeight),transparent,MGL_REPLACE_MODE); else MGL_bitBltCoord(dc,offdc,0,0,bmpWidth,bmpHeight,MGL_random(maxx-bmpWidth),MGL_random(maxy-bmpHeight),MGL_REPLACE_MODE); } } /* Remove all device contexts from memory. */ MGL_destroyDC(offdc); return pause(); }
void Particle::GoRandom(byte type,int x,int y,int z,byte force) { this->type=type; size=2; if(force==0) return; this->x=x+MGL_randoml(32<<FIXSHIFT)-(16<<FIXSHIFT); this->y=y+MGL_randoml(32<<FIXSHIFT)-(16<<FIXSHIFT); this->z=z; this->dx=(MGL_random(force)-force/2)<<FIXSHIFT; this->dy=(MGL_random(force)-force/2)<<FIXSHIFT; this->dz=MGL_random(force*2)<<FIXSHIFT; this->life=MGL_random(force)+20; }
void Particle::Go(byte type,int x,int y,int z,byte angle,byte force) { byte fforce; if(force==0) return; this->type=type; size=2; fforce=force/4; if(fforce==0) fforce=1; this->x=x+MGL_randoml(32<<FIXSHIFT)-(16<<FIXSHIFT); this->y=y+MGL_randoml(32<<FIXSHIFT)-(16<<FIXSHIFT); this->z=z; this->dx=Cosine(angle)*MGL_random(fforce); this->dy=Sine(angle)*MGL_random(fforce); this->dz=MGL_random(fforce*2)<<FIXSHIFT; this->life=MGL_random(force)+10; }
void PlayerThrowHammer(Guy *me) { if (opt.playAs == PLAYAS_BOUAPHA) { HammerLaunch(me->x, me->y, me->facing, player.hammers, player.hammerFlags); } else if (opt.playAs == PLAYAS_LUNATIC) { MakeSound(SND_BALLLIGHTNING, me->x, me->y, SND_CUTOFF, 600); FireBullet(me->x, me->y, me->facing, BLT_BALLLIGHTNING, 1); if (player.hammerFlags & HMR_REVERSE) FireBullet(me->x, me->y, (byte) MGL_random(8), BLT_BALLLIGHTNING, 1); } else { HappyLaunch(me->x, me->y, me->facing, player.hammers, player.hammerFlags); } player.reload = player.hamSpeed + 2; }
void CDPlayerUpdate(byte mode) { isPlaying = 0; if (stream != NULL) isPlaying = logg_update_stream(stream); bool modeChanged = currentMode != mode; currentMode = mode; if (!isPlaying || modeChanged) { switch (currentMode) { case CD_LOOPTRACK: CDPlay(trackNum); break; case CD_INTROLOOP: CDPlay(trackNum + 1); currentMode = CD_LOOPTRACK; break; case CD_RANDOM: CDPlay(3 + MGL_random(15)); break; case CD_NORMAL: if (!isPlaying) { int newTrack = trackNum + 1; if (newTrack > 18) newTrack = 3; CDPlay(newTrack); } break; case CD_OFF: default: if (isPlaying) { CDStop(); } break; } } }
void PlayerFireWeapon(Guy *me) { byte c; if (player.life == 0) return; // no shooting when you're dead switch (player.weapon) { case WPN_MISSILES: if (player.ammo) { FireBullet(me->x, me->y, me->facing, BLT_MISSILE, 1); player.ammo--; } player.wpnReload = 2; break; case WPN_BOMBS: if (player.ammo) { FireBullet(me->x, me->y, me->facing, BLT_BOMB, 1); player.ammo--; } player.wpnReload = 15; break; case WPN_AK8087: if (player.ammo) { FireBullet(me->x, me->y, me->facing, BLT_LASER, 1); player.ammo--; } me->z += FIXAMT * MGL_random(4); me->dx += FIXAMT / 2 - MGL_random(65535); me->dy += FIXAMT / 2 - MGL_random(65535); c = GetControls(); if (c & CONTROL_B2) // fire is held { player.wpnReload = 1; me->frmTimer = 0; } else { player.wpnReload = 5; } DoPlayerFacing(c, me); break; case WPN_FLAME: if (player.ammo) { FireBullet(me->x, me->y, me->facing, BLT_FLAME, 1); player.ammo--; } c = GetControls(); if (c & CONTROL_B2) // fire is held { player.wpnReload = 1; me->frmTimer = 0; } else player.wpnReload = 5; DoPlayerFacing(c, me); break; case WPN_BIGAXE: if (player.ammo) { FireBullet(me->x, me->y, me->facing, BLT_BIGAXE, 1); MakeSound(SND_BOMBTHROW, me->x, me->y, SND_CUTOFF, 1200); player.ammo--; } player.wpnReload = 10; break; case WPN_LIGHTNING: if (player.ammo) { // fire lightning FireBullet(me->x, me->y, me->facing, BLT_LIGHTNING, 1); player.ammo--; } c = GetControls(); if (c & CONTROL_B2) // fire is held { player.wpnReload = 1; me->frmTimer = 0; } else { player.wpnReload = 5; } DoPlayerFacing(c, me); break; case WPN_SPEAR: if (player.ammo) { MakeSound(SND_BOMBTHROW, me->x, me->y, SND_CUTOFF, 1200); FireBullet(me->x, me->y, me->facing, BLT_SPEAR, 1); player.ammo--; } player.wpnReload = 5; break; case WPN_MACHETE: if (player.ammo) { MakeSound(SND_SLASH, me->x, me->y, SND_CUTOFF, 1200); FireBullet(me->x + Cosine(me->facing * 32)*32, me->y + Sine(me->facing * 32)*32, me->facing, BLT_SLASH, 1); player.ammo--; } player.wpnReload = 2; break; case WPN_MINES: if (player.ammo) { MakeSound(SND_MINELAY, me->x, me->y, SND_CUTOFF, 1200); FireBullet(me->x - Cosine(me->facing * 32)*32, me->y - Sine(me->facing * 32)*32, me->facing, BLT_MINE, 1); player.ammo--; } player.wpnReload = 15; break; case WPN_TURRET: if (player.ammo) { Guy *g; g = AddGuy(me->x + Cosine(me->facing * 32)*32, me->y + Sine(me->facing * 32)*32, FIXAMT * 10, MONS_GOODTURRET); if (g == NULL || !g->CanWalk(g->x, g->y, GameCurrentMap(), &curWorld)) { MakeSound(SND_TURRETBZZT, me->x, me->y, SND_CUTOFF, 1200); if (g) g->type = MONS_NONE; } else { MakeSound(SND_MINELAY, me->x, me->y, SND_CUTOFF, 1200); player.ammo--; } player.wpnReload = 15; } break; case WPN_MINDCONTROL: if (player.ammo) { MakeSound(SND_MINDWIPE, me->x, me->y, SND_CUTOFF, 1200); FireBullet(me->x + Cosine(me->facing * 32)*32, me->y + Sine(me->facing * 32)*32, me->facing, BLT_MINDWIPE, 1); player.ammo--; player.wpnReload = 15; } break; case WPN_REFLECTOR: if (player.ammo) { MakeSound(SND_LIGHTSON, me->x, me->y, SND_CUTOFF, 1200); FireBullet(me->x, me->y, me->facing, BLT_REFLECT, 1); player.ammo--; c = GetControls(); if (c & CONTROL_B2) // fire is held { player.wpnReload = 0; me->frmTimer = 0; } else { player.wpnReload = 10; } } break; case WPN_JETPACK: if (player.ammo) { player.jetting = 5; player.ammo--; player.wpnReload = 3; } break; case WPN_SWAPGUN: if (player.ammo) { MakeSound(SND_LIGHTSON, me->x, me->y, SND_CUTOFF, 1200); FireBullet(me->x, me->y, me->facing, BLT_SWAP, 1); player.ammo--; player.wpnReload = 10; } break; } if (!player.ammo) player.weapon = 0; }
byte PlayerGetItem(byte itm, int x, int y) { int cx, cy; GetCamera(&cx, &cy); cx <<= FIXSHIFT; cy <<= FIXSHIFT; // won't pick up other weapons when in power armor if (player.weapon == WPN_PWRARMOR && (itm == ITM_MISSILES || itm == ITM_AK8087 || itm == ITM_FLAME || itm == ITM_BOMBS || itm == ITM_BIGAXE || itm == ITM_SPEAR || itm == ITM_MACHETE || itm == ITM_MINES || itm == ITM_LIGHTNING || itm == ITM_TURRETWPN || itm == ITM_JETPACK || itm == ITM_MINDCONTROL || itm == ITM_REFLECTOR || itm == ITM_SWAPGUN)) return 1; switch (itm) { case ITM_HAMMERUP: if (player.hammers < 5) player.hammers++; MakeNormalSound(SND_HAMMERUP); NewMessage("HAMMER UP!", 75, 0); player.score += 150; return 0; break; case ITM_PANTS: if (player.hamSpeed > 0) player.hamSpeed -= 4; NewMessage("PANTS OF POWER!", 75, 0); MakeNormalSound(SND_PANTS); player.score += 100; return 0; break; case ITM_REVERSE: player.hammerFlags |= HMR_REVERSE; NewMessage("REVERSE HAMMER!", 75, 0); MakeNormalSound(SND_REVERSE); player.score += 100; return 0; break; case ITM_REFLECT: player.hammerFlags |= HMR_REFLECT; NewMessage("REFLECT HAMMER!", 75, 0); MakeNormalSound(SND_REFLECT); player.score += 100; return 0; break; case ITM_MISSILES: if (player.weapon == WPN_MISSILES && player.ammo == 20) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("MISSILE PACK!", 75, 0); player.weapon = WPN_MISSILES; player.ammo = 20; player.score += 50; return 0; break; case ITM_FLAME: if (player.weapon == WPN_FLAME && player.ammo == 50) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("FLAMETHROWER!", 75, 0); player.weapon = WPN_FLAME; player.ammo = 50; player.score += 50; return 0; break; case ITM_BOMBS: if (player.weapon == WPN_BOMBS && player.ammo == 5) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("CHERRY BOMBS!", 75, 0); player.weapon = WPN_BOMBS; player.ammo = 5; player.score += 50; return 0; break; case ITM_AK8087: if (player.weapon == WPN_AK8087 && player.ammo == 99) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("AK-8087!", 75, 0); player.weapon = WPN_AK8087; player.ammo = 99; player.score += 50; return 0; break; case ITM_TAKEOUT: if (player.life == 128) return 1; // don't need the food MakeNormalSound(SND_FOOD); goodguy->poison = 0; switch (MGL_random(8)) { case 0: NewMessage("Just fried rice", 75, 0); PlayerHeal(5); break; case 1: NewMessage("Mmm, Kung Pao!", 75, 0); PlayerHeal(25); break; case 2: NewMessage("Szechwan Shredded Pork!!", 75, 0); PlayerHeal(50); break; case 3: NewMessage("Moo Shi Beef!", 75, 0); PlayerHeal(25); break; case 4: NewMessage("Ick, mostly veggies", 75, 0); PlayerHeal(1); break; case 5: NewMessage("Hmm, tastes kind of citrusy", 75, 0); PlayerHeal(15); break; case 6: NewMessage("Joy! Wontons!", 75, 0); PlayerHeal(20); break; case 7: NewMessage("GeneralTsao has outdone himself", 75, 0); PlayerHeal(40); break; } player.score += 50; return 0; break; case ITM_SHIELD: MakeNormalSound(SND_SHIELD); player.shield = 240; player.score += 50; NewMessage("Energy Barrier!", 30, 0); return 0; break; case ITM_BRAIN: MakeNormalSound(SND_GETBRAIN); player.brains++; if (player.brains >= TotalBrains()) { player.brains = TotalBrains(); if (opt.playAs == PLAYAS_BOUAPHA) MakeNormalSound(SND_KOOLKAT); else if (opt.playAs == PLAYAS_LUNATIC) MakeNormalSound(SND_DRLLAUGH); else MakeNormalSound(SND_HAPPYDIE); playerGlow = 127; } player.score += 25; return 0; break; case ITM_KEY: if (player.keys[0] < 3) { player.keys[0]++; MakeNormalSound(SND_GETKEY); return 0; } else return 1; // don't pick it up break; case ITM_KEYR: MakeNormalSound(SND_GETKEY); player.keys[1] = 1; return 0; break; case ITM_KEYG: MakeNormalSound(SND_GETKEY); player.keys[2] = 1; return 0; break; case ITM_KEYB: MakeNormalSound(SND_GETKEY); player.keys[3] = 1; return 0; break; case ITM_KEYCH1: MakeNormalSound(SND_GETKEYCHAIN); player.keychain[player.worldNum][0] = 1; KeyChainAllCheck(); player.score += 50000; player.prevScore += 50000; NewMessage("Cool! A pumpkin keychain!", 75, 0); return 0; break; case ITM_KEYCH2: MakeNormalSound(SND_GETKEYCHAIN); player.keychain[player.worldNum][1] = 1; KeyChainAllCheck(); player.score += 50000; player.prevScore += 50000; NewMessage("Cool! A hammer keychain!", 75, 0); return 0; break; case ITM_KEYCH3: MakeNormalSound(SND_GETKEYCHAIN); player.keychain[player.worldNum][2] = 1; KeyChainAllCheck(); player.score += 50000; player.prevScore += 50000; NewMessage("Cool! A rocket keychain!", 75, 0); return 0; break; case ITM_KEYCH4: MakeNormalSound(SND_GETKEYCHAIN); player.keychain[player.worldNum][3] = 1; KeyChainAllCheck(); player.score += 50000; player.prevScore += 50000; NewMessage("Cool! A squash keychain!", 75, 0); return 0; break; case ITM_LOONYKEY: MakeNormalSound(SND_LOONYKEY); player.lunacyKey[player.worldNum] = 1; player.score += 100000; player.prevScore += 100000; return 0; break; #ifdef EXPANDO case ITM_PWRARMOR: MakeNormalSound(SND_ROBOBOUAPHAON); NewMessage("POWER ARMOR!!", 75, 0); player.weapon = WPN_PWRARMOR; player.ammo = 1000; player.score += 150; player.shield = 0; goodguy->seq = ANIM_A2; goodguy->frm = 0; goodguy->frmTimer = 0; goodguy->frmAdvance = 64; goodguy->action = ACTION_BUSY; return 0; break; case ITM_BIGAXE: if (player.weapon == WPN_BIGAXE && player.ammo == 15) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("BIG AXE!", 75, 0); player.weapon = WPN_BIGAXE; player.ammo = 15; player.score += 50; return 0; break; case ITM_LIGHTNING: if (player.weapon == WPN_LIGHTNING && player.ammo == 40) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("LIGHTNING ROD!", 75, 0); player.weapon = WPN_LIGHTNING; player.ammo = 40; player.score += 50; return 0; break; case ITM_SPEAR: if (player.weapon == WPN_SPEAR && player.ammo == 20) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("SPEARS!", 75, 0); player.weapon = WPN_SPEAR; player.ammo = 20; player.score += 50; return 0; break; case ITM_MACHETE: if (player.weapon == WPN_MACHETE && player.ammo == 30) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("MACHETE!", 75, 0); player.weapon = WPN_MACHETE; player.ammo = 30; player.score += 50; return 0; break; case ITM_MINES: if (player.weapon == WPN_MINES && player.ammo == 8) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("MINES!", 75, 0); player.weapon = WPN_MINES; player.ammo = 8; player.score += 50; return 0; break; case ITM_GARLIC: NewMessage("Fresh Garlic!", 75, 0); player.garlic = 255; return 0; break; case ITM_ORBITER: FireBullet(goodguy->x, goodguy->y, goodguy->facing, BLT_ORBITER, 1); NewMessage("ORBITER!", 75, 0); return 0; break; case ITM_ACCEL: MakeNormalSound(SND_SPEEDUP); NewMessage("PARTICLE ACCELERATOR!", 75, 0); player.speed = 255; return 0; break; case ITM_TURRETWPN: if (player.weapon == WPN_TURRET && player.ammo == 3) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("TURRETS!", 75, 0); player.weapon = WPN_TURRET; player.ammo = 3; player.score += 50; return 0; break; case ITM_MINDCONTROL: if (player.weapon == WPN_MINDCONTROL && player.ammo == 1) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("MIND CONTROL RAY!", 75, 0); player.weapon = WPN_MINDCONTROL; player.ammo = 1; player.score += 50; return 0; break; case ITM_REFLECTOR: if (player.weapon == WPN_REFLECTOR && player.ammo == 40) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("REFLECTOR SHIELD!", 75, 0); player.weapon = WPN_REFLECTOR; player.ammo = 40; player.score += 50; return 0; break; case ITM_INVIS: MakeNormalSound(SND_ROBOBOUAPHAON); NewMessage("THE CLOAK INVISIBLE!", 75, 0); player.score += 50; player.invisibility = 255; return 0; break; case ITM_JETPACK: if (player.weapon == WPN_JETPACK && player.ammo == 10) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("JETPACK!", 75, 0); player.weapon = WPN_JETPACK; player.ammo = 10; player.score += 50; return 0; break; case ITM_SWAPGUN: if (player.weapon == WPN_SWAPGUN && player.ammo == 3) // don't get it return 1; MakeNormalSound(SND_WEAPON); NewMessage("SWAPGUN!", 75, 0); player.weapon = WPN_SWAPGUN; player.ammo = 3; player.score += 50; return 0; break; case ITM_UNHAMMER: if (player.hammers > 0) { player.hammers--; player.score -= 150; } MakeNormalSound(SND_HAMMERDN); NewMessage("HAMMER DOWN!", 75, 0); return 0; break; case ITM_UNPANTS: if (player.hamSpeed < 16) { player.hamSpeed += 4; player.score -= 100; } NewMessage("PANTS OF SLOWNESS!", 75, 0); MakeNormalSound(SND_PANTSDN); return 0; break; case ITM_BADCHINESE: MakeNormalSound(SND_FOOD); goodguy->poison = 0; switch (MGL_random(6)) { case 0: NewMessage("Radioactive Energy!!", 75, 0); PlayerHeal(30); player.speed = 255; break; case 1: NewMessage("Szechwan Surprise!", 75, 0); PlayerHeal(128); break; case 2: NewMessage("Filling... with... RAGE!!", 75, 0); PlayerHeal(50); player.rage = 127 * 256; break; case 3: NewMessage("Toxic Mu Shu!", 75, 0); goodguy->poison = 255; break; case 4: NewMessage("Thermonuclear Heartburn!", 75, 0); goodguy->GetShot(0, 0, 50, GameCurrentMap(), &curWorld); break; case 5: NewMessage("Atomic Inviso-Power!", 75, 0); player.invisibility = 255; break; } player.score += 50; return 0; break; #endif } return 1; }
void Particle::Update(Map *map) { byte mapx,mapy; byte v; byte c1; char brt; if(life>0) { if(type!=PART_LIGHTNING) { dz-=FIXAMT; x+=dx; y+=dy; z+=dz; if(z<0) { z=0; dz=-dz/2; } } life--; switch(type) { case PART_COUNTESS: dz+=FIXAMT; // no gravity break; case PART_SMOKE: dz+=FIXAMT; // no gravity z+=FIXAMT; size=(6-life/8); dx+=MGL_random(65535)-FIXAMT/2; dy+=MGL_random(65535)-FIXAMT/2; Dampen(&dx,FIXAMT/8); Dampen(&dy,FIXAMT/8); break; case PART_STINKY: dz+=FIXAMT; // no gravity z+=FIXAMT+FIXAMT/2; size=((life/2)&3); if(size==3) size=1; dx+=MGL_random(65535)-FIXAMT/2; dy+=MGL_random(65535)-FIXAMT/2; Dampen(&dx,FIXAMT/8); Dampen(&dy,FIXAMT/8); break; case PART_BOOM: dz+=FIXAMT; z+=FIXAMT; size=7-life; break; case PART_HAMMER: v=life; if(v>31-8) v=31-8; color=128+v; if(life>20) size=2; else if(life<10) size=0; else size=1; break; case PART_GLASS: if(life>20) size=2; else if(life<10) size=0; else size=1; break; case PART_DIRT: v=life; if(v>31-8) v=31-8; color=64+v; if(life>20) size=2; else if(life<10) size=0; else size=1; break; case PART_SNOW2: v=life*2; if(v>31) v=31; if(v<31-16) v=31-16; color=v; if(life>20) size=2; else if(life<10) size=0; else size=1; break; case PART_WATER: v=life; if(v>31) v=31; if(v<8) v=8; color=96+v; if(life>20) size=2; else if(life<10) size=0; else size=1; break; case PART_SLIME: v=life; if(v>31-8) v=31-8; color=32+4+v; if(life>10) size=2; else if(life<5) size=0; else size=1; break; case PART_SNOW: dx+=MGL_random(65535)-FIXAMT/2; dy+=MGL_random(65535)-FIXAMT/2; Dampen(&dx,FIXAMT/8); Dampen(&dy,FIXAMT/8); dz+=FIXAMT-256; // not as much gravity as other things color=31; if(z==0) { dx=0; dy=0; dz=0; if(life<50) size=1; if(life<25) size=0; color=life/2; if(color<26) color=26; if(color>31) color=31; snowCount++; } else life++; // can't die while airborne break; case PART_LIGHTNING: // get dimmer with each frame color/=2; break; } if(x<0 || y<0 || x>=((map->width*TILE_WIDTH)<<FIXSHIFT) || y>=((map->height*TILE_HEIGHT)<<FIXSHIFT)) { life=0; return; } if(type==PART_SMOKE || type==PART_BOOM || type==PART_STINKY) { mapx=(x/TILE_WIDTH)>>FIXSHIFT; mapy=(y/TILE_HEIGHT)>>FIXSHIFT; color=64+map->map[mapx+mapy*map->width].templight; } else if(type==PART_LIGHTNING || type==PART_GLASS)
void DoRage(Guy *me) { int cx, cy, i; if (player.rageClock > 0) player.rageClock--; if (player.rageClock > 59) switch (rageWpn) { case WPN_NONE: switch (opt.playAs) { case PLAYAS_BOUAPHA: if (player.rageClock == (player.rageClock / 4)*4) HammerLaunch(me->x, me->y, me->facing, 5, HMR_REVERSE | HMR_REFLECT); break; case PLAYAS_LUNATIC: if (player.rageClock == (player.rageClock / 4)*4) { for (i = 0; i < 10; i++) FireBullet(me->x, me->y, (byte) MGL_random(8), BLT_BALLLIGHTNING, 1); } break; case PLAYAS_HAPPY: if (player.rageClock == (player.rageClock / 4)*4) HappyLaunch(me->x, me->y, me->facing, 5, HMR_REVERSE | HMR_REFLECT); break; } break; case WPN_MISSILES: FireBullet(me->x, me->y, (player.rageClock & 7), BLT_MISSILE, 1); break; case WPN_BOMBS: GetCamera(&cx, &cy); cx -= 320; cy -= 240; FireBullet((cx + MGL_random(640)) << FIXSHIFT, (cy + MGL_random(480)) << FIXSHIFT, 0, BLT_BOOM, 1); ShakeScreen(10); // make the screen shake! break; case WPN_AK8087: FireBullet(me->x, me->y, (byte) MGL_random(8), BLT_LASER, 1); FireBullet(me->x, me->y, (byte) MGL_random(8), BLT_LASER, 1); FireBullet(me->x, me->y, (byte) MGL_random(8), BLT_LASER, 1); break; case WPN_FLAME: GetCamera(&cx, &cy); cx -= 320; cy -= 240; for (i = 0; i < 3; i++) FireBullet((cx + MGL_random(640)) << FIXSHIFT, (cy + MGL_random(480)) << FIXSHIFT, (byte) MGL_random(8), BLT_FLAME, 1); break; case WPN_BIGAXE: if (player.rageClock == (player.rageClock / 5)*5) { MakeSound(SND_BOMBTHROW, me->x, me->y, SND_CUTOFF, 1200); FireBullet(me->x, me->y, me->facing, BLT_BIGAXE, 1); } break; case WPN_LIGHTNING: GetCamera(&cx, &cy); cx -= 320; cy -= 240; FireBullet((cx + MGL_random(640)) << FIXSHIFT, (cy + MGL_random(480)) << FIXSHIFT, (byte) MGL_random(8), BLT_LIGHTNING, 1); break; case WPN_SPEAR: if (player.rageClock == (player.rageClock / 3)*3) { MakeSound(SND_BOMBTHROW, me->x, me->y, SND_CUTOFF, 1200); FireBullet(me->x, me->y, (me->facing + 7)&7, BLT_SPEAR, 1); FireBullet(me->x, me->y, me->facing, BLT_SPEAR, 1); FireBullet(me->x, me->y, (me->facing + 1)&7, BLT_SPEAR, 1); } break; case WPN_MACHETE: GetCamera(&cx, &cy); cx -= 320; cy -= 240; for (i = 0; i < 10; i++) FireBullet((cx + MGL_random(640)) << FIXSHIFT, (cy + MGL_random(480)) << FIXSHIFT, (byte) MGL_random(8), BLT_SLASH, 1); break; case WPN_MINES: if (player.rageClock == (player.rageClock / 8)*8) { cx = 32 / 8 - ((player.rageClock - 60) / 8) + 1; for (i = 0; i < 8; i++) FireBullet(me->x + Cosine(i * 32)*(cx * 32), me->y + Sine(i * 32)*(cx * 32), 0, BLT_BOOM, 1); } break; case WPN_MINDCONTROL: if (player.rageClock & 1) for (i = 0; i < 8; i++) FireBullet(me->x, me->y, i, BLT_MINDWIPE, 1); break; case WPN_REFLECTOR: FireBullet(me->x, me->y, 0, BLT_REFLECT, 1); break; case WPN_TURRET: case WPN_SWAPGUN: for (i = 0; i < 4; i++) FireBullet(me->x, me->y, (i * 64 + player.rageClock)&255, BLT_GREEN, 1); break; case WPN_JETPACK: for (i = 0; i < 8; i++) FireBullet(me->x, me->y, i, BLT_FLAME, 1); break; } }
/**************************************************************************** PARAMETERS: dc - Display dc trans - Turn on/off transparent blitting REMARKS: Demo showing how to use offscreen buffers to store sprites and to use hardware acceleration to blt them to the display dc. ****************************************************************************/ ibool bufferBlit( MGLDC *dc, ibool trans) { MGLBUF *buf = NULL; color_t transparent; palette_t pal[256]; pixel_format_t pf; MGLDC *memdc; /* Display title message at the top of the window. */ if (trans) mainWindow(dc,"Offscreen Buffer Accelerated Transparent Blit Demo"); else mainWindow(dc,"Offscreen Buffer Accelerated Blit Demo"); statusLine("Press any key to continue, ESC to Abort"); if ((buf = MGL_createBuffer(dc,bmpWidth,bmpHeight,MGL_BUF_CACHED | MGL_BUF_MOVEABLE)) == NULL) { gprintf("Hardware accelerated buffer not available."); } else { /* Create a memory device context */ MGL_getPixelFormat(dc,&pf); if ((memdc = MGL_createMemoryDC(bmpWidth,bmpHeight,MGL_getBitsPerPixel(dc),&pf)) == NULL) MGL_fatalError(MGL_errorMsg(MGL_result())); /* Load a bitmap into the memory device context. The palette gets * loaded into the memory device context as well. */ if (!MGL_loadBitmapIntoDC(memdc,IMAGE_NAME,0,0,true)) MGL_fatalError(MGL_errorMsg(MGL_result())); MGL_copyToBuffer(memdc,0,0,bmpWidth,bmpHeight,0,0,buf); /* Set the display device context with the palette from the * memory device context. */ if (MGL_getBitsPerPixel(dc) <= 8) { MGL_getPalette(memdc,pal,MGL_getPaletteSize(memdc),0); MGL_setPalette(dc,pal,MGL_getPaletteSize(memdc),0); MGL_realizePalette(dc,MGL_getPaletteSize(memdc),0,true); } /* Get transparent color from pixel (0,0) */ MGL_makeCurrentDC(memdc); transparent = MGL_getPixelCoord(0,0); MGL_makeCurrentDC(dc); /* Copy image from offscreen video memory to the screen. */ while (!checkEvent()) { if (trans) MGL_putBufferSrcTrans(dc,MGL_random(maxx-bmpWidth),MGL_random(maxy-bmpHeight),buf,transparent,MGL_REPLACE_MODE); else MGL_putBuffer(dc,MGL_random(maxx-bmpWidth),MGL_random(maxy-bmpHeight),buf,MGL_REPLACE_MODE); } MGL_destroyDC(memdc); } /* Destroy the buffer */ MGL_destroyBuffer(buf); return pause(); }