virtual void Init( bool isFirstInit )
	{
		if (isFirstInit)
		{
			CreateObjects();
		}
	}
Ejemplo n.º 2
0
void
Serialized::CreateObjects(const wxXmlNode& root)
{
	wxString uid;
	if (root.GetPropVal(wxT("uid"), &uid))
	{
		if (m_Objects.find(uid) == m_Objects.end())
		{
			wxString classname = root.GetName();
			std::map<wxString, Creator>::iterator it = m_Creators.find(classname);
			if (it == m_Creators.end())
			{
				THROW(TXT("Class \"%s\" not found."), root.GetName().c_str());
			}
			Serialized *obj = (it->second)(root);
			m_Objects.insert(std::pair<wxString, Serialized *>(uid, obj));
		}
	}
	wxXmlNode *child = root.GetChildren();
	while (child != NULL)
	{
		CreateObjects(*child);
		child = child->GetNext();
	}
}
Ejemplo n.º 3
0
void main (int argc, char *argv[])
{
    SUIT_init(argv[0]);
    CreateObjects();
    SUIT_createDoneButton(NULL);
    SUIT_beginStandardApplication();
}	
Ejemplo n.º 4
0
CGame::CGame (CStagePtr inStage, const std::string inAssetsPath) :
	mStage (inStage),
	mAssetsPath (inAssetsPath),
	mTypeCount (0),
	mDisableInputCount (0),
	mHasSelection (false),
	mIsSwapping (false),
	mSwapEndTicks (0),
	mIsDropping (false),
	mDropEndTicks (0),
	mIsExploding (false),
	mClipRect ({ sGridLeft, sGridTop, sGridColCount * sCellWidth, sGridRowCount * sCellHeight }),
	mGameRunning (false),
	mGameFinished (false),
	mGameEndTicks (0),
	mSoundFxFuse (0),
	mSoundFxExplosion (0),
	mFuseChannel (-1),
	mScore (0)
{
	mStage->SetBackground (mAssetsPath + "BackGround.jpg");

	CreateTextures();
	CreateObjects();

	LoadSoundFx();
}
Ejemplo n.º 5
0
void Level_2::Restart()
{
	//destroy objects
	player_.DestroyBody();
	blade_.DestroyBody();
	enemy_.DestroyBody();

	//destroy pickups
	for ( int pickupindex = 0; pickupindex < pickups_.size(); pickupindex++)
	{
		//reset for another play
		if(pickups_[pickupindex].dead == true)
		{
			pickups_[pickupindex].DestroyBody();
		}
	}

	//destroy plants
	for ( int plantindex = 0; plantindex < plants_.size(); plantindex++)
	{
		//reset for another play
		if(plants_[plantindex].dead == true)
		{
			plants_[plantindex].DestroyBody();
		}
	}

	score_ = 0;
	collectables_ = 0;

	//create new versions at starting position
	CreateObjects();

	gameOver_ = false;
}
/*ADD*/	
/*ADD*/	void CollisionFilteringDemo::InitializePhysics() {
/*ADD*/		// create the collision configuration
/*ADD*/		m_pCollisionConfiguration = new btDefaultCollisionConfiguration();
/*ADD*/		// create the dispatcher
/*ADD*/		m_pDispatcher = new btCollisionDispatcher(m_pCollisionConfiguration);
/*ADD*/		// create the broadphase
/*ADD*/		m_pBroadphase = new btDbvtBroadphase();
/*ADD*/		// create the constraint solver
/*ADD*/		m_pSolver = new btSequentialImpulseConstraintSolver();
/*ADD*/		// create the world
/*ADD*/		m_pWorld = new btDiscreteDynamicsWorld(m_pDispatcher, m_pBroadphase, m_pSolver, m_pCollisionConfiguration);
/*ADD*/		CreateObjects();
/*ADD*/	}
Ejemplo n.º 7
0
void System::DoTimeStep(){
	if(mNumCurrentSpheres<mNumSpheres&&mFrameNumber%600==0){
		//CreateObjects(10, 1, 10, 1, 1+mFrameNumber*3, 0, true, 0);
		//CreateObjects(10, 1, 10, 1, 2+mFrameNumber*3, 0, true, 1);
		CreateObjects(10, 10, 10, 1, 15, 0, false, 2);

	}
	mFrameNumber++;
	mSystem->DoStepDynamics( mTimeStep );
	mCurrentTime+=mTimeStep;
	if(mSystem->GetChTime()>=mEndTime){exit(0);}
	if(mSystem->GetNbodies()==0){exit(0);}
}
Ejemplo n.º 8
0
BOOL CUIGlobals::InitColorsAndTablesAndObjects(LPDICOLORSET lpDIColorSet)
{tracescope(__ts,_T("CUIGlobals::InitColorsAndTablesAndObjects()\n"));

	// init ui tables
	if (!InitTables())
	{
		etrace(_T("Could not initialize tables\n"));
		return FALSE;
	}

	// decide whether or not to use the passed colorset
	if (lpDIColorSet != NULL)
	{
		m_ColorSet = *lpDIColorSet;

		m_bUseColorSet = !IsZeroOrInvalidColorSet(m_ColorSet);
	}
	else
		m_bUseColorSet = FALSE;

	// use it, or use defaults
	if (m_bUseColorSet)
	{
		// transfer colors from passed colorset
		SetTableColor(UIC_TEXTFORE, D3DCOLOR2COLORREF(m_ColorSet.cTextFore));
		SetTableColor(UIC_TEXTHIGHLIGHT, D3DCOLOR2COLORREF(m_ColorSet.cTextHighlight));
		SetTableColor(UIC_CALLOUTLINE, D3DCOLOR2COLORREF(m_ColorSet.cCalloutLine));
		SetTableColor(UIC_CALLOUTHIGHLIGHT, D3DCOLOR2COLORREF(m_ColorSet.cCalloutHighlight));
		SetTableColor(UIC_BORDER, D3DCOLOR2COLORREF(m_ColorSet.cBorder));
		SetTableColor(UIC_CONTROLFILL, D3DCOLOR2COLORREF(m_ColorSet.cControlFill));
		SetTableColor(UIC_HIGHLIGHTFILL, D3DCOLOR2COLORREF(m_ColorSet.cHighlightFill));
		SetTableColor(UIC_AREAFILL, D3DCOLOR2COLORREF(m_ColorSet.cAreaFill));
	}
	else
	{
		// use default colors
		SetTableColor(UIC_TEXTFORE,				RGB(255, 255, 255));
		SetTableColor(UIC_TEXTHIGHLIGHT,		RGB(  0, 255,   0));
		SetTableColor(UIC_CALLOUTLINE,			RGB(255, 255, 255));
		SetTableColor(UIC_CALLOUTHIGHLIGHT,		RGB(  0, 255,   0));
		SetTableColor(UIC_BORDER,				RGB(255, 255,   0));
		SetTableColor(UIC_CONTROLFILL,			RGB(  0, 191,   0));
		SetTableColor(UIC_HIGHLIGHTFILL,		RGB(  0,   0,   0));
		SetTableColor(UIC_AREAFILL,				RGB(  0,   0,   0));
	}

	// create the table objects
	CreateObjects();

	return TRUE;
}
void BasicDemo::InitializePhysics() {
	// create the collision configuration
	m_pCollisionConfiguration = new btDefaultCollisionConfiguration();
	// create the dispatcher
	m_pDispatcher = new btCollisionDispatcher(m_pCollisionConfiguration);
	// create the broadphase
	m_pBroadphase = new btDbvtBroadphase();
	// create the constraint solver
	m_pSolver = new btSequentialImpulseConstraintSolver();
	// create the world
	m_pWorld = new btDiscreteDynamicsWorld(m_pDispatcher, m_pBroadphase, m_pSolver, m_pCollisionConfiguration);

	// create our scene's physics objects
	CreateObjects();
}
Ejemplo n.º 10
0
Serialized *
Serialized::DeserializeObject(const wxXmlNode& root, Serialized *obj)
{
	m_Objects.clear();
	wxString uid;
	if (!root.GetPropVal(wxT("uid"), &uid))
	{
		return (Serialized *)NULL;
	}
	if (obj != NULL)
	{
		m_Objects.insert(std::pair<wxString, Serialized *>(uid, obj));
		Debug::Printf(TXT("%s(%p, %p) -> object %s created as %p\n"), __FUNCTION__, &root, obj, uid.c_str(), obj);
	}
	CreateObjects(root);
	obj = GetObjectByUID(uid);
	obj->Deserialize(root);
	return obj;
}
///	\brief	paste objects from clipboard
///	\param	pParentName - name of the state machine or single state to paste
///	\param	object - list with created objects
///	\return	true if objects were pasted from the clipboard
bool CStateMachineClipboard::Paste( IHashString *pParentName, vector<ObjectInfo> &objects ) const
{
	if( !CanPaste() )
	{
		return false;
	}

	IXMLArchive *pArchive = GetClipboardDataArchive();
	if( pArchive == NULL )
	{
		return false;
	}

	if( !IsValidArchive( pArchive ))
	{
		pArchive->Close();
		return false;
	}

	CStateMachineClipboardPreprocessor preprocessor;
	if( !preprocessor.Prepare( pParentName, pArchive ) )
	{
		pArchive->Close();
		return false;
	}

	IXMLArchive *pTransformedArchive = TransformXMLArchive( pArchive, preprocessor );
	if( pTransformedArchive == NULL )
	{
		pArchive->Close();
		return false;
	}

#ifdef _DEBUG
	DumpStream( pTransformedArchive, _T("c:\\stateMachine.transformed.xml") );
#endif

	bool res = CreateObjects( pParentName, pTransformedArchive, objects );
	pTransformedArchive->Close();
	return res;
}
Ejemplo n.º 12
0
void ImageBrowser5D::Setup()
{
	if(!img) return;

	for(int c=0; c<img->GetImageInfo()->numChannels; ++c)
		m_chflag.push_back(true);
	
	CreateObjects();
	CreateLayout();
	CreateLookupTable();
	CreateVolumeProperties();
	CreateInteractorStyle();

	UpdateVSlider();
	UpdateHSlider();
	UpdateRenderer();

	this->resize(img->GetImageInfo()->numColumns, img->GetImageInfo()->numRows);
	this->setAttribute ( Qt::WA_DeleteOnClose );
	this->setWindowTitle(tr("Image Browser"));
}
Ejemplo n.º 13
0
/* Constructor. */
INTERACTIVE::INTERACTIVE(const CMarkup * original_script) : SCENE(original_script) {	
	last_active_object = 0;
	caption_displayed  = false;
	
	if(!scene_created)
		return;
	if(!CreateObjects())
		return;
	if(Play() != S_OK)
		return;

	// Editor setup
	outliner = new Gdiplus::Pen(Gdiplus::Color(0,255,0),1.5f);
	nowliner = new Gdiplus::Pen(Gdiplus::Color(0,0,255),1.5f);
	temp_points_count = 0;
	temp_points = new Gdiplus::Point[1000];
	last_point = Gdiplus::Point(0,0);
	DrawOutlines();
	BlendText();

	PostSceneCreated();	
}
Ejemplo n.º 14
0
int main(int argc,char** argv)
{
	glutInit(&argc,argv);

	init();
    glutDisplayFunc(display);
	glutKeyboardFunc(keyboard);
	glutKeyboardUpFunc(KeyUp);
	glutSpecialFunc(SpecialFunction);
	glutIgnoreKeyRepeat(true);

	Timer->start();
	last_time=Timer->time();
	walkTimer = Timer->time();

    LoadImages(); 
    CreateObjects();
	CreateWorld();

	glutMainLoop();
	return 0;
}
Ejemplo n.º 15
0
	LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
	{
		unsigned long uThreadID;
		unsigned long uThreadID1;
		srand(unsigned(time(NULL)));
		char MyStr[128];
		HDC hdc = GetWindowDC(hwnd);
		HPEN hPen;
		PAINTSTRUCT ps;
		RECT rect;//оброботка сообщения
		switch (iMsg)
		{
		int x,y,sx,sy;
		HDC hDC;
		case WM_CREATE://создание окна
			hwnd7=CreateWindow("BUTTON", "Старт", WS_CHILD|SS_CENTERIMAGE|SS_PATHELLIPSIS,10,130,70,30,hwnd, (HMENU) DEFPUSHBUTTON_1,NULL,NULL);
			ShowWindow (hwnd7, SW_SHOW);		
			return 0;
			break;
		case WM_SIZE:
			sx = 680;
			sy = 130;
		case WM_PAINT:
			hdc = BeginPaint(hwnd, &ps);
			hPen = CreatePen(PS_DASHDOTDOT, 3, RGB(0, 0, 0));
			SelectObject(hdc, hPen);
			for (x = 20; x < sx; x += sx/15)
			{
				MoveToEx(hdc, x, 20, NULL);
				LineTo(hdc, x, sy);
			}
			for (y = 20; y < sy; y += sy/5)
			{
				MoveToEx(hdc, 20, y, NULL);
				LineTo(hdc, sx, y);
			}
			ValidateRect(hwnd, NULL);
			EndPaint (hwnd, &ps);
			return 0;
			break;
		case WM_DESTROY://уничтожение окна
			PostQuitMessage (0);//запрос ОС на уничтожение окна
			return 0;
		case WM_COMMAND:
			if (wParam==DEFPUSHBUTTON_1) //двойной клик например
			{
				for(int i = 0; i < SIZE; i++){
					pages[i] = rand()%10 + 1;
				}
				wsprintf(Buf1,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",pages[0],pages[1],pages[2],pages[3],pages[4],
					pages[5],pages[6],pages[7],pages[8],pages[9],pages[10],pages[11],pages[12],pages[13],pages[14]);
				TextOut(hdc,10,250,Buf1,100);
				CreateThread(0,0,(LPTHREAD_START_ROUTINE)TimeTick,0,0,&uThreadID);
				CreateObjects();
				CreateThread(0,0,(LPTHREAD_START_ROUTINE)Run,0,0,&uThreadID);
			}
			return 0;
			break;
		default:
		//обработка по умолчанию всех сообщений, что не были обработвны в программе
		return DefWindowProc (hwnd, iMsg, wParam, lParam);
			 }	
    }
Ejemplo n.º 16
0
void CUIGlobals::RecreateObjects()
{
	DeleteObjects();
	CreateObjects();
}
Ejemplo n.º 17
0
Layer::Layer(Level * _level, tinyxml2::XMLElement * element_, int index_) : GameObject(_level)
{
	//Save reference to the level as proper pointer
	dl = static_cast<DIY_Level *>(_level);

	index = index_;
	distanceFromSun = element_->FloatAttribute("r");

	position = Vec3(Random::box_muller(0.f, 1.f), 0, Random::box_muller(0.f, 1.f)).Normalized() * (distanceFromSun + dl->sunRadius);

	//Adjust size of layer
	float scale = element_->FloatAttribute("s");
	
	//Enforce minimum layer size
	if (scale < 10) scale = 10.0f;

	Scale(Vec3(scale, 0.01f, scale));

	//Not the first layer
	if (index != 0)
	{
		float x = element_->FloatAttribute("wormHoleX");
		float z = element_->FloatAttribute("wormHoleZ");

		float destX = element_->FloatAttribute("wormHoleDestX");
		float destZ = element_->FloatAttribute("wormHoleDestY");

		wormHole = new Wormhole(dl, position + Vec3(x, 0, z), index - 1, Vec3(destX, 0, destZ));

		//Create wormhole here
		objects.push_back(wormHole);
	}

	float x = element_->FloatAttribute("planetX");
	float z = element_->FloatAttribute("planetZ");
	float s = element_->FloatAttribute("planetScale");
	const char * sunTex = element_->Attribute("planetTexture");

	//Planet creation not including scale
	planet = new Planet(dl, position + Vec3(x, 0, z), s, sunTex, true, index == 0);
	objects.push_back(planet);

	//Grab the first element and loop through all the elements
	//Adding GameObjects as you go
	tinyxml2::XMLElement * object = element_->FirstChildElement("Object");
	while (object)
	{
		Vec2 position = Vec2(object->FloatAttribute("x"), object->FloatAttribute("z"));
		CreateObjects(object->Attribute("type"), position);
		object = object->NextSiblingElement();
	}


	for (int i = 0; i < objects.size(); i++)
	{
		addChild(objects[i]);

		objects[i]->SetRenderEnabled(false);
	}

	r = new Generic_RenderableComponent(this, "cuboid", "layerGrid");
	r->SetEffecctedByLight(false, false, false);
	r->isEnabled = false;
}
Ejemplo n.º 18
0
void EZB::Connect(char* mac_address){

	if(m_connected)
		throw std::runtime_error("Already connected");


	if(mac_address){
		m_mac_address = (char*)malloc(sizeof(char) * (strlen(mac_address)+1));
		strcpy(m_mac_address, mac_address);
	}else{

	}

	// allocate a socket
	m_socket = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

	// set the connection parameters (who to connect to)
#ifdef _WINDOWS
	m_addr.addressFamily = AF_BLUETOOTH;
	m_addr.port = 1;
	str2ba(m_mac_address, &m_addr.btAddr);
#else
	m_addr.rc_family = AF_BLUETOOTH;
	m_addr.rc_channel = (uint8_t) 1;
	str2ba( m_mac_address, &m_addr.rc_bdaddr );
#endif
	// connect to server
	int status = connect(m_socket, (struct sockaddr *)&m_addr, sizeof(m_addr));

	if(status < 0){
		char error[512];
		sprintf(error, "%s", strerror(errno));
		throw std::runtime_error(error);
	}

	CreateObjects();

#ifdef _WINDOWS
	InitializeCriticalSection(&m_send_mutex);
#else
	pthread_mutex_init(&m_send_mutex, NULL);
#endif

	m_connected = true;

	SendCommand(EZB::Ping);
	usleep(1000000);



	if(!KeepAlive())
		throw std::runtime_error("Controller not responding");

#ifdef _WINDOWS
	m_keepalive_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ConnectionCheckStub, (void*)this, NULL, 0);
#else
	pthread_create(&m_keepalive_thread, NULL, ConnectionCheckStub, (void*)this);
#endif


}