Exemplo n.º 1
0
Camera::Camera( ) {
	_to_pos = START_TO_POS;
	_before_mouse_pos = _to_pos;

	FrameworkPtr fw = Framework::getInstance( );
	fw->setCameraUp( Vector( 0.0, 0.0, 1.0 ) );
	fw->setCamera( _target + _to_pos, _target );
}
Exemplo n.º 2
0
void Drawer::drawBackground( ) {
	int ani = ( _ani_timer / ANI_FPS ) % 5;
	FrameworkPtr fw = Framework::getInstance( );
	//背景。
	DrawRectExtendGraph( 0,                     0, 
						 fw->getWindowWidth( ), fw->getWindowHeight( ), 
						 0,						0, 
						 BG_IMG_WIDTH,			BG_IMG_HEIGHT, 
						 _background_img,		TRUE );

	//海草
	//plz magic number delete
	DrawRectExtendGraph( 10,                  fw->getWindowHeight( ) - SEEWEED_HEIGHT, 
						 SEEWEED_WIDTH + 10,  fw->getWindowHeight( ), 
						 ani * SEEWEED_WIDTH, 0, 
						 SEEWEED_WIDTH,       SEEWEED_HEIGHT, 
						 _seeweed_img,        TRUE );
	DrawRectExtendGraph( 50,                  fw->getWindowHeight( ) - SEEWEED_HEIGHT, 
						 SEEWEED_WIDTH + 50,  fw->getWindowHeight( ), 
						 ani * SEEWEED_WIDTH, SEEWEED_HEIGHT,
						 SEEWEED_WIDTH,       SEEWEED_HEIGHT, 
						 _seeweed_img,        TRUE );
	DrawRectExtendGraph( 90,                  fw->getWindowHeight( ) - SEEWEED_HEIGHT, 
						 SEEWEED_WIDTH + 90,  fw->getWindowHeight( ), 
						 ani * SEEWEED_WIDTH, SEEWEED_HEIGHT * 2, 
						 SEEWEED_WIDTH,       SEEWEED_HEIGHT, 
						 _seeweed_img,        TRUE );
}
Exemplo n.º 3
0
PlayerFactory::PlayerFactory( const unsigned char player_id, CameraPtr camera ) {
	FrameworkPtr fw = Framework::getInstance ( );
	DevicePtr device = DevicePtr( new Device );
	KeyboardPtr keyboad = KeyboardPtr( new Keyboard );
	MousePtr mouse = MousePtr( new Mouse );
	ClientPtr client = ClientPtr( new Client );
	AppPtr app = AppPtr( new App( player_id )  );
	ViewerPtr viewer = ViewerPtr( new Viewer );
	DrawerPtr drawer = DrawerPtr( new Drawer( "../Resource" ) );
	SoundPtr sound = SoundPtr( new Sound( ) );
	if ( !camera ) {
		camera = PlayerCameraPtr( new PlayerCamera );
	}

	fw->addTask( Device::getTag( ), device );
	fw->addTask( Keyboard::getTag( ), keyboad );
	fw->addTask( Mouse::getTag( ), mouse );
	fw->addTask( Client::getTag( ), client );
	fw->addTask( Viewer::getTag( ), viewer );
	fw->addTask( Drawer::getTag( ), drawer );
	fw->addTask( App::getTag( ), app );
	fw->addTask( Camera::getTag( ), camera );
	fw->addTask( Sound::getTag( ), sound );
}
Exemplo n.º 4
0
AppServerPtr AppServer::getTask( ) {
	FrameworkPtr fw = Framework::getInstance( );
	return std::dynamic_pointer_cast< AppServer >( fw->getTask( AppServer::getTag( ) ) );
}
Exemplo n.º 5
0
ClientPtr Client::getTask( ) {
	FrameworkPtr fw = Framework::getInstance( );
	return std::dynamic_pointer_cast< Client >( fw->getTask( Client::getTag( ) ) );
}
Exemplo n.º 6
0
KeyboardPtr Keyboard::getTask( ) {
	FrameworkPtr fw = Framework::getInstance( );
	return std::dynamic_pointer_cast< Keyboard >( fw->getTask( Keyboard::getTag( ) ) );
}
Exemplo n.º 7
0
CameraPtr Camera::getTask( ) {
	FrameworkPtr fw = Framework::getInstance( );
	return std::dynamic_pointer_cast< Camera >( fw->getTask( getTag( ) ) );
}
Exemplo n.º 8
0
void Camera::update( ) {
	// マウスの左右でZ軸回転をするように
	FrameworkPtr fw = Framework::getInstance( );
	MousePtr mouse = Mouse::getTask( );
	KeyboardPtr keyboard = Keyboard::getTask( );

	Vector mouse_pos = mouse->getPos( );

	Vector diff = _before_mouse_pos - mouse_pos;
	_before_mouse_pos = mouse_pos;

	if ( diff.x != 0 ) {
		double angle = ( 10 * PI / 180 ) * diff.normalize( ).x;
		Matrix mat = Matrix::makeTransformRotation( Vector( 0, 0, 1 ), angle );
		_to_pos = mat.multiply( _to_pos );
	}

	if ( diff.y != 0 ) {
		Vector axis = _to_pos.cross( Vector( 0.0, 0.0, 1.0 ) );
		double angle = ( 5 * PI / 180 ) * diff.normalize( ).y;
		Matrix mat = Matrix::makeTransformRotation( axis, angle );
		_to_pos = mat.multiply( _to_pos );
	}

	int wheel = mouse->getWheelRotValue( );
	if ( wheel != 0 ) {
		double length = _to_pos.getLength( );
		length += wheel;
		if ( length < 10 ) {
			length = 10;
		}
		_to_pos = _to_pos.normalize( ) * length;
	}

	if ( keyboard->isPushKey( "ENTER" ) ) {
  		_to_pos = START_TO_POS;
	}

	Vector vec;
	if ( keyboard->isHoldKey( "ARROW_UP" ) ) {
		vec = _to_pos;
		vec.z = 0;
		vec *= -1;
	}

	if ( keyboard->isHoldKey( "ARROW_DOWN" ) ) {
		vec = _to_pos;
		vec.z = 0;
	}

	if ( keyboard->isHoldKey( "ARROW_LEFT" ) ) {
		vec = _to_pos;
		vec.z = 0;
		vec = _to_pos.cross( Vector( 0, 0, -1 ) );
	}
	
	if ( keyboard->isHoldKey( "ARROW_RIGHT" ) ) {
		vec = _to_pos;
		vec.z = 0;
		vec = _to_pos.cross( Vector( 0, 0, 1 ) );
	}
	

	_target += vec.normalize( ) * 0.1;

	fw->setCamera( _target + _to_pos, _target );
}
Exemplo n.º 9
0
DrawerPtr Drawer::getTask( ) {
	FrameworkPtr fw = Framework::getInstance( );
	return std::dynamic_pointer_cast< Drawer >( fw->getTask( Drawer::getTag( ) ) );
}