예제 #1
0
void drawSkeleton( nite::UserTrackerFrameRef& userFrame,
                   nite::UserTracker& userTracker,
                   cv::Mat& image)
{
    const nite::Array<nite::UserData>& users = userFrame.getUsers();
    for ( int i = 0; i < users.getSize(); ++i ) {
        const nite::UserData& user = users[i];
        if ( user.isNew() ) {
            userTracker.startSkeletonTracking( user.getId() );
            userTracker.startPoseDetection( user.getId(), nite::POSE_PSI);
            userTracker.startPoseDetection( user.getId(), nite::POSE_CROSSED_HANDS);
        }
        else if ( !user.isLost() ) {
            // skeletonの表示
            const auto skeleton = user.getSkeleton();
            if ( skeleton.getState() == nite::SkeletonState::SKELETON_TRACKED ) {
                for ( int j = 0; j < 15; j++ ) {
                    const auto joint = skeleton.getJoint((nite::JointType)j);
                    if ( joint.getPositionConfidence() >= 0.7f ) {
                        const auto position = joint.getPosition();
                        float x = 0, y = 0;
                        userTracker.convertJointCoordinatesToDepth(
                            position.x, position.y, position.z, &x, &y );

                        cv::circle( image, cvPoint( (int)x, (int)y ),
                            3, cv::Scalar( 0, 0, 255 ), 5 );
                    }
                }
            }
            // poseの表示
            const auto pose_psi = user.getPose(nite::POSE_PSI);
            if( pose_psi.isHeld() || pose_psi.isEntered() )
            {
                auto center = user.getCenterOfMass();
                float x = 0, y = 0;
                userTracker.convertJointCoordinatesToDepth(center.x, center.y, center.z, &x, &y);
                cv::putText(image, "PSI", cv::Point2f(x,y), cv::FONT_HERSHEY_SIMPLEX, 2, cv::Scalar(0xFF,0xFF,0xFF));
            }
            const auto pose_cross = user.getPose(nite::POSE_CROSSED_HANDS);
            if( pose_cross.isHeld() || pose_cross.isEntered() ){
                auto center = user.getCenterOfMass();
                float x = 0, y = 0;
                userTracker.convertJointCoordinatesToDepth(center.x, center.y, center.z, &x, &y);
                cv::putText(image, "Cross", cv::Point2f(x,y), cv::FONT_HERSHEY_COMPLEX, 2, cv::Scalar(0xFF,0xFF,0xFF));
            }
        }
    }
}
예제 #2
0
	void SuperMushroom::Update(long gameTime)
	{
		Item::Update(gameTime);
		if(active)
		{
			if(finishTime<=Global::getWorldTime())
			{
				destroy();
			}
		}
		if(isHeld())
		{
			Player*playr = getPlayer();
			x = playr->x;
			y = playr->y;
		}
		else
		{
			if(moving)
			{
				switch(dir)
				{
					case Player::LEFT:
					x-=2;
					break;
					
					case Player::RIGHT:
					x+=2;
					break;
				}
			}
		}
	}
예제 #3
0
	void SmashBall::whilePlatformColliding(Platform*collide, byte dir)
	{
		if(!isHeld())
		{
			setDirection(dir,speed);
		}
	}
예제 #4
0
bool InputHandler::isPressed(InputHandler::t_buttonNum button, t_joyNum joyNum)
{
	if (!wasPressed(button, joyNum) && isHeld(button, joyNum))
	{
		return true;
	}
	else
		return false;
}
    bool PlayerInputHeroActionController::shouldChargeWeapon() const {
        if(!input.expired()) {
            auto in = input.lock();

            if(in) {
                return in->isHeld(Input::BUTTON_SHOOT);
            }
        }
        return false;
    }
예제 #6
0
	void BeamSword::onPlayerHit(Player*collide, byte dir)
	{
		if(isHeld())
		{
		    if(attackDir==ATTACK_NORMAL)
		    {
		    	causeDamage(collide,2);
		    	switch(getPlayer()->getPlayerDir())
		    	{
					case Player::LEFT:
		    		causeHurtLaunch(collide, -1,2,3, -1,1,2);
		    		causeHurt(collide, Player::RIGHT, 3);
		    		break;
		    		
					case Player::RIGHT:
		    		causeHurtLaunch(collide, 1,2,3, -1,1,2);
		    		causeHurt(collide, Player::LEFT, 3);
		    		break;
		    	}
		    }
		    else if(attackDir==ATTACK_SIDE)
		    {
		    	causeDamage(collide,3);
		    	switch(getPlayer()->getPlayerDir())
		    	{
					case Player::LEFT:
		    		causeHurtLaunch(collide, -1,3,3.5f, -1,2,2.3f);
		    		causeHurt(collide, Player::RIGHT, 3);
		    		break;
		    		
					case Player::RIGHT:
		    		causeHurtLaunch(collide, 1,3,3.5f, -1,2,2.3f);
		    		causeHurt(collide, Player::LEFT, 3);
		    		break;
		    	}
		    }
		    else if(attackDir==ATTACK_SMASH)
		    {
		    	causeDamage(collide,smashPower);
		    	switch(getPlayer()->getPlayerDir())
		    	{
					case Player::LEFT:
		    		causeHurtLaunch(collide, -1,2+((float)smashPower/4),2.1f, -1,2+((float)smashPower/4),2.6f);
		    		causeHurt(collide, Player::RIGHT, 4);
		    		break;
		    		
					case Player::RIGHT:
		    		causeHurtLaunch(collide, 1,2+((float)smashPower/4),2.1f, -1,2+((float)smashPower/4),2.6f);
		    		causeHurt(collide, Player::LEFT, 4);
		    		break;
		    	}
		    }
	    }
	}
예제 #7
0
NEVER_INLINE void LockBase::lockSlow()
{
    unsigned spinCount = 0;

    // This magic number turns out to be optimal based on past JikesRVM experiments.
    const unsigned spinLimit = 40;
    
    for (;;) {
        uint8_t currentByteValue = m_byte.load();
        if (verbose)
            dataLog(toString(currentThread(), ": locking with ", currentByteValue, "\n"));

        // We allow ourselves to barge in.
        if (!(currentByteValue & isHeldBit)
            && m_byte.compareExchangeWeak(currentByteValue, currentByteValue | isHeldBit))
            return;

        // If there is nobody parked and we haven't spun too much, we can just try to spin around.
        if (!(currentByteValue & hasParkedBit) && spinCount < spinLimit) {
            spinCount++;
            std::this_thread::yield();
            continue;
        }

        // Need to park. We do this by setting the parked bit first, and then parking. We spin around
        // if the parked bit wasn't set and we failed at setting it.
        if (!(currentByteValue & hasParkedBit)
            && !m_byte.compareExchangeWeak(currentByteValue, currentByteValue | hasParkedBit))
            continue;

        // We now expect the value to be isHeld|hasParked. So long as that's the case, we can park.
        ParkingLot::ParkResult parkResult =
            ParkingLot::compareAndPark(&m_byte, isHeldBit | hasParkedBit);
        if (parkResult.wasUnparked) {
            switch (static_cast<Token>(parkResult.token)) {
            case DirectHandoff:
                // The lock was never released. It was handed to us directly by the thread that did
                // unlock(). This means we're done!
                RELEASE_ASSERT(isHeld());
                return;
            case BargingOpportunity:
                // This is the common case. The thread that called unlock() has released the lock,
                // and we have been woken up so that we may get an opportunity to grab the lock. But
                // other threads may barge, so the best that we can do is loop around and try again.
                break;
            }
        }

        // We have awoken, or we never parked because the byte value changed. Either way, we loop
        // around and try again.
    }
}
예제 #8
0
파일: RayGun.cpp 프로젝트: 3Xpedite/iSSB
	void RayGun::Update(long gameTime)
	{
		Item::Update(gameTime);
		
		if(isHeld())
		{
			if(activeTime<=Global::getWorldTime())
			{
				active = false;
			}
			Player*playr = getPlayer();
			if(active)
			{
				switch(playr->getPlayerDir())
				{
					case Player::LEFT:
					changeAnimation("left",FORWARD);
					break;
					
					case Player::RIGHT:
					changeAnimation("right",FORWARD);
					break;
				}
			}
			else
			{
				switch(playr->getPlayerDir())
				{
					case Player::LEFT:
					changeAnimation("down_left",FORWARD);
					break;
					
					case Player::RIGHT:
					changeAnimation("down_right",FORWARD);
					break;
				}
			}
		}
		else
		{
			switch(dir)
			{
				case Player::LEFT:
				changeAnimation("left",FORWARD);
				break;
				
				case Player::RIGHT:
				changeAnimation("right",FORWARD);
				break;
			}
		}
	}
예제 #9
0
	void SmashBall::Draw(Graphics2D&g, long gameTime)
	{
		if(isHeld() && readyFire!=null)
		{
			Player*owner = Global::getPlayerActor(getItemHolder());
			readyFire->x = owner->x;
			readyFire->y = owner->y;
			x = 0;
			y = 0;
		}
		else
		{
			Item::Draw(g, gameTime);
		}
	}
예제 #10
0
	void BeamSword::Update(long gameTime)
	{
		Item::Update(gameTime);
		if(active)
		{
			if(isHeld())
			{
				setHitState(true);
				setHoldOffset(0, 0);
			}
		}
		else
		{
			setHitState(false);
			if(isHeld())
			{
				Player*playr = getPlayer();
				switch(playr->getPlayerDir())
				{
					case Player::LEFT:
					changeAnimation("carry_left",FORWARD);
					break;
					
					case Player::RIGHT:
					changeAnimation("carry_right",FORWARD);
					break;
				}
				setHoldOffset(4,-4);
			}
			else
			{
				active = false;
				changeAnimation("normal",FORWARD);
			}
		}
	}
예제 #11
0
void InputHandler::update()
{
	for (int j = 0; j < m_maxPlayers; j++)
	{
		for (int i = 0; i < m_buttonsPressed[j].size(); i++)
		{
			t_buttonNum button = m_buttonsPressed[j][i].first;
			bool isHeldB = isHeld(button, j);
			if (!isHeldB)
			{
				//cout << "kjdsh'vi" << endl;
			}

			m_buttonsPressed[j][i] = std::pair<t_buttonNum, bool>(button, isHeldB);
		}
	}
}
예제 #12
0
	void SmashBall::Update(long gameTime)
	{
		if(isHeld())
		{
			//
		}
		else
		{
			if(!hittable)
			{
				if(unHittableTime <= Global::getWorldTime())
				{
					hittable = true;
				}
			}
			if(moveTime <= Global::getWorldTime())
			{
				setDirection();
			    
			    moveTime = Global::getWorldTime() + 1000;
			}
			
			Rectangle borders = Global::currentStage->getItemBoundaries();
			
			if(x < borders.x)
			{
				xvelocity = speed;
			}
			else if(x > (borders.x + borders.width))
			{
				xvelocity = -speed;
			}
			
			if(y < borders.y)
			{
				yvelocity = speed;
			}
			else if(y > (borders.y + borders.height))
			{
				yvelocity = -speed;
			}
		}
		Item::Update(gameTime);
	}
예제 #13
0
	void SmashBall::whilePlayerColliding(Player*collide)
	{
		byte dir = getDir(collide,this);
		if(isHeld())
		{
			setDirection(dir,speed);
		}
		else
		{
			if(collide->getAttacksPriority()>0 && hittable)
			{
				hittable = false;
				unHittableTime = Global::getWorldTime() + 300;
				setDirection(dir,2*speed);
				hitSmashBall(collide,dir);
			}
			else
			{
				setDirection(dir,speed);
			}
		}
	}
예제 #14
0
static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config)
{
	if(wpadNeedScan){ WPAD_ScanPads(); wpadNeedScan = 0; }
	WPADData* wpad = WPAD_Data(Control);
	BUTTONS* c = Keys;
	memset(c, 0, sizeof(BUTTONS));
	//Reset buttons & sticks
	c->btns.All = 0xFFFF;
	c->leftStickX = c->leftStickY = c->rightStickX = c->rightStickY = 128;

	// Only use a connected classic controller
	if(!available(Control))
		return 0;

	unsigned int b = getButtons(&wpad->exp.classic);
	inline int isHeld(button_tp button){
		return (b & button->mask) == button->mask ? 0 : 1;
	}
	
	c->btns.SQUARE_BUTTON    = isHeld(config->SQU);
	c->btns.CROSS_BUTTON     = isHeld(config->CRO);
	c->btns.CIRCLE_BUTTON    = isHeld(config->CIR);
	c->btns.TRIANGLE_BUTTON  = isHeld(config->TRI);

	c->btns.R1_BUTTON    = isHeld(config->R1);
	c->btns.L1_BUTTON    = isHeld(config->L1);
	c->btns.R2_BUTTON    = isHeld(config->R2);
	c->btns.L2_BUTTON    = isHeld(config->L2);

	c->btns.L_DPAD       = isHeld(config->DL);
	c->btns.R_DPAD       = isHeld(config->DR);
	c->btns.U_DPAD       = isHeld(config->DU);
	c->btns.D_DPAD       = isHeld(config->DD);

	c->btns.START_BUTTON  = isHeld(config->START);
	c->btns.R3_BUTTON    = isHeld(config->R3);
	c->btns.L3_BUTTON    = isHeld(config->L3);
	c->btns.SELECT_BUTTON = isHeld(config->SELECT);

	//adjust values by 128 cause PSX sticks range 0-255 with a 128 center pos
	s8 stickX = 0;
	s8 stickY = 0;
	if(config->analogL->mask == L_STICK_AS_ANALOG){
		stickX = getStickValue(&wpad->exp.classic.ljs, STICK_X, 127);
		stickY = getStickValue(&wpad->exp.classic.ljs, STICK_Y, 127);
	} else if(config->analogL->mask == R_STICK_AS_ANALOG){
		stickX = getStickValue(&wpad->exp.classic.rjs, STICK_X, 127);
		stickY = getStickValue(&wpad->exp.classic.rjs, STICK_Y, 127);
	}
	c->leftStickX  = (u8)(stickX+127) & 0xFF;
	if(config->invertedYL)	c->leftStickY = (u8)(stickY+127) & 0xFF;
	else					c->leftStickY = (u8)(-stickY+127) & 0xFF;

	if(config->analogR->mask == L_STICK_AS_ANALOG){
		stickX = getStickValue(&wpad->exp.classic.ljs, STICK_X, 127);
		stickY = getStickValue(&wpad->exp.classic.ljs, STICK_Y, 127);
	} else if(config->analogR->mask == R_STICK_AS_ANALOG){
		stickX = getStickValue(&wpad->exp.classic.rjs, STICK_X, 127);
		stickY = getStickValue(&wpad->exp.classic.rjs, STICK_Y, 127);
	}
	c->rightStickX  = (u8)(stickX+127) & 0xFF;
	if(config->invertedYR)	c->rightStickY = (u8)(stickY+127) & 0xFF;
	else					c->rightStickY = (u8)(-stickY+127) & 0xFF;

	// Return 1 if whether the exit button(s) are pressed
	return isHeld(config->exit) ? 0 : 1;
}
예제 #15
0
bool InputHandler::isReleased(InputHandler::t_buttonNum button, t_joyNum joyNum)
{
	bool isHeldB = isHeld(button, joyNum);
	return !isHeldB;
}
예제 #16
0
static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config,
                    int (*available)(int),
                    unsigned int (*getButtons)(WPADData*))
{
	if(wpadNeedScan){ WPAD_ScanPads(); wpadNeedScan = 0; }
	WPADData* wpad = WPAD_Data(Control);
	BUTTONS* c = Keys;
	memset(c, 0, sizeof(BUTTONS));
	//Reset buttons & sticks
	c->btns.All = 0xFFFF;
	c->leftStickX = c->leftStickY = c->rightStickX = c->rightStickY = 128;

	// Only use a connected nunchuck controller
	if(!available(Control))
		return 0;

	unsigned int b = getButtons(wpad);
	inline int isHeld(button_tp button){
		return (b & button->mask) == button->mask ? 0 : 1;
	}
	
	c->btns.SQUARE_BUTTON    = isHeld(config->SQU);
	c->btns.CROSS_BUTTON     = isHeld(config->CRO);
	c->btns.CIRCLE_BUTTON    = isHeld(config->CIR);
	c->btns.TRIANGLE_BUTTON  = isHeld(config->TRI);

	c->btns.R1_BUTTON    = isHeld(config->R1);
	c->btns.L1_BUTTON    = isHeld(config->L1);
	c->btns.R2_BUTTON    = isHeld(config->R2);
	c->btns.L2_BUTTON    = isHeld(config->L2);

	c->btns.L_DPAD       = isHeld(config->DL);
	c->btns.R_DPAD       = isHeld(config->DR);
	c->btns.U_DPAD       = isHeld(config->DU);
	c->btns.D_DPAD       = isHeld(config->DD);

	c->btns.START_BUTTON  = isHeld(config->START);
	c->btns.R3_BUTTON    = isHeld(config->R3);
	c->btns.L3_BUTTON    = isHeld(config->L3);
	c->btns.SELECT_BUTTON = isHeld(config->SELECT);

	//adjust values by 128 cause PSX sticks range 0-255 with a 128 center pos
	s8 stickX = 0;
	s8 stickY = 0;
	if(config->analogL->mask == NUNCHUK_AS_ANALOG){
		stickX = getStickValue(&wpad->exp.nunchuk.js, STICK_X, 127);
		stickY = getStickValue(&wpad->exp.nunchuk.js, STICK_Y, 127);
	} else if(config->analogL->mask == IR_AS_ANALOG){
		if(wpad->ir.smooth_valid){
			stickX = ((short)(wpad->ir.sx - 512)) >> 2;
			stickY = -(signed char)((wpad->ir.sy - 384) / 3);
		} else {
예제 #17
0
static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config)
{
    if(padNeedScan) {
        gc_connected = PAD_ScanPads();
        padNeedScan = 0;
    }
    BUTTONS* c = Keys;
    memset(c, 0, sizeof(BUTTONS));
    //Reset buttons & sticks
    c->btns.All = 0xFFFF;
    c->leftStickX = c->leftStickY = c->rightStickX = c->rightStickY = 128;

    controller_GC.available[Control] = (gc_connected & (1<<Control)) ? 1 : 0;
    if (!controller_GC.available[Control]) return 0;

    unsigned int b = getButtons(Control);
    inline int isHeld(button_tp button) {
        return (b & button->mask) == button->mask ? 0 : 1;
    }

    c->btns.SQUARE_BUTTON    = isHeld(config->SQU);
    c->btns.CROSS_BUTTON     = isHeld(config->CRO);
    c->btns.CIRCLE_BUTTON    = isHeld(config->CIR);
    c->btns.TRIANGLE_BUTTON  = isHeld(config->TRI);

    c->btns.R1_BUTTON    = isHeld(config->R1);
    c->btns.L1_BUTTON    = isHeld(config->L1);
    c->btns.R2_BUTTON    = isHeld(config->R2);
    c->btns.L2_BUTTON    = isHeld(config->L2);

    c->btns.L_DPAD       = isHeld(config->DL);
    c->btns.R_DPAD       = isHeld(config->DR);
    c->btns.U_DPAD       = isHeld(config->DU);
    c->btns.D_DPAD       = isHeld(config->DD);

    c->btns.START_BUTTON  = isHeld(config->START);
    c->btns.R3_BUTTON    = isHeld(config->R3);
    c->btns.L3_BUTTON    = isHeld(config->L3);
    c->btns.SELECT_BUTTON = isHeld(config->SELECT);

    //adjust values by 128 cause PSX sticks range 0-255 with a 128 center pos
    int stickX = 0, stickY = 0;
    if(config->analogL->mask == ANALOG_AS_ANALOG) {
        stickX = PAD_StickX(Control);
        stickY = PAD_StickY(Control);
    } else if(config->analogL->mask == C_STICK_AS_ANALOG) {
        stickX = PAD_SubStickX(Control);
        stickY = PAD_SubStickY(Control);
    }
    c->leftStickX = GCtoPSXAnalog(stickX);
    c->leftStickY = GCtoPSXAnalog(config->invertedYL ? stickY : -stickY);

    if(config->analogR->mask == ANALOG_AS_ANALOG) {
        stickX = PAD_StickX(Control);
        stickY = PAD_StickY(Control);
    } else if(config->analogR->mask == C_STICK_AS_ANALOG) {
        stickX = PAD_SubStickX(Control);
        stickY = PAD_SubStickY(Control);
    }
    c->rightStickX = GCtoPSXAnalog(stickX);
    c->rightStickY = GCtoPSXAnalog(config->invertedYR ? stickY : -stickY);

    // Return 1 if whether the exit button(s) are pressed
    return isHeld(config->exit) ? 0 : 1;
}
예제 #18
0
static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config,
                    int (*available)(int),
                    unsigned int (*getButtons)(WPADData*))
{
	WPADData* wpad = WPAD_Data(Control);
	BUTTONS* c = Keys;
	memset(c, 0, sizeof(BUTTONS));

	// Only use a connected nunchuck controller
	if(!available(Control))
		return 0;

	WPAD_ReadPending(Control, NULL);

	unsigned int b = getButtons(wpad);
	inline int isHeld(button_tp button){
		return (b & button->mask) == button->mask;
	}
	
	c->R_DPAD       = isHeld(config->DR);
	c->L_DPAD       = isHeld(config->DL);
	c->D_DPAD       = isHeld(config->DD);
	c->U_DPAD       = isHeld(config->DU);
	
	c->START_BUTTON = isHeld(config->START);
	c->B_BUTTON     = isHeld(config->B);
	c->A_BUTTON     = isHeld(config->A);

	c->Z_TRIG       = isHeld(config->Z);
	c->R_TRIG       = isHeld(config->R);
	c->L_TRIG       = isHeld(config->L);

	c->R_CBUTTON    = isHeld(config->CR);
	c->L_CBUTTON    = isHeld(config->CL);
	c->D_CBUTTON    = isHeld(config->CD);
	c->U_CBUTTON    = isHeld(config->CU);

	if(config->analog->mask == NUNCHUK_AS_ANALOG){
		c->X_AXIS = getStickValue(&wpad->exp.nunchuk.js, STICK_X, 128);
		c->Y_AXIS = getStickValue(&wpad->exp.nunchuk.js, STICK_Y, 128);
	} else if(config->analog->mask == IR_AS_ANALOG){
		if(wpad->ir.smooth_valid){
			c->X_AXIS = ((short)(wpad->ir.sx - 512)) >> 2;
			c->Y_AXIS = -(signed char)((wpad->ir.sy - 384) / 3);
		} else {