예제 #1
0
파일: paddle.cpp 프로젝트: treewojima/game
Paddle::Paddle(const b2Vec2 &position, std::shared_ptr<Walls> walls) :
    Entity("Paddle", Type::PADDLE),
    _body(nullptr),
    _fixture(nullptr)
{
    // First, create the body itself
    b2BodyDef bodyDef;
    bodyDef.position = position;
    bodyDef.linearDamping = 4;
    bodyDef.type = b2_dynamicBody;
    bodyDef.userData = this;
    _body = Physics::createBody(bodyDef);

    // Now create the body fixture
    b2PolygonShape box;
    box.SetAsBox(DIMENSIONS.x / 2, DIMENSIONS.y / 2);
    b2FixtureDef fixtureDef;
    fixtureDef.shape = &box;
    fixtureDef.density = 1;
    fixtureDef.friction = 0.05;
    fixtureDef.restitution = 0;
    fixtureDef.filter.categoryBits = getType();
    fixtureDef.filter.maskBits = Type::BARRIER | Type::BALL | Type::CURSOR;
    _fixture = _body->CreateFixture(&fixtureDef);

    // Set up a prismatic joint to restrict movement
    b2PrismaticJointDef jointDef;
    jointDef.Initialize(_body, walls->_body, position, b2Vec2(1, 0));
    jointDef.collideConnected = true;
    Physics::getWorld().CreateJoint(&jointDef);

    // Finally, set up keyboard control events
    registerEvents();
}
예제 #2
0
KeyMonitor::KeyMonitor(QObject* parent)
: QObject(parent),
  m_modifiers(Qt::NoModifier)
{
    if (registerEvents()) {
        getModifiers();
    }
}
예제 #3
0
void CloseIisuServer::setup() 
{
	// We need to specify where is located the iisu dll and it's configuration file.
	// in this sample we'll use the SDK's environment variable.

	string dllLocation = getenv("IISU_SDK_DIR") ;
	dllLocation+="/bin" ;

	// get the working context
	Context& context = Context::Instance();

	// create an iisu configuration
	IisuHandle::Configuration iisuConfiguration(dllLocation.c_str(),"iisu_config.xml");
	// you can customize the configuration here
	
	// create the handle according to the configuration structure
	Return<IisuHandle*> retHandle = context.createHandle(iisuConfiguration);
	if(retHandle.failed())
	{
		cerr << "Failed to get iisu handle!" << endl
			<< "Error " << retHandle.getErrorCode() << ": " << retHandle.getDescription().ptr() << endl;
		getchar();
		exit(0);
	}

	// get the iisu handle
	m_iisuHandle = retHandle.get();

	// create device configuration
	Device::Configuration deviceConfiguration ;
	// you can customize the configuration here

	// create the device according to the configuration structure
	Return<Device*> retDevice = m_iisuHandle->initializeDevice(deviceConfiguration);
	if(retDevice.failed())
	{
		cerr << "Failed to create device!" << endl
			<< "Error " << retDevice.getErrorCode() << ": " << retDevice.getDescription().ptr() << endl;
		getchar();
		exit(0);
	}

	// get the device
	m_device = retDevice.get();

	registerEvents() ; 
	initIisu() ; 

	SK::Result devStart = m_device->start();
	if(devStart.failed())
	{
		cerr << "Failed to start device!" << endl
			<< "Error " << devStart.getErrorCode() << ": " << devStart.getDescription().ptr() << endl;
		getchar();
		exit(0);
	}

}
예제 #4
0
void Mesh2Cloud::init() {
	//m_mesh->request_vertex_status();
	//m_mesh->request_face_status();
	//m_mesh->request_vertex_normals();
	//m_mesh->request_face_normals();
	SingleMesh::init();
	m_mesh->update_face_normals();
	MultiPointCloud::init();
	addProperties();
	registerEvents();
}
예제 #5
0
EditorManager::EditorManager(wxAuiNotebook* notebook)
: mEditorNotebook(notebook), mActiveEditor(NULL)
{
	registerEvents();

	if(mEditorNotebook != NULL)
	{
		Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler(EditorManager::OnPageChanged));
		Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEventHandler(EditorManager::OnPageClosed));

		mEditorNotebook->PushEventHandler(this);
	}
}
예제 #6
0
/**
 * Main workhorse function, starts up the server listening on a port and
 * loops over the libevent handler.
 */
void TNonblockingServer::serve() {

  registerEvents(NULL);

  // Run the primary (listener) IO thread loop in our main thread; this will
  // only return when the server is shutting down.
  ioThreads_[0]->run();

  // Ensure all threads are finished before exiting serve()
  for (uint32_t i = 0; i < ioThreads_.size(); ++i) {
    ioThreads_[i]->join();
    GlobalOutput.printf("TNonblocking: join done for IO thread #%d", i);
  }
}
예제 #7
0
int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::InitGoogleMock(&argc, argv);
    qRegisterMetaType<QModelIndex>("QModelIndex");
    SIM::createEventHub();
	SIM::setImageStorage(imagestorage);
    //SIM::setImageStorage(&imagestorage);
    SIM::createCommandHub();
    registerEvents();
    int ret = RUN_ALL_TESTS();
#ifdef WIN32
    getchar();
#endif
	return ret;
}
예제 #8
0
int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::InitGoogleMock(&argc, argv);
    SIM::createEventHub();
    StubObjects::StubImageStorage imagestorage;
    SIM::setImageStorage(&imagestorage);
    SIM::createCommandHub();
    SIM::createContactList();
    registerEvents();
    int ret = RUN_ALL_TESTS();
#ifdef WIN32
    getchar();
#endif
	return ret;
}
예제 #9
0
void TNonblockingIOThread::run() {
  if (eventBase_ == NULL)
    registerEvents();

  GlobalOutput.printf("TNonblockingServer: IO thread #%d entering loop...", number_);

  if (useHighPriority_) {
    setCurrentThreadHighPriority(true);
  }

  // Run libevent engine, never returns, invokes calls to eventHandler
  event_base_loop(eventBase_, 0);

  if (useHighPriority_) {
    setCurrentThreadHighPriority(false);
  }

  // cleans up our registered events
  cleanupEvents();

  GlobalOutput.printf("TNonblockingServer: IO thread #%d run() done!", number_);
}
void TNonblockingIOThread::run() {
  threadId_ = Thread::get_current();

  assert(eventBase_ == 0);
  eventBase_ = event_base_new();

  // Print some libevent stats
  if (number_ == 0) {
    GlobalOutput.printf("TNonblockingServer: using libevent %s method %s",
            event_get_version(),
            event_base_get_method(eventBase_));
  }


  registerEvents();

  GlobalOutput.printf("TNonblockingServer: IO thread #%d entering loop...",
                      number_);

  if (useHighPriority_) {
    setCurrentThreadHighPriority(true);
  }

  // Run libevent engine, never returns, invokes calls to eventHandler
  event_base_loop(eventBase_, 0);

  if (useHighPriority_) {
    setCurrentThreadHighPriority(false);
  }

  // cleans up our registered events
  cleanupEvents();

  GlobalOutput.printf("TNonblockingServer: IO thread #%d run() done!",
    number_);
}
예제 #11
0
TechniqueController::TechniqueController(Technique* technique)
: mParentController(NULL), mTechnique(technique)
{
	registerEvents();
}
예제 #12
0
TechniqueController::TechniqueController(MaterialController* parent, Technique* technique)
: mParentController(parent), mTechnique(technique)
{
	registerEvents();
}
예제 #13
0
Editor::Editor(EditorInput* input)
: mEditorInput(input)
{
	registerEvents();
}
예제 #14
0
RootEventPlugin::RootEventPlugin()
{
	registerEvents();
}
예제 #15
0
// Function Implementation //
TopMostWindowComponent::TopMostWindowComponent(const std::weak_ptr<IApp>& app) : Component(app)
{
	registerEvents();
}
예제 #16
0
Editor::Editor()
: mEditorInput(NULL), mName("Editor")
{
	registerEvents();
}
예제 #17
0
TextureUnitController::TextureUnitController(TextureUnitState* tus)
: mParentController(NULL), mTextureUnit(tus)
{
	registerEvents();
}
예제 #18
0
TextureUnitController::TextureUnitController(PassController* parent, TextureUnitState* tus)
: mParentController(parent), mTextureUnit(tus)
{
	registerEvents();
}
예제 #19
0
TextureUnitController::TextureUnitController()
: mParentController(NULL), mTextureUnit(NULL)
{
	registerEvents();
}
예제 #20
0
PassController::PassController(TechniqueController* parent, Pass* pass)
: mParentController(parent), mPass(pass)
{
	registerEvents();
}
예제 #21
0
MaterialController::MaterialController()
    : mMaterialPtr(NULL)
{
    registerEvents();
}
예제 #22
0
Workspace::Workspace()
{
	registerEvents();
}
예제 #23
0
MaterialController::MaterialController(MaterialPtr materialPtr)
    : mMaterialPtr(materialPtr)
{
    registerEvents();
}
예제 #24
0
SelectionService::SelectionService()
{
	registerEvents();
}
예제 #25
0
PassController::PassController(Pass* pass)
: mParentController(NULL), mPass(pass)
{
	registerEvents();
}