Example #1
0
void Gib::draw(Graphics::Bitmap * work, int rel_x, int rel_y){
    if (fade > 0){
        // Bitmap::dissolveBlender( 0, 0, 0, 255 - fade );
        Graphics::Bitmap::transBlender(0, 0, 0, 255 - fade);
        image.translucent().draw(getRX() - rel_x - image.getWidth() / 2, getRY() - image.getHeight() / 2, *work);
    } else {
        // Graphics::Bitmap::transBlender(0, 0, 0, 200);
        /* hack to make sure bloodImage gets converted to a video bitmap */
        bloodImage->draw(-999999, 999999, *work);
        work->startDrawing();
        for (std::vector< Point >::iterator it = blood.begin(); it != blood.end(); it++){
            const Point & p = *it;

            // bloodImage->translucent().draw(p.x - rel_x, p.y, *work);
            bloodImage->draw(p.x - rel_x - bloodImage->getWidth() / 2, p.y - bloodImage->getHeight() / 2, *work);
            /*
            int l = 200 + p.life * 15;
            Graphics::Color red = Graphics::makeColor(l > 255 ? 255 : l, 0, 0);
            work->translucent().circleFill(p.x - rel_x, p.y, 1, red);
            */
            // work->putPixel( p.x - rel_x, p.y, red );
        }
        work->endDrawing();
        // image->draw( getRX() - rel_x - image->getWidth() / 2, getRY() - image->getHeight() / 2, *work );
        image.drawRotate(getRX() - rel_x - image.getWidth() / 2, getRY() - image.getHeight() / 2, angle, *work);
    }
}
Example #2
0
void Cat::draw( Graphics::Bitmap * work, int rel_x, int rel_y ){
    if ( getFacing() == Object::FACING_RIGHT ){
        current_animation->Draw(getRX() - rel_x, getRY(), NULL, work);
    } else {
        current_animation->DrawFlipped(getRX() - rel_x, getRY(), NULL, work); 
    }

    if (Util::rnd(2000) == 0){
        int distance = 1000 - fabs((double)getRX() - rel_x) / 2;
        double volume = distance < 0 ? 0.1 : (double) distance / 1000.0;
        int pan = 128 + (getRX() - rel_x) / 50;
        meow.play(volume, pan);
    }
}
//==============================================================================
void EntityPlayer::onRender(double interpolation) {	
	//---------Reset
	//glLoadIdentity();
	//---------Move World Coordinates to Player Location	
	rX = getRX(interpolation);
	rY = getRY(interpolation);
	rDir = direction;
	//---------stateRotation Interpolation
	if(stateRotation[ROTATE_LEFT]){
		rDir = direction + turnSpeed*interpolation;
	}
	if(stateRotation[ROTATE_RIGHT]){
		rDir = direction - turnSpeed*interpolation;
	}	
	//---------Translate to interpolated location
	glTranslatef(rX,rY,0.0f);
	//---------Texture
	//Facing Right
	if((rDir < 45) || (rDir > 315)) {currentFrame = 2;}
	//Facing Back
	if((rDir < 135) && (rDir > 45)) {currentFrame = 3;}
	//Facing Left
	if((rDir < 225) && (rDir > 135)) {currentFrame = 1;}
	//Facing Front
	if((rDir < 315) && (rDir > 225)) {currentFrame = 0;}
	
	//Bind Texture
	glBindTexture(GL_TEXTURE_2D, texID[currentFrame]);	
	//---------Reset Texture Matrix
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	//---------Rotate texture according to rDir
	//glTranslatef(0.5,0.5,0.0);
	//glRotatef(rDir-90,0.0,0.0,1.0);
	//glTranslatef(-0.5,-0.5,0.0);
	//---------Draw Model
	glMatrixMode(GL_MODELVIEW); 
	//---------
	glBegin(GL_POLYGON);
		for(int a = 0; a < numVertices; a++) {		
			glTexCoord2f(0.5f+(vertices[a].x/width),0.5f+(vertices[a].y/height));
			glVertex3f(vertices[a].x,vertices[a].y,0.0f);
		}	
	glEnd();
	//--------
	glTranslatef(-rX,-rY,0.0f);
}
Example #4
0
void Gib::act(std::vector< Object * > * others, World * world, std::vector< Object * > * add){
    if (fade > 0){
        fade += 2;
        if (fade > 255){
            setHealth(-1);
        }
    } else {

        moveX(dx);
        moveY(dy);
        moveZ(dz);

        dy -= 0.1;
        if ( getY() <= 0 ){
            dy = -dy / 2;
            dx = dx / 2;
            dz = dz / 2;
            if ( fade == 0 && fabs( dy ) < 0.1 ){
                fade = 1;
            }
        }

        double gibAmount = Configuration::getProperty(GibProperty, 5) / 5.0;
        for (int i = 0; i < Util::rnd((int)(2 * gibAmount)) + 2; i++){
            int x = getRX() + Util::rnd(5) - 2;
            int y = getRY() + Util::rnd(5) - 2;
            blood.push_back(Point(x, y, Util::rnd(10) + 5));
        }

        for (std::vector< Point >::iterator it = blood.begin(); it != blood.end(); /**/){
            Point & p = *it;
            p.life -= 1;
            if (p.life <= 0){
                it = blood.erase(it);
            } else {
                it++;
            }
        }

        angle += (int) sqrt(dx * dx + dy * dy) * 3;
    }
}
void TJoystick::update(float dt) {
	if (IsConnected()) {
		old_rx = rx;
		old_ry = ry;

		// Left and right stick axis values
		lx = GetState().Gamepad.sThumbLX;
		ly = GetState().Gamepad.sThumbLY;
		rx = GetState().Gamepad.sThumbRX;
		ry = GetState().Gamepad.sThumbRY;
		// Right stick delta values
		drx = (rx - old_rx) / right_stick_x_sensibility;
		dry = (ry - old_ry) / right_stick_y_sensibility;
		// Button state
		button_A.setCurrentStatus((GetState().Gamepad.wButtons & XINPUT_GAMEPAD_A) != 0);
		button_A.update(dt);
		button_B.setCurrentStatus((GetState().Gamepad.wButtons & XINPUT_GAMEPAD_B) != 0);
		button_B.update(dt);
		button_X.setCurrentStatus((GetState().Gamepad.wButtons & XINPUT_GAMEPAD_X) != 0);
		button_X.update(dt);
		button_Y.setCurrentStatus((GetState().Gamepad.wButtons & XINPUT_GAMEPAD_Y) != 0);
		button_Y.update(dt);
		button_R.setCurrentStatus((GetState().Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) != 0);
		button_R.update(dt);
		button_L.setCurrentStatus((GetState().Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) != 0);
		button_L.update(dt);
		button_START.setCurrentStatus((GetState().Gamepad.wButtons & XINPUT_GAMEPAD_START) != 0);
		button_START.update(dt);
		button_BACK.setCurrentStatus((GetState().Gamepad.wButtons & XINPUT_GAMEPAD_BACK) != 0);
		button_BACK.update(dt);
		// Trigger values
		button_LT = GetState().Gamepad.bLeftTrigger;
		button_RT = GetState().Gamepad.bRightTrigger;

		//Stick pulsation
		lstick.update(getLX(), getLY(), dt);
		rstick.update(getRX(), getRY(), dt);
	}
}
Example #6
0
Point::Point(float x, float y)
{
	x_ = x == 0 ? getRX() : x;
	y_ = y == 0 ? getRY() : y;
}