Пример #1
0
int main()
{
	MainGame mainGame;
	mainGame.run();

    return 0;
}
Пример #2
0
bool Enemy::initwithGame(Layer* gameLayer)
{
	if (!Node::init())
		return false;

	_gameLayer = gameLayer;
	_maxHp = 40;
	_currentHp = _maxHp;
	_walkingspeed = 5.0f;

	_ptrSprite = Sprite::create("images/enemy.png");
	this->addChild(_ptrSprite);

	
	MainGame* layer = static_cast<MainGame*>(_gameLayer);
	unsigned int count = layer->getWayPoints().size();
	WayPoint* wayPoint = static_cast<WayPoint*>(layer->getWayPoints().at(count - 1));
	_destinationWayPoint = wayPoint->getNextWayPoint();
	_spritePosition = wayPoint->getWayPosition();
	_ptrSprite->setPosition(_spritePosition);

	_gameLayer->addChild(this);

	scheduleUpdate();

	return true;
}
Пример #3
0
int main(int argc, char** argv) {

	MainGame mainGame;
	mainGame.run();

	return 0;
}
Пример #4
0
int main(int argc, char** argv)
{
    MainGame mainGame;
    mainGame.Run();
    SDL_Delay(5000);
    return 0;
}
Пример #5
0
int main(int argc, char **argv)
{
	MainGame game; //Instantiates the engine

	game.Run(); //begins the engine loop

	return 0;
}
Пример #6
0
void MainWindow::on_NewGame_clicked()  //Opens Maingame window
{
    //MainGame mgame;
    MainGame *mgame = new MainGame;
    mgame->setWindowTitle("Star Stuff");
    mgame->show();
    this->destroy();
}
Пример #7
0
int main(int argc, char** argv) {
	MainGame mainGame;
	mainGame.run();

	return 0;
	//SDL_Init(SDL_INIT_EVERYTHING);

	//	return 0;
	}
Пример #8
0
int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    app.setApplicationName("Test Game");

    MainGame game;
    game.init();
    game.show();

    return app.exec();
}
Пример #9
0
int WINAPI wWinMain(HINSTANCE i_hInstance, HINSTANCE i_hPrevInstance, LPWSTR i_lpCmdLine, int i_nCmdShow)
{
	//_CrtSetBreakAlloc(506);

	MainGame mainGame;

	mainGame.Initialize(i_hInstance, i_nCmdShow);
	mainGame.Run();

#ifdef _DEBUG
	_CrtDumpMemoryLeaks();
#endif
}
Пример #10
0
void Enemy::getRemoved()
{
	for (Tower* attacker : _vectAttackedBy)
	{
		attacker->targetKilled();
	}

	this->removeFromParentAndCleanup(true);

	MainGame* layer = static_cast<MainGame*>(_gameLayer);
	layer->awardGold(100);
	layer->getEnemies().eraseObject(this, true);
	layer->enemyGotKilled();
}
Пример #11
0
void Enemy::update(float dt)
{
	Node::update(dt);

	if (!_active)
		return;

	MainGame* layer = static_cast<MainGame*>(_gameLayer);

	if (layer->circle(_spritePosition, 1.0f, _destinationWayPoint->getWayPosition(), 1.0f))
	{
		if (_destinationWayPoint->getNextWayPoint())
		{
			_destinationWayPoint = _destinationWayPoint->getNextWayPoint();
		}
		else
		{
			layer->getHpDamage();
			getRemoved();
			return;
		}
	}

	Point targetPoint = _destinationWayPoint->getWayPosition();
	float movementSpeed = _walkingspeed;

	
	Point normalized = ccpNormalize(Point(targetPoint.x - _spritePosition.x, targetPoint.y - _spritePosition.y));
	_ptrSprite->setRotation(CC_RADIANS_TO_DEGREES(atan2(normalized.y, -normalized.x)));

	_spritePosition = Point(_spritePosition.x+normalized.x*movementSpeed,
		_spritePosition.y+normalized.y*movementSpeed);

	_ptrSprite->setPosition(_spritePosition);

	
}
Пример #12
0
int main()
{
	//Initializes main game class
	MainGame mainGame;
	mainGame.init();
}
Пример #13
0
INT WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR, INT)
{
	LPCTSTR szClassName = _T("MyMainWindowClass");

	WNDCLASSEX wcex = {0};

    wcex.cbSize = sizeof(wcex);
    wcex.style = CS_VREDRAW | CS_HREDRAW;
    wcex.lpfnWndProc = &WndProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInst;
	wcex.hIcon = ::LoadIcon(NULL, IDI_APPLICATION);
	wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH);
    wcex.lpszMenuName = 0;
    wcex.lpszClassName = szClassName;
	wcex.hIconSm = wcex.hIcon;

	if (!::RegisterClassEx(&wcex))
	{
		return 1;
	}

	int cx = ::GetSystemMetrics(SM_CXSCREEN);
	int cy = ::GetSystemMetrics(SM_CYSCREEN);

	int width = 800;
	int height = 600;

	//int x = (cx - width)/2;
	//int y = (cy - height)/2;
	//해상도가 좌측상단(0, 0) 이 아니면 짤려서 나옴.. !!

	//화면 해상도를 설정을 하기위한 구조체..
	DEVMODE dev;
	dev.dmSize = sizeof(DEVMODE);
	dev.dmPelsWidth = width;
	dev.dmPelsHeight = height;
	dev.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;

	//해상도를 바꾸기 위해서 이 함수를 써야하는데 그래서 위 구조체를 정의해줬다. (크아가 이런식으로 하는거군..)
	//::ChangeDisplaySettings(&dev, CDS_FULLSCREEN);

	DWORD dwStyle = WS_POPUP; // 미니 전체화면..
	//dwStyle = dwStyle & ~WS_THICKFRAME;
	//dwStyle = dwStyle & ~WS_MINIMIZEBOX;
	//dwStyle = dwStyle & ~WS_MAXIMIZEBOX;

	HWND hWnd = ::CreateWindowEx(0, szClassName, _T("Win32 Mouse"), dwStyle,
		0, 0, width, height,
		NULL, NULL, hInst, NULL);

	if (hWnd == NULL)
	{
		return 2;
	}



	::ShowWindow(hWnd, SW_NORMAL);
	::UpdateWindow(hWnd);


	RECT rc;
	::GetClientRect(hWnd, &rc);
	POINT lt = {rc.left, rc.top};
	POINT rb = {rc.right, rc.bottom};

	::ClientToScreen(hWnd, &lt);
	::ClientToScreen(hWnd, &rb);

	RECT rcScreen = {lt.x, lt.y, rb.x, rb.y};

	::ClipCursor(&rcScreen);


	MSG msg;

	MainGame mg;
	mg.Attach(hWnd);
	mg.Load();

	DWORD dt = 0;
	DWORD st = ::GetTickCount();

	while (true)
	{
		if(::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			::TranslateMessage(&msg);
			::DispatchMessage(&msg);
		}
		if (msg.message == WM_QUIT)
			break;

		mg.Input(dt);
		mg.Update(dt, hWnd);
		mg.Draw(dt);

		dt = ::GetTickCount() - st;
		st = ::GetTickCount();
	}
	return msg.wParam;
}