Exemplo n.º 1
0
void cDangerousGame::checkCollision(){
	//if( ball1->checkCollision( playerDetails->getPosX(), playerDetails->getPosY(), playerDetails->getWidth(), playerDetails->getHeight() ) ) {
	if( ball1->checkCollision( playerDetails ) ) {
		ball1->changePosition( wRand(), hRand() );
		playerDetails->addPoint();
	}

	//if( ball2->checkCollision( playerDetails->getPosX(), playerDetails->getPosY(), playerDetails->getWidth(), playerDetails->getHeight() ) ) {
	if( ball2->checkCollision( playerDetails ) ) {
		ball2->changePosition( wRand(), hRand() );
		playerDetails->addPoint();
	}

	//if( ball3->checkCollision( playerDetails->getPosX(), playerDetails->getPosY(), playerDetails->getWidth(), playerDetails->getHeight() ) ) {
	if( ball3->checkCollision( playerDetails ) ) {
		ball3->changePosition( wRand(), hRand() );
		playerDetails->addPoint();
	}

	//if( ball4->checkCollision( playerDetails->getPosX(), playerDetails->getPosY(), playerDetails->getWidth(), playerDetails->getHeight() ) ) {
	if( ball4->checkCollision( playerDetails ) ) {
		ball4->changePosition( wRand(), hRand() );
		playerDetails->addPoint();
	}
}
Exemplo n.º 2
0
cDangerousGame::cDangerousGame( const int screen_width, const int screen_height ){

	finished = false;
	started = false;
	startButton = BUTTON_NOT_PRESSED;

	message = NULL;
	screen = NULL;
	background = NULL;
	opponents = NULL;
	player = NULL;
	font = NULL;
	timeMessage = NULL;
	playerMessage = NULL;

	textColor = { 255, 255, 255 };

	bool init = game_init( (int) screen_width, (int) screen_height );
	if( !init ) { printf("initialitation failed\n"); }
	bool loading = load_files();
	if( !loading ) { printf("loading files failed\n"); }

	playerDetails = new cPlayer();

        clip[ 0 ].x = 0;
        clip[ 0 ].y = 0;
        clip[ 0 ].w = 40;
        clip[ 0 ].h = 40;

        clip[ 1 ].x = 40;
        clip[ 1 ].y = 0;
        clip[ 1 ].w = 40;
        clip[ 1 ].h = 40;

        clip[ 2 ].x = 0;
        clip[ 2 ].y = 40;
        clip[ 2 ].w = 40;
        clip[ 2 ].h = 40;

        clip[ 3 ].x = 40;
        clip[ 3 ].y = 40;
        clip[ 3 ].w = 40;
        clip[ 3 ].h = 40;

	srand(time(NULL) + getpid());
	ball1 = new cBall( wRand(), hRand(), 10, 10, screen_h, screen_w );
	ball2 = new cBall( wRand(), hRand(), 10, -10, screen_h, screen_w );
	ball3 = new cBall( wRand(), hRand(), -10, 10, screen_h, screen_w );
	ball4 = new cBall( wRand(), hRand(), -10, -10, screen_h, screen_w );

	timeGameStarted = 0;//SDL_GetTicks();
	timeForOneRound = 120;
	lastBlittTime = -1;

	playerPoints = 0;

	createPlayerPointMessage();
}
Exemplo n.º 3
0
void cDangerousGame::restartGame(){
	playerDetails->resetPoints();
	playerDetails->setPos( playerDetails->getWidth() / 2, playerDetails->getHeight() / 2 );
	ball1->changePosition( wRand(), hRand() );
	ball2->changePosition( wRand(), hRand() );
	ball3->changePosition( wRand(), hRand() );
	ball4->changePosition( wRand(), hRand() );
	timeGameStarted = SDL_GetTicks();
	started = true;
	finished = false;
}
Exemplo n.º 4
0
Arquivo: Sim.cpp Projeto: wonsch/ds
BOOL CSimApp::InitInstance()
{
	CWinApp::InitInstance();

	CwRand wRand(GetTickCount());
	//RandomSeed = wRand();
	RandomSeed = 2925723681;
	CacheMode = MODE_CACHE_OFF;
	GroupMode = MODE_GROUPING_OFF;
	MaxFloodHopCount = 6;
	PeerCount = 10000;
	SearchContentCount = 10;
	GroupSize = 8;

	CSimDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
	}
	else if (nResponse == IDCANCEL)
	{
	}

	return FALSE;
}
Exemplo n.º 5
0
CContentInfo *CSimulatorIn::GetRandomContent()
{
	// Get a random content which exists.
	POSITION pos = ContentInfoMap->GetStartPosition();
	if(pos == NULL) return NULL;

	unsigned int StartIndex = wRand() % ContentInfoMap->GetCount();
	for(unsigned int i = 0;i < StartIndex;i++) ContentInfoMap->GetNext(pos);

	unsigned int ContentID;
	CContentInfo *ContentInfo;
	ContentInfoMap->GetNextAssoc(pos, ContentID, ContentInfo);

	return ContentInfo;
}
Exemplo n.º 6
0
CPeerInfo *CSimulatorIn::GetRandomPeer()
{
	// Get a random peer which exists.
	POSITION pos = PeerInfoMap->GetStartPosition();
	if(pos == NULL) return NULL;

	unsigned int StartIndex = wRand() % PeerInfoMap->GetCount();
	for(unsigned int i = 0;i < StartIndex;i++) PeerInfoMap->GetNext(pos);

	unsigned int PeerID;
	CPeerInfo *PeerInfo;
	PeerInfoMap->GetNextAssoc(pos, PeerID, PeerInfo);

	return PeerInfo;
}