OpenGL fade effect

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

jjackdev
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 16
Joined: Mon Aug 30, 2010 11:55 pm

Re: OpenGL fade effect

Post by jjackdev »

Its in the code I posted earlier. It looks like this.

Code: Select all

for (int i = 0; i < TILE_SOLID_COUNT; i++) {
			if (IsCollision(tileRect[i], playerRect) == true) {
				collision = true;
				if (i == 33) { //Collision with the warp
					x = 303; //Set to center
					y = 223; //Set to center
					alpha = 0.0f; //Set the alpha to zero
					fading = true; //Set the fading to true
				}
				if (movedX == true) {
					if (movedRight == true) {
						x-=5;
					}
					else {
						x+=5;
					}

				} 
                                //Collision response below
				if (movedY == true) {
					if (movedUp == true) {
						y+=5;
					}
					else {
						y-=5;
					}

				}
			}
			if (fading) {
				break;
			}	
		}
User avatar
WSPSNIPER
Chaos Rift Regular
Chaos Rift Regular
Posts: 145
Joined: Sun Jan 03, 2010 6:19 pm
Current Project: top down shooter
Favorite Gaming Platforms: ps3
Programming Language of Choice: c++

Re: OpenGL fade effect

Post by WSPSNIPER »

jjackdev wrote:Its in the code I posted earlier. It looks like this.

Code: Select all

for (int i = 0; i < TILE_SOLID_COUNT; i++) {
			if (IsCollision(tileRect[i], playerRect) == true) {
				collision = true;
				if (i == 33) { //Collision with the warp
					x = 303; //Set to center
					y = 223; //Set to center
					alpha = 0.0f; //Set the alpha to zero
					fading = true; //Set the fading to true
				}
				if (movedX == true) {
					if (movedRight == true) {
						x-=5;
					}
					else {
						x+=5;
					}

				} 
                                //Collision response below
				if (movedY == true) {
					if (movedUp == true) {
						y+=5;
					}
					else {
						y-=5;
					}

				}
			}
			if (fading) {
				break;
			}	
		}
well the if(fading) break wont make it fade but idk if thats what your code looks like...
jjackdev
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 16
Joined: Mon Aug 30, 2010 11:55 pm

Re: OpenGL fade effect

Post by jjackdev »

Just ignore the if (fading) break; thing that is just a test to see if it will work but it doesn't. I got it to work I think it has to do with SDL and the OpenGL not communicating.
jjackdev
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 16
Joined: Mon Aug 30, 2010 11:55 pm

Re: OpenGL fade effect

Post by jjackdev »

WSPSNIPER : Thank you so much I used your new updated method and it works even with the warp.Thank you so much
User avatar
WSPSNIPER
Chaos Rift Regular
Chaos Rift Regular
Posts: 145
Joined: Sun Jan 03, 2010 6:19 pm
Current Project: top down shooter
Favorite Gaming Platforms: ps3
Programming Language of Choice: c++

Re: OpenGL fade effect

Post by WSPSNIPER »

jjackdev wrote:WSPSNIPER : Thank you so much I used your new updated method and it works even with the warp.Thank you so much

YAY!!! you're welcome! im just glad to help :mrgreen:
User avatar
TheBuzzSaw
Chaos Rift Junior
Chaos Rift Junior
Posts: 310
Joined: Wed Dec 02, 2009 3:55 pm
Current Project: Paroxysm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: OpenGL fade effect

Post by TheBuzzSaw »

I have a fade effect inside my fragment shader. It's quite handy.
Post Reply