Beispiel #1
0
void updatePixel(sr_Screen * WS, unsigned short x, unsigned short y, sr_Color c) {
  unsigned long p = (x*WS->height+y);

  if(x<WS->width && y<WS->height) {
    if(!sameColor(WS->pixels[p/4].color[p%4],c)) {
      WS->pixels[p/4].update &= ~(3<<((p%4)*2));
      WS->pixels[p/4].update |= 1<<((p%4)*2);
      copyColor(&(WS->pixels[p/4].color[p%4]),c);
    } else {
    	if(!(WS->pixels[p/4].update & 3<<((p%4)*2)) && WS->pixels[p/4].update & 2<<((p%4)*2))
    		WS->pixels[p/4].update |= 3<<((p%4)*2);
    }
  }

}
Color
SetContextForeGroundColor (Color color)
{
	Color oldColor;

	if (!ContextActive ())
		return DEFAULT_FORE_COLOR;

	oldColor = _get_context_fg_color ();
	if (!sameColor(oldColor, color))
	{
		SwitchContextForeGroundColor (color);

		if (!(_get_context_fbk_flags () & FBK_IMAGE))
		{
			SetContextFBkFlags (FBK_DIRTY);
		}
	}
	SetPrimColor (&_locPrim, color);

	return (oldColor);
}
Beispiel #3
0
std::vector<casePlateau *> *cavalier::deplacementPossible(){
    std::vector<casePlateau *> *listCase = new std::vector<casePlateau *>(0);

    casePlateau *caseArr;
    coup *cp;
    pieces *piece;

    std::vector<int> simpleStep = {-1, 1};
    std::vector<int> doubleStep = {-2, 2};

    foreach (int i, doubleStep) {
        foreach (int j, simpleStep) {
            if (p->valid(getColumn()+i, getLine()+j)) {
                caseArr = p->getCase(getColumn()+i, getLine()+j);
                piece = caseArr->getPiece();
                if (piece == NULL || !sameColor(piece)) {
                    cp = new coup(casePiece, caseArr);
                    if (p->isCoupValid(cp)) {
                        listCase->push_back(caseArr);
                    }
                }
            }
        }
    }
static void
ilwrath_preprocess (ELEMENT *ElementPtr)
{
	STATUS_FLAGS status_flags;
	STARSHIP *StarShipPtr;
	PRIMITIVE *lpPrim;

	GetElementStarShip (ElementPtr, &StarShipPtr);
	status_flags = StarShipPtr->cur_status_flags;
	lpPrim = &(GLOBAL (DisplayArray))[ElementPtr->PrimIndex];
	if (GetPrimType (lpPrim) == STAMPFILL_PRIM)
	{
		Color color;
		BOOLEAN weapon_discharge;

		color = GetPrimColor (lpPrim);
		weapon_discharge = ((status_flags & WEAPON)
				&& StarShipPtr->RaceDescPtr->ship_info.energy_level >= WEAPON_ENERGY_COST);
	
		if (
			weapon_discharge
			|| (
				StarShipPtr->special_counter == 0
				&& ( 
					((!sameColor(color, BLACK_COLOR)) && (!sameColor(color, INVIS_COLOR)))
					|| status_flags & SPECIAL
				)
			)
		)
		{
			if (sameColor (color,
					BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)))
				SetPrimType (lpPrim, STAMP_PRIM);
			else if (sameColor (color,
					BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B)))
				SetPrimColor (lpPrim,
						BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
			else if (sameColor (color,
					BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03)))
				SetPrimColor (lpPrim,
						BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B));
			else if (sameColor (color,
					BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09)))
				SetPrimColor (lpPrim,
						BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03));
			else if (sameColor (color,
					BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)))
				SetPrimColor (lpPrim,
						BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09));
			else
			{
				ProcessSound (SetAbsSoundIndex (
						/* CLOAKING_OFF */
					StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 2), ElementPtr);
			
				SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01));
			}
			
			ElementPtr->state_flags |= CHANGING;
			status_flags &= ~SPECIAL;
			StarShipPtr->special_counter = 0;
		}
		else if ( (!sameColor (color, BLACK_COLOR))
				&& (!sameColor (color, INVIS_COLOR)))
		{
			if (sameColor (color, BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01)))
			{
				if(PlayerControl[ElementPtr->playerNr] & HUMAN_CONTROL)
					SetPrimColor (lpPrim, INVIS_COLOR);
				else
					SetPrimColor (lpPrim, BLACK_COLOR);
				Untarget (ElementPtr);
			}
			else if (sameColor (color,
					BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09)))
				SetPrimColor (lpPrim,
						BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01));
			else if (sameColor (color,
					BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03)))
				SetPrimColor (lpPrim,
						BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x09));
			else if (sameColor (color,
					BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B)))
				SetPrimColor (lpPrim,
						BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x14), 0x03));
			else
				SetPrimColor (lpPrim,
						BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x0B));

			ElementPtr->state_flags |= CHANGING;
		}
	}

	if ((status_flags & SPECIAL)
			&& StarShipPtr->special_counter == 0
			&& DeltaEnergy (ElementPtr, -SPECIAL_ENERGY_COST))
	{
		SetPrimColor (lpPrim, BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
		SetPrimType (lpPrim, STAMPFILL_PRIM);

		ProcessSound (SetAbsSoundIndex (
						/* CLOAKING_ON */
				StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 1),
				ElementPtr);
		StarShipPtr->special_counter =
				StarShipPtr->RaceDescPtr->characteristics.special_wait;

		ElementPtr->state_flags |= CHANGING;
	}
}
Beispiel #5
0
static void
destruct_preprocess (ELEMENT *ElementPtr)
{
#define DESTRUCT_SWITCH ((NUM_EXPLOSION_FRAMES * 3) - 3)
    PRIMITIVE *lpPrim;

    // ship_death() set the ship element's life_span to
    // (NUM_EXPLOSION_FRAMES * 3)
    lpPrim = &(GLOBAL (DisplayArray))[ElementPtr->PrimIndex];
    ElementPtr->state_flags |= CHANGING;
    if (ElementPtr->life_span > DESTRUCT_SWITCH)
    {
        // First, stamp-fill the ship's own element with changing colors
        // for 3 frames. No explosion element yet.
        SetPrimType (lpPrim, STAMPFILL_PRIM);
        if (ElementPtr->life_span == DESTRUCT_SWITCH + 2)
            SetPrimColor (lpPrim,
                          BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E));
        else
            SetPrimColor (lpPrim,
                          BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
    }
    else if (ElementPtr->life_span < DESTRUCT_SWITCH)
    {
        // Stamp-fill the explosion element with cycling colors for the
        // remainder of the glory explosion frames.
        Color color = GetPrimColor (lpPrim);

        ElementPtr->next.image.frame =
            IncFrameIndex (ElementPtr->current.image.frame);
        if (sameColor (color,
                       BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)))
            SetPrimColor (lpPrim,
                          BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E));
        else if (sameColor (color,
                            BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x0A), 0x0E)))
            SetPrimColor (lpPrim,
                          BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C));
        else if (sameColor (color,
                            BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x0A), 0x0C)))
            SetPrimColor (lpPrim,
                          BUILD_COLOR (MAKE_RGB15 (0x14, 0x0A, 0x00), 0x06));
        else if (sameColor (color,
                            BUILD_COLOR (MAKE_RGB15 (0x14, 0x0A, 0x00), 0x06)))
            SetPrimColor (lpPrim,
                          BUILD_COLOR (MAKE_RGB15 (0x14, 0x00, 0x00), 0x04));
    }
    else
    {
        HELEMENT hDestruct;

        SetPrimType (lpPrim, NO_PRIM);
        // The ship's own element will not be drawn anymore but will remain
        // alive all through the glory explosion.
        ElementPtr->preprocess_func = NULL;

        // Spawn a separate glory explosion element.
        // XXX: Why? Why not keep using the ship's element?
        //   Is it because of conflicting state_flags, hit_points or
        //   mass_points?
        hDestruct = AllocElement ();
        if (hDestruct)
        {
            ELEMENT *DestructPtr;
            STARSHIP *StarShipPtr;

            GetElementStarShip (ElementPtr, &StarShipPtr);

            PutElement (hDestruct);
            LockElement (hDestruct, &DestructPtr);
            SetElementStarShip (DestructPtr, StarShipPtr);
            DestructPtr->hit_points = DestructPtr->mass_points = 0;
            DestructPtr->playerNr = NEUTRAL_PLAYER_NUM;
            DestructPtr->state_flags = APPEARING | FINITE_LIFE | NONSOLID;
            DestructPtr->life_span = (NUM_EXPLOSION_FRAMES - 3) - 1;
            SetPrimType (&(GLOBAL (DisplayArray))[DestructPtr->PrimIndex],
                         STAMPFILL_PRIM);
            SetPrimColor (&(GLOBAL (DisplayArray))[DestructPtr->PrimIndex],
                          BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F));
            DestructPtr->current.image.farray =
                StarShipPtr->RaceDescPtr->ship_data.special;
            DestructPtr->current.image.frame =
                StarShipPtr->RaceDescPtr->ship_data.special[0];
            DestructPtr->current.location = ElementPtr->current.location;
            DestructPtr->preprocess_func = destruct_preprocess;
            DestructPtr->postprocess_func = NULL;
            DestructPtr->death_func = NULL;
            ZeroVelocityComponents (&DestructPtr->velocity);
            UnlockElement (hDestruct);
        }
    }
}