コード例 #1
0
ファイル: Level.itcm.cpp プロジェクト: xfix/Fireworlds
void Level::render(f32 x, f32 y)
{
	int bx = (x.toint()-128) / 256;
	int by = (y.toint()-96) / 256;
	
	for(int xx = bx-2; xx <= bx+2; xx++)
		for(int yy = by -2; yy  <= by+2; yy++)
		{
			if(xx < 0) continue;
			if(yy < 0) continue;
			if(xx >= 32) continue;
			if(yy >= 32) continue;
			
			renderBlock(xx, yy, x, y, true);
		}

	for(int xx = bx-2; xx <= bx+2; xx++)
		for(int yy = by -2; yy  <= by+2; yy++)
		{
			if(xx < 0) continue;
			if(yy < 0) continue;
			if(xx >= 32) continue;
			if(yy >= 32) continue;
			
			renderBlock(xx, yy, x, y, false);
		}
}
コード例 #2
0
ファイル: Level.itcm.cpp プロジェクト: xfix/Fireworlds
inline bool collisionWith(LevelObj& obj, f32 px, f32 py)
{
	int x = px.toint();
	int y = py.toint();
	if(outside(obj, 0, 1, x, y)) return false;
	if(outside(obj, 1, 2, x, y)) return false;
	if(outside(obj, 2, 3, x, y)) return false;
	if(outside(obj, 3, 0, x, y)) return false;
	
	return true;
}
コード例 #3
0
ファイル: CharActor.cpp プロジェクト: Dirbaio/Fireworlds
CharActor::CharActor(Scene* world, char c, f32 x, f32 y) : Actor(world)
{
    this->c = c;
    this->x = x;
    this->y = y;
    life = 120 + x.toint()/4;
}
コード例 #4
0
ファイル: Level.itcm.cpp プロジェクト: xfix/Fireworlds
void Level::tick(f32 x, f32 y)
{
	if(sparkleTime > 0) sparkleTime--;
	
	int bx = (x.toint()-128) / 256;
	int by = (y.toint()-96) / 256;
	
	for(int xx = bx-1; xx <= bx+1; xx++)
		for(int yy = by -1; yy  <= by+1; yy++)
		{
			if(xx < 0) continue;
			if(yy < 0) continue;
			if(xx >= 32) continue;
			if(yy >= 32) continue;
			
			tickBlock(xx, yy, x, y);
		}
}
コード例 #5
0
ファイル: Level.itcm.cpp プロジェクト: xfix/Fireworlds
void renderObject(LevelObj& obj, f32 xx, f32 yy, Scene* sc)
{
	int x = xx.toint();
	int y = yy.toint();
	const int z = 1000;

		if(obj.type == BEH_WATER || obj.type == BEH_LAVA || obj.type == BEH_WATERDOWN || obj.type == BEH_LAVADOWN)
		{
			bool top = obj.type == BEH_WATER || obj.type == BEH_LAVA;
			bool lava = obj.type == BEH_LAVADOWN || obj.type == BEH_LAVA;

			if(top)
			{
				setTexture(TEX_VERTGRAD);
				glPolyFmt(POLY_ALPHA(28) | POLY_ID(WATER_POLYID) | POLY_CULL_NONE);
				glBegin(GL_QUAD_STRIP);
				int divnum = 32;
				f32 dx = obj.x[1]-obj.x[0];
				f32 dy = obj.y[1]-obj.y[0];
				f32 len = fsqrt(dx*dx+dy*dy);
				if(len < 90) divnum = 16;
				if(len < 45) divnum = 8;
				if(!top) divnum = 1;
				for(int j = 0; j <= divnum; j++)
				{
					int x1 = (obj.x[0]*j+obj.x[1]*(divnum-j))/divnum;
					int y1 = (obj.y[0]*j+obj.y[1]*(divnum-j))/divnum;
					int x2 = (obj.x[3]*j+obj.x[2]*(divnum-j))/divnum;
					int y2 = (obj.y[3]*j+obj.y[2]*(divnum-j))/divnum;
					
					f32 dx = x2-x1;
					f32 dy = y2-y1;
					f32 len = fsqrt(dx*dx+dy*dy);
					dx /= len;
					dy /= len;
					
					int in = x1*19+y1*14+sc->time*20;
					int in2 = x1*24-y1*18-sc->time*12;
	//				int in2 = x1*18-y1*21-sc->time*15;
					if(top)
					{
						int xw = 0;
						if(!lava)
						{
							xw += sinLerp(in*40)/600;
							xw += sinLerp(in2*23)/600;
						}
						else
						{
							xw += sinLerp(in*27)/800;
							xw += sinLerp(in2*13)/300;
						}
						dx *= xw;
						dy *= xw;
						x1 += dx.toint();
						y1 += dy.toint();
						
						if(!lava)
							glColor3b(130, 180, 255);
						else
							glColor3b(255, 180, 30);
					}
					
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(64));
					glVertex3v16((x1-x)*32, (y1-y)*32, z);

					if(!lava)
						glColor3b(20, 50, 215);
					else
						glColor3b(255, 60, 0);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(0));
					glVertex3v16((x2-x)*32, (y2-y)*32, z);
				}
				glEnd();
			}
			else
			{
				if(!lava)
					glColor3b(20, 50, 215);
				else
					glColor3b(255, 60, 0);

				setNoTexture();
				glPolyFmt(POLY_ALPHA(7) | POLY_ID(WATER_POLYID) | POLY_CULL_NONE);
				
				glBegin(GL_QUAD);

				glVertex3v16((obj.x[0]-x)*32, (obj.y[0]-y)*32, z);
				glVertex3v16((obj.x[1]-x)*32, (obj.y[1]-y)*32, z);
				glVertex3v16((obj.x[2]-x)*32, (obj.y[2]-y)*32, z);
				glVertex3v16((obj.x[3]-x)*32, (obj.y[3]-y)*32, z);

				glEnd();
				
			}
		}
		else
		{

			int a = 28;
			if(obj.type == BEH_WALL)
				glColor3b(200, 200, 255);
			else if(obj.type == BEH_BOUNCY)
				glColor3b(255, 100, 210);
			else if(obj.type == BEH_PORTAL1)
				glColor3b(100, 255, 20);
			else if(obj.type == BEH_PORTAL2)
				glColor3b(30, 140, 210);

			if(obj.type == BEH_PORTAL1 && sc->switchesActive[0]) a = 6;
			if(obj.type == BEH_PORTAL2 && sc->switchesActive[1]) a = 6;
			
			if(debugShown)
			{
				if(obj.state == 1)
					glColor3b(0, 200, 0);
				else if(obj.state == 2)
					glColor3b(0, 000, 200);
			}
			
			setTexture(TEX_INVBALL);
			glPolyFmt(POLY_ALPHA(a) | POLY_ID(LEVEL_POLYID) | POLY_CULL_NONE);

			glBegin(GL_QUAD);

			GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(0));
			glVertex3v16((obj.x[0]-x)*32, (obj.y[0]-y)*32, z);
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(64));
			glVertex3v16((obj.x[1]-x)*32, (obj.y[1]-y)*32, z);
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(64));
			glVertex3v16((obj.x[2]-x)*32, (obj.y[2]-y)*32, z);
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(0));
			glVertex3v16((obj.x[3]-x)*32, (obj.y[3]-y)*32, z);

			glEnd();
		}
}