Esempio n. 1
0
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();
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
ibool fastPolyDemo(MGLDC *dc)
/****************************************************************************
*
* Function:     fastPolyDemo
* Parameters:   dc  - Device context
*
* Description:  Display a random pattern of convex triangular polygons
*               in replace mode at full speed.
*
****************************************************************************/
{
    int         maxx,maxy;
    fxpoint_t   poly[4];            /* Space to hold polygon data   */

    mainWindow(dc,"MGL_fillPolygonFast Demonstration");
    statusLine("Press any key to continue, ESC to Abort");

    maxx = MGL_maxx();
    maxy = MGL_maxy();

    while (!checkEvent()) {
        /* Define a random polygon */

        poly[0].x = MGL_randoml(MGL_TOFIX(maxx));
        poly[0].y = MGL_randoml(MGL_TOFIX(maxy));
        poly[1].x = MGL_randoml(MGL_TOFIX(maxx));
        poly[1].y = MGL_randoml(MGL_TOFIX(maxy));
        poly[2].x = MGL_randoml(MGL_TOFIX(maxx));
        poly[2].y = MGL_randoml(MGL_TOFIX(maxy));

        MGL_setColor(randomColor());
        MGL_fillPolygonFX(3,poly,sizeof(fxpoint_t),0,0);
        }

    defaultAttributes(dc);
    return pause();
}
Esempio n. 5
0
void PlayerControlMe(Guy *me, mapTile_t *mapTile, world_t *world)
{
	byte c;
	int x, y, i;

	player.life = me->hp;

	if (player.rage)
	{
		if (player.rage > 5)
			player.rage -= 6;
		else
			player.rage = 0;
	}
	if (player.rageClock)
		DoRage(me);

	if (player.invisibility)
		player.invisibility--;

	if (player.jetting && me->seq != ANIM_DIE && me->seq != ANIM_A3)
	{
		me->dx += Cosine(me->facing * 32)*6;
		me->dy += Sine(me->facing * 32)*6;
		Clamp(&me->dx, FIXAMT * 20);
		Clamp(&me->dy, FIXAMT * 20);

		if (me->z < FIXAMT * 20)
			me->z += FIXAMT * 4;
		me->dz = 0;

		MakeSound(SND_FLAMEGO, me->x, me->y, SND_CUTOFF, 1200);
		for (i = 0; i < 3; i++)
		{
			c = ((me->facing + 4)&7)*32;
			x = me->x + Cosine(c)*10 - FIXAMT * 10 + MGL_randoml(FIXAMT * 20);
			y = me->y + Sine(c)*10 - FIXAMT * 10 + MGL_randoml(FIXAMT * 20);
			FireBullet(x, y, (me->facing + 4)&7, BLT_FLAME, 1);
		}
		player.jetting--;
	}

	if (player.weapon == WPN_PWRARMOR)
	{
		PlayerControlPowerArmor(me, mapTile, world);
		return;
	}

	if (player.reload)
		player.reload--;
	if (player.wpnReload)
		player.wpnReload--;

	if (player.garlic)
	{
		player.garlic--;
		StinkySteam(me->x - FIXAMT * 20 + MGL_randoml(FIXAMT * 40), me->y - FIXAMT * 20 + MGL_randoml(FIXAMT * 40),
				me->z + FIXAMT * 40, FIXAMT * 2);
	}

	if (player.shield)
		player.shield--;

	if (player.pushPower)
		player.pushPower--;

	if (tportclock)
		tportclock--;

	// ice is slippery
	if (!(world->terrain[mapTile->floor].flags & TF_ICE))
	{
		if (player.jetting && me->mind1)
		{
			if (me->mind1 & 1)
			{
				me->dx = -me->dx;
				switch (me->facing) {
					case 0:
						me->facing = 4;
						break;
					case 1:
						me->facing = 3;
						break;
					case 2:
					case 6:
						break;
					case 3:
						me->facing = 1;
						break;
					case 4:
						me->facing = 0;
						break;
					case 5:
						me->facing = 7;
						break;
					case 7:
						me->facing = 5;
						break;
				}
			}
			if (me->mind1 & 2)
			{
				me->dy = -me->dy;
				switch (me->facing) {
					case 0:
					case 4:
						break;
					case 1:
						me->facing = 7;
						break;
					case 2:
						me->facing = 6;
						break;
					case 3:
						me->facing = 5;
						break;
					case 5:
						me->facing = 3;
						break;
					case 6:
						me->facing = 2;
						break;
					case 7:
						me->facing = 1;
						break;
				}
			}
		}
		Dampen(&me->dx, PLYR_DECEL);
		Dampen(&me->dy, PLYR_DECEL);
	}
	else
	{
		if (me->mind1) // bumped a wall while on ice
		{
			if (me->mind1 & 1)
				me->dx = -me->dx / 8;
			if (me->mind1 & 2)
				me->dy = -me->dy / 8;
		}
	}
	me->mind1 = 0;

	if (me->ouch == 4)
	{
		if (opt.playAs == PLAYAS_BOUAPHA)
		{
			if (me->hp > 0)
				MakeSound(SND_BOUAPHAOUCH, me->x, me->y, SND_CUTOFF | SND_ONE, 2000);
			else if (me->seq == ANIM_DIE) // so it doesn't do this if you're drowning
				MakeSound(SND_BOUAPHADIE, me->x, me->y, SND_CUTOFF | SND_ONE, 2000);
		}
		else if (opt.playAs == PLAYAS_LUNATIC)
		{
			if (me->hp > 0)
				MakeSound(SND_DRLOUCH, me->x, me->y, SND_CUTOFF | SND_ONE, 2000);
			else if (me->seq == ANIM_DIE) // so it doesn't do this if you're drowning
				MakeSound(SND_DRLDIE, me->x, me->y, SND_CUTOFF | SND_ONE, 2000);
		}
		else
		{
			if (me->hp > 0)
				MakeSound(SND_HAPPYOUCH, me->x, me->y, SND_CUTOFF | SND_ONE, 2000);
			else if (me->seq == ANIM_DIE) // so it doesn't do this if you're drowning
				MakeSound(SND_HAPPYDIE, me->x, me->y, SND_CUTOFF | SND_ONE, 2000);
		}
	}

	if (me->parent) // being grabbed by a Super Zombie or something
	{
		if (me->parent->type == MONS_SUPERZOMBIE)
		{
			me->dz = 0;
			if (me->parent->frm < 4)
				me->z += FIXAMT * 3;
			else if (me->parent->frm > 18)
			{
				me->z -= FIXAMT * 4;
				if (me->parent->frm == 21)
				{
					me->z = 0;
					me->parent = NULL;
					me->action = ACTION_IDLE;
					if (me->hp == 0)
					{
						me->seq = ANIM_DIE;
						me->frm = 0;
						me->frmTimer = 0;
						me->frmAdvance = 64;
						me->action = ACTION_BUSY;
					}
					return;
				}
			}
			if (me->seq != ANIM_MOVE)
			{
				me->seq = ANIM_MOVE;
				me->frm = 0;
				me->frmTimer = 0;
				me->frmAdvance = 512;
			}
			return;
		}
		else if (me->parent->type == MONS_MINECART)
		{
			me->x = me->parent->x;
			me->y = me->parent->y + 1;
			me->z = FIXAMT * 8;
		}
		else
		{
			me->parent = NULL;
		}
	}

	// triggering stuff
	if (me->action == ACTION_BUSY)
	{
		// throw hammer if need be, use item if need be
		if (me->seq == ANIM_A1 && me->frm == 2 && player.wpnReload == 0)
		{
			PlayerFireWeapon(me);
			return;
		}

		if (me->seq == ANIM_A3)
		{
			if (me->frm < 11)
			{
				me->z = FIXAMT * 8; // hover while spinning feet in the air before plunging into water
				me->dz = FIXAMT;
			}
			else
			{
				ExplodeParticles(PART_WATER, me->x, me->y, 0, 16);
			}
			return;
		}
		if (me->seq == ANIM_DIE)
		{
			me->facing = (me->facing + 1)&7;
			return;
		}
		if (me->seq == ANIM_A1)
			return;
	}

	// not busy, let's see if you want to do something
	c = GetControls();

	if (!player.jetting)
		DoPlayerFacing(c, me);

	if (me->action == ACTION_IDLE)
	{
		if ((c & (CONTROL_B1 | CONTROL_B2)) == (CONTROL_B1 | CONTROL_B2) && (player.rage / 256) >= player.life)
		{
			// RAGE!!!!!!!
			player.rage = 0;
			player.rageClock = 15;
			if (player.shield == 0)
				player.shield = 30;
			EnterRage();
		}
		if ((c & CONTROL_B1) && player.reload == 0) // pushed hammer throw button
		{
			me->action = ACTION_IDLE;
			if (!(c & (CONTROL_UP | CONTROL_DN | CONTROL_LF | CONTROL_RT)))
			{
				me->seq = ANIM_ATTACK; // even if unarmed
				me->frm = 0;
				me->frmTimer = 0;
				me->frmAdvance = 255;
				me->frm += 4 - (player.hamSpeed >> 2);
			}
			player.boredom = 0;
			if (player.hammers > 0)
				PlayerThrowHammer(me);
			player.reload += (10 - (4 - (player.hamSpeed >> 2)));
		}