Example #1
0
		double noise(double x, double y, double z) const
		{
			const std::int32_t X = static_cast<std::int32_t>(std::floor(x)) & 255;
			const std::int32_t Y = static_cast<std::int32_t>(std::floor(y)) & 255;
			const std::int32_t Z = static_cast<std::int32_t>(std::floor(z)) & 255;

			x -= std::floor(x);
			y -= std::floor(y);
			z -= std::floor(z);

			const double u = Fade(x);
			const double v = Fade(y);
			const double w = Fade(z);

			const std::int32_t A = p[X] + Y, AA = p[A] + Z, AB = p[A + 1] + Z;
			const std::int32_t B = p[X + 1] + Y, BA = p[B] + Z, BB = p[B + 1] + Z;

			return Lerp(w, Lerp(v, Lerp(u, Grad(p[AA], x, y, z),
				Grad(p[BA], x - 1, y, z)),
				Lerp(u, Grad(p[AB], x, y - 1, z),
				Grad(p[BB], x - 1, y - 1, z))),
				Lerp(v, Lerp(u, Grad(p[AA + 1], x, y, z - 1),
				Grad(p[BA + 1], x - 1, y, z - 1)),
				Lerp(u, Grad(p[AB + 1], x, y - 1, z - 1),
				Grad(p[BB + 1], x - 1, y - 1, z - 1))));
		}
Example #2
0
float CPerlinNoise::Noise3( float x, float y, float z )
{
	vector<int32_t>& p = m_PermutationTbl;

	int X = (int)floor(x) & 255,             /* FIND UNIT CUBE THAT */
		Y = (int)floor(y) & 255,             /* CONTAINS POINT.     */
		Z = (int)floor(z) & 255;
	x -= floor(x);                             /* FIND RELATIVE X,Y,Z */
	y -= floor(y);                             /* OF POINT IN CUBE.   */
	z -= floor(z);
	float  u = Fade(x),                       /* COMPUTE FADE CURVES */
		v = Fade(y),                       /* FOR EACH OF X,Y,Z.  */
		w = Fade(z);
	int  A = p[X]+Y, 
		AA = p[A]+Z, 
		AB = p[A+1]+Z, /* HASH COORDINATES OF */
		B = p[X+1]+Y, 
		BA = p[B]+Z, 
		BB = p[B+1]+Z; /* THE 8 CUBE CORNERS, */

	return BasicMath::Lerp(w,BasicMath::Lerp(v,BasicMath::Lerp(u, Grad(p[AA  ], x, y, z),   /* AND ADD */
		Grad(p[BA  ], x-1, y, z)),        /* BLENDED */
		BasicMath::Lerp(u, Grad(p[AB  ], x, y-1, z),         /* RESULTS */
		Grad(p[BB  ], x-1, y-1, z))),     /* FROM  8 */
		BasicMath::Lerp(v, BasicMath::Lerp(u, Grad(p[AA+1], x, y, z-1 ),/* CORNERS */
		Grad(p[BA+1], x-1, y, z-1)),      /* OF CUBE */
		BasicMath::Lerp(u, Grad(p[AB+1], x, y-1, z-1),
		Grad(p[BB+1], x-1, y-1, z-1))));
}
Example #3
0
BOOL CDrawGraphics::DelChar(int Position,int FadeOr)
{
	//キャラ非表示
	switch(Position){
		case PosL:
			if(FadeOr==0)Fade(CharL,FadeOut);
			//CharL->SetChar(g_lpD3DDevice,IDR_INV);
			CharL->Destroy(g_lpD3DDevice,PosL);
			break;
		case PosC:
			if(FadeOr==0)Fade(CharC,FadeOut);
			//CharC->SetChar(g_lpD3DDevice,IDR_INV);
			CharC->Destroy(g_lpD3DDevice,PosC);
			break;
		case PosR:
			if(FadeOr==0)Fade(CharR,FadeOut);
			//CharR->SetChar(g_lpD3DDevice,IDR_INV);
			CharR->Destroy(g_lpD3DDevice,PosR);
			break;
		case PosBG:
			if(FadeOr==0)Fade(Haikei,FadeOut);
			Haikei->Destroy(g_lpD3DDevice,PosBG);
			break;
		default:
			return FALSE;
	}

	return 0;
}
Example #4
0
// Title Screen Draw logic
void DrawTitleScreen(void)
{
    // TODO: Draw TITLE screen here!
    DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE);
    //DrawTextureEx(titleTexture, (Vector2){GetScreenWidth()/2-titleTexture.width/2, GetScreenHeight()/2-titleTexture.height/2}, 0, 1, Fade(WHITE, titleAlpha));
    DrawRectangle(GetScreenWidth()/2-200, GetScreenHeight()/2-100, 400, 150, Fade(YELLOW, titleAlpha));
    DrawText("PRESS <ENTER> to START the GAME", 208, GetScreenHeight()-75, 20, Fade(BLACK, startTextAlpha));
}
Example #5
0
// Ending Screen Draw logic
void DrawEndingScreen(void)
{
    DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKGRAY);

    DrawTextEx(font, "CONGRATULATIONS!", (Vector2){ 50, 160 }, font.baseSize*3, 2, Fade(WHITE, alpha));
    DrawTextEx(font, "SKULLY ESCAPED!", (Vector2){ 100, 300 }, font.baseSize*3, 2, Fade(WHITE, alpha));
    
    if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawText("PRESS ENTER or CLICK", 380, 545, 40, BLACK);
}
Example #6
0
// Gameplay Screen Draw logic
void DrawAisle01Screen(void)
{
    DrawTexture(background, -scroll, 0, WHITE);
    
    // Draw monsters
	DrawMonster(lamp, scroll);
    DrawMonster(picture, scroll);
    
    // Draw door
    Vector2 doorScrollPos = { doorCenter.position.x - scroll, doorCenter.position.y };
    if (doorCenter.selected) DrawTextureRec(doors, doorCenter.frameRec, doorScrollPos, GREEN);
    else DrawTextureRec(doors, doorCenter.frameRec, doorScrollPos, WHITE);
    
    doorScrollPos = (Vector2){ doorLeft.position.x - scroll, doorLeft.position.y };
    if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, GREEN);
    else DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, WHITE);
    
    doorScrollPos = (Vector2){ doorRight.position.x - scroll, doorRight.position.y };
    if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorScrollPos, GREEN);
    else DrawTextureRec(doors, doorRight.frameRec, doorScrollPos, WHITE);
    
    // Draw messsages
    if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f));
    else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f));

    if (msgState == 0) 
    {
        DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
    }
    else if (msgState == 1)
    {
        DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.baseSize, 2, WHITE);
        
        if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
    }
    else if (msgState == 2)
    {
        if ((msgCounter/30)%2)
        {
            DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.baseSize*2, 2, WHITE);
            
            DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
            DrawRectangleRec(picture.bounds, Fade(RED, 0.6f));
        }
    }
    else
    {
        if ((monsterHover) && ((msgCounter/30)%2))
        {
            DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f));
            DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK);
        }
    }

    DrawPlayer();       // NOTE: Also draws mouse pointer!
}
Example #7
0
void GameEntityWhiteScreen::Animate(float delay) {
    GameEntity::Animate(delay);

    float fade=Fade();

    sprite.setColor(sf::Color(255, 255, 255, 255 * fade));
}
Example #8
0
void WrapperDLL::Sound_Fade(void* self,int32_t id,float second,float targetedVolume){
	auto self_ = (Sound*)self;
	auto arg0 = id;
	auto arg1 = second;
	auto arg2 = targetedVolume;
	self_->Fade(arg0,arg1,arg2);
};
Example #9
0
void CPartSnowFlake::Think( float flTime )
{
	if( m_flBrightness < 130.0 && !m_bTouched )
		m_flBrightness += 4.5;

	Fade( flTime );
	Spin( flTime );

	if( m_flSpiralTime <= gEngfuncs.GetClientTime() )
	{
		m_bSpiral = !m_bSpiral;

		m_flSpiralTime = gEngfuncs.GetClientTime() + UTIL_RandomLong( 2, 4 );
	}
	else
	{
	}

	if( m_bSpiral && !m_bTouched )
	{
		const float flDelta = flTime - g_Environment.GetOldTime();

		const float flSpin = sin( flTime * 5.0 + reinterpret_cast<int>( this ) );
	
		m_vOrigin = m_vOrigin + m_vVelocity * flDelta;

		m_vOrigin.x += ( flSpin * flSpin ) * 0.3;
	}
	else
	{
		CalculateVelocity( flTime );
	}

	CheckCollision( flTime );
}
Example #10
0
/*
================
idLight::FadeIn
================
*/
void idLight::FadeIn( float time ) {
	idVec3 color;
	idVec4 color4;
	currentLevel = levels;
	spawnArgs.GetVector( "_color", "1 1 1", color );
	color4.Set( color.x, color.y, color.z, 1.0f );
	Fade( color4, time );
}
void UIPicButton::NotifyTimer (unsigned int wParam)
{
	if (g_bUsefade == true) {
		if (wParam == TMR_FADE+g_controlID) {
			Fade ();
		}
	}
}
Example #12
0
int main()
{
    // Initialization
    //--------------------------------------------------------------------------------------
    int screenWidth = 800;
    int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle");

    const char textLine1[] = "Lena image is a standard test image which has been in use since 1973.";
    const char textLine2[] = "It comprises 512x512 pixels, and it is probably the most widely used";
    const char textLine3[] = "test image for all sorts of image processing algorithms.";

    // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
    Texture2D texture = LoadTexture("resources/lena.png");        // Texture loading

    Rectangle eyesRec = { 225, 240, 155, 50 };  // Part of the texture to draw
    Vector2 position = { 369, 241 };
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Update
        //----------------------------------------------------------------------------------
        // TODO: Update your variables here
        //----------------------------------------------------------------------------------

        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();

            ClearBackground(RAYWHITE);

            DrawText("LENA", 220, 100, 20, PINK);

            DrawTexture(texture, screenWidth/2 - 256, 0, Fade(WHITE, 0.1f)); // Draw background image

            DrawTextureRec(texture, eyesRec, position, WHITE);  // Draw eyes part of image

            DrawText(textLine1, 220, 140, 10, DARKGRAY);
            DrawText(textLine2, 220, 160, 10, DARKGRAY);
            DrawText(textLine3, 220, 180, 10, DARKGRAY);

        EndDrawing();
        //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    UnloadTexture(texture);       // Texture unloading

    CloseWindow();                // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}
Example #13
0
BOOL CDrawGraphics::Disp(int resID,int Position,int loadFlag)
{
	//キャラ表示
	switch(Position){
		case PosL:
			if(CharL->Visible==FALSE||loadFlag==1){
				if(CharL->LastChar!=resID){
					CharL->SetChar(g_lpD3DDevice,resID);
					Fade(CharL,FadeIn);
				}
			}
			break;
		case PosC:
			if(CharC->Visible==FALSE||loadFlag==1){
				if(CharC->LastChar!=resID){
					CharC->SetChar(g_lpD3DDevice,resID);
					Fade(CharC,FadeIn);
				}
			}
			break;
		case PosR:
			if(CharR->Visible==FALSE||loadFlag==1){
				if(CharR->LastChar!=resID){
					CharR->SetChar(g_lpD3DDevice,resID);
					Fade(CharR,FadeIn);
				}
			}
			break;
		case PosBG:
			if(Haikei->LastBG!=resID||loadFlag==1){
				if(CtrlOn==FALSE)OldHaikei->SetHaikei(g_lpD3DDevice,Haikei->LastBG);
				Haikei->SetHaikei(g_lpD3DDevice,resID);
				if(CtrlOn==FALSE){
					Fade(Haikei,FadeIn);
					OldHaikei->Destroy(g_lpD3DDevice,PosBG);
				}
			}
			break;
		default:
			return 0;
	}
	
	return 0;
}
void main(void) {
    byte pattern=0;
    initSquareWear();
    initBlink();
    // open button interrupt
    openOnBoardButtonInterrupt(button_callback);
    while(1) {
        switch(pattern) {
            case 0:
                Blink(500); // blink at 500ms interval
                break;
            case 1:
                Blink(250); // blink at 250ms interval
                break;
            case 2:
                Blink(1000); // blink at 100ms interval
                break;
            case 3:
                Fade(15);   // fade at 50ms interval
                break;
            case 4:
                Fade(50);    // fade at 1ms interval
                break;
            case 5:
                Fade(4);    // fade at 2ms interval
                break;
        }
        if(change) {
            pattern=(pattern+1)%6;  // change pattern
            // call corresponding initialization function
            if(pattern==0 || pattern==1 || pattern==2)  {
                initBlink();
            } else {
                initFade();
            }
            change=0;
        }

    }

}
Example #15
0
void GameEntityFlyingText::Animate(float delay) {
    GameEntity::Animate(delay);

    text.setPosition(x, y);

    float fade=Fade();
    text.setColor(sf::Color(128 * fade, 255 * fade, 255 , 255 * fade));
    //float fade=Fade();

    //sprite.SetColor(sf::Color(255, 255, 255, 255 * fade));

}
Example #16
0
void Transitions2D::Fade(CIwTexture* start, CIwTexture* end, uint8 transitionSpeed, bool skipFirstAndLastFrame)
{
	CIwTexture* tempStart = mStartTexture;
	CIwTexture* tempEnd = mEndTexture;
	mStartTexture = start;
	mEndTexture = end;
	isUsingPrivateTextures = false;
	Fade(transitionSpeed, skipFirstAndLastFrame);
	isUsingPrivateTextures = true;
	mStartTexture = tempStart;
	mEndTexture = tempEnd;
}
Example #17
0
void idLight::Event_FadeLight( float time, const idVec3 &newColor )
{
	idVec3 color;
	idVec4 color4;

	currentLevel = levels;

	color4.Set( newColor.x, newColor.y, newColor.z, 1.0f );
	Fade( color4, time );

	this->isOn = true;
}
Example #18
0
void GameEntityBoom::Animate(float delay) {
    GameEntity::Animate(delay);

    float fade=Fade();

    if (fade>0.9f) {
        fade=(1.0f-fade) * 10;
    } else  {
        fade = fade*10/9;
    }


    sprite.setScale(5.0f*fade, 5.0f*fade);
}
Example #19
0
void GameEntityLightning::Animate(float delay) {
    GameEntity::Animate(delay);

    float fade=Fade();

    if (fade>0.9f) {
        fade=(1.0f-fade) * 10;
    } else  {
        fade = fade*10/9;
    }
    if (fade < 0.0f) fade = 0.0f;
    if (fade > 1.0f) fade = 1.0f;

    sprite.setColor(sf::Color(255, 255, 255, 255 * fade));

    bool flipX = rand()%2 == 0;
    bool flipY = rand()%2 == 0;

    sprite.setTextureRect(sf::IntRect(flipX ? width : 0, flipY ? height : 0,
                                      flipX ? -width : width, flipY ? -height : height));
}
void CFriendChange_UI::Update()
{
	float fTime = g_D3dDevice->GetTime() ;
	float fSpeed = 0.0f ;

	if(m_StateC==NONE && g_Keyboard->IsButtonDown(DIK_A))
	{
		if(m_StateF==DISABLE)
			SetFadeState(FADE_IN) ;
		
		m_fFadeTime = 0.0f ;
		m_nNowAlpha = 255 ;
		m_StateC = RIGHT ;
		m_StateF = ENABLE ;
	}
	else if(m_StateC==NONE && g_Keyboard->IsButtonDown(DIK_S))
	{
		if(m_StateF==DISABLE)
			SetFadeState(FADE_IN) ;
		
		m_fFadeTime = 0.0f ;
		m_nNowAlpha = 255 ;
		m_StateC = LEFT ;
		m_StateF = ENABLE ;
	}

	for(int i=0; i<5; i++)
	{
		m_fDegree[i] += fSpeed * fTime ;
		if(m_fDegree[i]>=360.0f)
			m_fDegree[i] -= 360.0f ;
		else if(m_fDegree[i]<0.0f)
			m_fDegree[i] += 360.0f ;
	}

	Animation() ;
	Fade() ;

	SetCirclePosition() ;
}
Example #21
0
Title::Title(AppNative* app) :
SceneBase(app, Fade(Fade::Type::In)),
font_(loadAsset("rounded-l-mplus-1c-regular.ttf")),
pos_(0, 0),
net_("127.0.0.1", 12345) {
  font_.setSize(50);

  recv_.init(54321);

  enable_ = true;
  send_th_ = std::thread([&] {
    while (true) {
      picojson::object obj;
      obj.emplace(std::make_pair("posx", pos_.x));
      obj.emplace(std::make_pair("posy", pos_.y));

      picojson::value val(obj);

      net_.send(val.serialize());
      if (!enable_) break;
    }
  });

  recv_th_ = std::thread([&] {
    while (true) {
      std::string data;
      recv_ >> data;
      if (data.size() < 8) continue;
      picojson::value val;
      picojson::parse(val, data);
      picojson::object obj(val.get<picojson::object>());

      e_pos_.x = obj["posx"].get<double>();
      e_pos_.y = obj["posy"].get<double>();

      if (!enable_) break;
    }
  });
Example #22
0
//white out or black out effect
BOOL CDrawGraphics::DispOut(int Flag/*,int resID*/)
{
	if(CtrlOn==TRUE){
		//MessageBox(NULL,"ctrl","",MB_OK);
		OutFlag=0;
		return 0;
	}

	OldHaikei->SetHaikei(g_lpD3DDevice,Haikei->LastBG);
	//OutFlag=1;
	switch(Flag){
		case BLACKOUT:
            Haikei->SetHaikei(g_lpD3DDevice,IDR_BL1);
			break;
		case WHITEOUT:
			Haikei->SetHaikei(g_lpD3DDevice,IDR_WH1);
			break;
		default:
			break;
	}
	Fade(Haikei,FadeIn);
	return 0;
}
Example #23
0
/*
=================
idPlayerView::Flash

flashes the player view with the given color
=================
*/
void idPlayerView::Flash(idVec4 color, int time ) {
	Fade(idVec4(0, 0, 0, 0), time);
	fadeFromColor = colorWhite;
}
Example #24
0
// Update and Draw one frame
void UpdateDrawFrame(void)
{
    // Update
    //----------------------------------------------------------------------------------
    if (!onTransition)
    {
        switch (currentScreen)
        {
            case LOGO:
            {
                UpdateLogoScreen();

                if (FinishLogoScreen()) TransitionToScreen(TITLE);

            } break;
            case TITLE:
            {
                UpdateTitleScreen();

                // NOTE: FinishTitleScreen() return an int defining the screen to jump to
                if (FinishTitleScreen() == 1)
                {
                    UnloadTitleScreen();
                    //currentScreen = OPTIONS;
                    //InitOptionsScreen();
                }
                else if (FinishTitleScreen() == 2)
                {
                    UnloadTitleScreen();
                    
                    InitGameplayScreen();
                    TransitionToScreen(GAMEPLAY);
                }
            } break;
            case GAMEPLAY:
            {
                UpdateGameplayScreen();

                if (FinishGameplayScreen())
                {
                    UnloadGameplayScreen();
                    
                    InitEndingScreen();
                    TransitionToScreen(ENDING); 
                }
            } break;
            case ENDING:
            {
                UpdateEndingScreen();

                if (FinishEndingScreen())
                {
                    UnloadEndingScreen();
                    
                    InitGameplayScreen();
                    TransitionToScreen(GAMEPLAY); 
                }
            } break;
            default: break;
        }
    }
    else UpdateTransition();
    
    UpdateMusicStream(music);
    //----------------------------------------------------------------------------------

    // Draw
    //----------------------------------------------------------------------------------
    BeginDrawing();

        ClearBackground(WHITE);
        
        switch (currentScreen)
        {
            case LOGO: DrawLogoScreen(); break;
            case TITLE: DrawTitleScreen(); break;
            case GAMEPLAY: DrawGameplayScreen(); break;
            case ENDING: DrawEndingScreen(); break;
            default: break;
        }

        if (onTransition) DrawTransition();
        
        DrawFPS(20, GetScreenHeight() - 30);
        
        DrawRectangle(GetScreenWidth() - 200, GetScreenHeight() - 50, 200, 40, Fade(WHITE, 0.6f));
        DrawText("ALPHA VERSION", GetScreenWidth() - 180, GetScreenHeight() - 40, 20, DARKGRAY);

    EndDrawing();
    //----------------------------------------------------------------------------------
}
Example #25
0
void DrawTransition(void)
{
    DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha));
}
Example #26
0
/*
================
idLight::FadeOut
================
*/
void idLight::FadeOut( float time ) {
	Fade( colorBlack, time );
}
void ZoomControlExternal::ExtendedZoomControls::Hide()
{
    Fade(IView::GONE, 1.0f, 0.0f);
}
void ZoomControlExternal::ExtendedZoomControls::Show(
    /* [in] */ Boolean showZoom)
{
    mPlusMinusZoomControls->SetVisibility(showZoom ? IView::VISIBLE : IView::GONE);
    Fade(IView::VISIBLE, 0.0f, 1.0f);
}
int main(void)
{
    // Initialization
    //--------------------------------------------------------------------------------------
    const int screenWidth = 800;
    const int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles blending");

    // Particles pool, reuse them!
    Particle mouseTail[MAX_PARTICLES] = { 0 };

    // Initialize particles
    for (int i = 0; i < MAX_PARTICLES; i++)
    {
        mouseTail[i].position = (Vector2){ 0, 0 };
        mouseTail[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 };
        mouseTail[i].alpha = 1.0f;
        mouseTail[i].size = (float)GetRandomValue(1, 30)/20.0f;
        mouseTail[i].rotation = (float)GetRandomValue(0, 360);
        mouseTail[i].active = false;
    }

    float gravity = 3.0f;

    Texture2D smoke = LoadTexture("resources/smoke.png");

    int blending = BLEND_ALPHA;

    SetTargetFPS(60);
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Update
        //----------------------------------------------------------------------------------

        // Activate one particle every frame and Update active particles
        // NOTE: Particles initial position should be mouse position when activated
        // NOTE: Particles fall down with gravity and rotation... and disappear after 2 seconds (alpha = 0)
        // NOTE: When a particle disappears, active = false and it can be reused.
        for (int i = 0; i < MAX_PARTICLES; i++)
        {
            if (!mouseTail[i].active)
            {
                mouseTail[i].active = true;
                mouseTail[i].alpha = 1.0f;
                mouseTail[i].position = GetMousePosition();
                i = MAX_PARTICLES;
            }
        }

        for (int i = 0; i < MAX_PARTICLES; i++)
        {
            if (mouseTail[i].active)
            {
                mouseTail[i].position.y += gravity;
                mouseTail[i].alpha -= 0.01f;

                if (mouseTail[i].alpha <= 0.0f) mouseTail[i].active = false;

                mouseTail[i].rotation += 5.0f;
            }
        }

        if (IsKeyPressed(KEY_SPACE))
        {
            if (blending == BLEND_ALPHA) blending = BLEND_ADDITIVE;
            else blending = BLEND_ALPHA;
        }
        //----------------------------------------------------------------------------------

        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();

            ClearBackground(DARKGRAY);

            BeginBlendMode(blending);

                // Draw active particles
                for (int i = 0; i < MAX_PARTICLES; i++)
                {
                    if (mouseTail[i].active) DrawTexturePro(smoke, (Rectangle){ 0.0f, 0.0f, (float)smoke.width, (float)smoke.height },
                                                           (Rectangle){ mouseTail[i].position.x, mouseTail[i].position.y, smoke.width*mouseTail[i].size, smoke.height*mouseTail[i].size },
                                                           (Vector2){ (float)(smoke.width*mouseTail[i].size/2.0f), (float)(smoke.height*mouseTail[i].size/2.0f) }, mouseTail[i].rotation,
                                                           Fade(mouseTail[i].color, mouseTail[i].alpha));
                }

            EndBlendMode();

            DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, BLACK);

            if (blending == BLEND_ALPHA) DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, BLACK);
            else DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, RAYWHITE);

        EndDrawing();
        //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    UnloadTexture(smoke);

    CloseWindow();        // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}
Example #30
0
// Mission Screen Draw logic
void DrawMissionScreen(void)
{
    // Draw MISSION screen here!
    DrawTexture(texBackground, 0,0, WHITE);
    DrawTexturePro(texBackline, sourceRecBackLine, destRecBackLine, (Vector2){0,0},0, Fade(WHITE, fadeBackLine));

    if (writeNumber) DrawTextEx(fontMission, FormatText("Filtración #%02i ", currentMission + 1), numberPosition, missionSize + 10, 0, numberColor);
    DrawTextEx(fontMission, TextSubtext(missions[currentMission].brief, 0, missionLenght), missionPosition, missionSize, 0, missionColor);
    if (writeKeyword && blinkKeyWord) DrawTextEx(fontMission, FormatText("Keyword: %s", missions[currentMission].key), keywordPosition, missionSize + 10, 0, keywordColor);

    if (showButton)
    {
        if (!writeEnd) DrawButton("saltar");
        else DrawButton("codificar");
    }
}