Esempio n. 1
0
void Mouse::render() {
	glLoadMatrixf(maze->modelMatrix);
	float x1 = maze->x0 + x*maze->cellWidth;
	float y1 = maze->y0 + y*maze->cellHeight;
	glTranslatef(x1, y1, 0);
	glScalef(maze->cellWidth*0.5, maze->cellHeight*0.5, 0);
	glRotatef(angle - 90, 0, 0, 1);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_TEXTURE_2D);
	if (sick) {
		glBindTexture(GL_TEXTURE_2D, sickMouseTexture);
	} else if (drill) {
		glBindTexture(GL_TEXTURE_2D, drillMouseTexture);
	} else {
		glBindTexture(GL_TEXTURE_2D, mouseTexture);
	}
	glBegin(GL_QUADS);
	if (magic) {
		adjustColor(Color(1, 0.7, 0)).gl();
	} else {
		adjustColor(color).gl();
	}
	glTexCoord2f(0, 0); glVertex2f(-1, -1);
	glTexCoord2f(0, 1); glVertex2f(-1, 1);
	glTexCoord2f(1, 1); glVertex2f(1, 1);
	glTexCoord2f(1, 0); glVertex2f(1, -1);
	glEnd();
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_BLEND);
}
Esempio n. 2
0
void cBkGrid::update(sf::Time dt)
{    
    mAccumulator += dt;
    if ( mAccumulator >= mTimer )
    {
        mAccumulator = sf::Time::Zero;
        adjustColor();
    }
    
    // Horizontal lines' velocity
    sf::Vector2f    dVhori { 0.0, mVelocity.y };
    dVhori *= dt.asSeconds();
    for (auto i = 0; i < gGridSize.y * 2; ++i)
    {
        mPoints[i].position += dVhori;
        
        if (mPoints[i].position.y < 0)
        {
            mPoints[i].position.y += mSize;
        }
        if (mPoints[i].position.y > mSize)
        {
            mPoints[i].position.y -= mSize;
        }
    }
    
    // Vertical lines' velocity
    sf::Vector2f    dVvert { mVelocity.x, 0.0 };
    dVvert *= dt.asSeconds();
    for (auto i = mFirstVline; i < gGridPointCount; ++i)
    {
        mPoints[i].position += dVvert;
        
        if (mPoints[i].position.x < 0)
        {
            mPoints[i].position.x += mSize;
        }
        if (mPoints[i].position.x > mSize)
        {
            mPoints[i].position.x -= mSize;
        }
    }
    
    // Now rotate
    mRot += mSpin * dt.asSeconds();
    if ( mRot < -360 ) mRot += 360;
    if ( mRot > 360 ) mRot -= 360;
    setRotation(mRot);
    
    // Adjust position
    setPosition(mHalfSize / 2.0, mHalfSize / 2.0);
}
Esempio n. 3
0
/* Create our GC's to draw colored lines and such */
struct Colors *
setGCs(Drawable d)
{
	struct Colors *colors;
	XGCValues gcv;
	unsigned long origColor;
	char dashList[2] = {3, 1};

	colors = malloc(sizeof(struct Colors));
	if (colors == NULL)
		return NULL;

	/* Get the GC-values of the default GC */
	XGetGCValues(DADisplay, DAGC,
		     GCForeground | GCBackground | GCGraphicsExposures, &gcv);

	origColor = gcv.foreground;

	/* don't send expose events */
	gcv.graphics_exposures = False;

	/* GC for white color */
	gcv.foreground = WhitePixel(DADisplay, DefaultScreen(DADisplay));
	colors->white = XCreateGC(DADisplay, d,
				  GCForeground | GCGraphicsExposures, &gcv);

	/* GC for dark blue color */
#if 1
	gcv.foreground = DAGetColor("navy");
#else
	gcv.foreground = 0;
#endif
	colors->black = XCreateGC(DADisplay, d,
				  GCForeground | GCGraphicsExposures, &gcv);

	/* GC for light borders */
	gcv.foreground = DAGetColor("lightGray");
	colors->lightGray = XCreateGC(DADisplay, d,
				      GCForeground | GCGraphicsExposures, &gcv);

	/* GC for dark borders (note re-use of gcv-values) */
	gcv.foreground = DAGetColor("#222222");
	colors->darkGray =  XCreateGC(DADisplay, d,
				      GCForeground | GCGraphicsExposures, &gcv);

	/* GC for the un-/highlighted colors and dashed line of the slider */
	gcv.foreground = origColor;
	gcv.line_width = 9;
	gcv.line_style = LineOnOffDash;

	colors->slider = XCreateGC(DADisplay, d,
				   GCForeground | GCBackground | GCGraphicsExposures |
				   GCLineWidth | GCLineStyle, &gcv);

	XSetDashes(DADisplay, colors->slider, 1, dashList, 2);

	/* light slider GC */
	gcv.foreground = adjustColor(origColor, +0x40);

	colors->sliderLight = XCreateGC(DADisplay, d,
					GCForeground | GCBackground | GCGraphicsExposures |
					GCLineWidth | GCLineStyle, &gcv);

	XSetDashes(DADisplay, colors->sliderLight, 1, dashList, 2);

	/* dark slider GC */
	gcv.foreground = adjustColor(origColor, -0x40);

	colors->sliderDark = XCreateGC(DADisplay, d,
				       GCForeground | GCBackground | GCGraphicsExposures |
				       GCLineWidth | GCLineStyle, &gcv);

	XSetDashes(DADisplay, colors->sliderDark, 1, dashList, 2);

	return colors;
}