Ejemplo n.º 1
0
		virtual void getInputAt(int step, InputSource* left, InputSource* right)
		{
			assert( step  < mGameLength );

			// for now, we have only a linear sequence of InputPackets, so finding the right one is just
			// a matter of address arithmetics.

			// each packet has size 1 byte for now
			// so we find step at mReplayOffset + step
			char packet = mBuffer[mReplayOffset + step];

			// now read the packet data
			left->setInput(PlayerInput((bool)(packet & 32), (bool)(packet & 16), (bool)(packet & 8)));
			right->setInput(PlayerInput((bool)(packet & 4), (bool)(packet & 2), (bool)(packet & 1)));
		}
Ejemplo n.º 2
0
PlayerInput PlayerInputAbs::toPlayerInput( const DuelMatch* match ) const
{
	if( mFlags & F_RELATIVE)
		return PlayerInput( mFlags & F_LEFT, mFlags & F_RIGHT, mFlags & F_JUMP );
	else
	{
		bool left = false;
		bool right = false;

		PlayerSide side = mFlags & F_LEFT ? LEFT_PLAYER : RIGHT_PLAYER;

		// here we load the current position of the player.
		float blobpos = match->getBlobPosition(side).x;

		float distance = std::abs(blobpos - mTarget);

		if ( std::abs(blobpos + BLOBBY_SPEED - mTarget) < distance )
			right = true;
		else if (std::abs(blobpos - BLOBBY_SPEED - mTarget) < distance)
			left = true;
		return PlayerInput( left, right, mFlags & F_JUMP );
	}

}
Ejemplo n.º 3
0
int main(int argc, char *argv[]){
    state = STATE_GAME_LEVEL;
    
    ShaderProgram program = Setup();
    setupSound();
    
    done = false;
    while (!done) {
        PlayerInput(done, program);
        fixedTSUpdate(&program);
        Render(&program);
        glUseProgram(program.programID);
    }
    for (int i = 0; i < entities.size(); i++) {
        entities[i].~Entity();
    }
    for (int i = 0; i < menuEntities.size(); i++) {
        menuEntities[i].~Entity();
    }
    Mix_FreeChunk(pewpew);
    Mix_FreeMusic(music);
    SDL_Quit();
    return 0;
}