コード例 #1
0
ファイル: EAGLView.cpp プロジェクト: johanekholm/hex-game
int EAGLView::run() {
	SDL_Event event;

	while(1) {

		while ( SDL_PollEvent( &event ) ) {
			switch( event.type ) {
				case SDL_VIDEORESIZE:
					SDL_SetVideoMode( event.resize.w, event.resize.h, 16, d->videoFlags );
					break;
				case SDL_MOUSEMOTION:
					d->centralControl->touchesMoved(GPointMake(event.motion.x, event.motion.y));
					break;
				case SDL_MOUSEBUTTONDOWN:
					d->centralControl->touchesBegan(GPointMake(event.button.x, event.button.y));
					break;
				case SDL_MOUSEBUTTONUP:
					d->centralControl->touchesEnded(GPointMake(event.button.x, event.button.y));
					break;
				case SDL_QUIT:
					return 0;
// 				default:
// 					printf("default %i\n", event.type);
			}
		}
		d->centralControl->update();
		draw();
		usleep(1000);
	}

	return 0;
}
コード例 #2
0
ファイル: UnitView.cpp プロジェクト: mickeprag/hex-game
void UnitViewController::drawGUI(const GPoint& cameraPos) {
    _hpBarSlot->drawAt(GPointMake(_pos.x - 16.0f, _pos.y + 26.0f));
    _apBarSlot->drawAt(GPointMake(_pos.x- 16.0f, _pos.y + 30.0f));
    
    _hpBar->drawAt(GPointMake(_pos.x - 16.0f, _pos.y + 26.0f));
    _apBar->drawAt(GPointMake(_pos.x- 16.0f, _pos.y + 30.0f));
    
    BaseUnitViewController::drawGUI(cameraPos);
}
コード例 #3
0
ファイル: MessageView.cpp プロジェクト: johanekholm/hex-game
MessageView::MessageView(const GPoint& pos, const std::string& string, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
	_pos = pos;
    _posOffset = GPointMake(0.0f, -10.0f);
    _counter = 0;
    _width = 0.0f;
    _height = 0.0f;
    
	_stringImage = new StringImage(string, RGBAMake(red, green, blue, alpha));
}
コード例 #4
0
MultiRowStringImage::MultiRowStringImage(const std::string& string, const RGBA& color, GLfloat rowLength, GLfloat rowOffset) {
	int character = 0;
	int lastSpace = 0;
	int rowStart = 0;
	unsigned int index = 0;
	GLfloat sumLengthLastSpace = 0.0f;
	GLfloat sumLength = 0.0f;
	
    _color = color;
    _string = string;
	_rowLength = rowLength;
	_rowOffset = GPointMake(0.0f, rowOffset);
	_numRows = 0;
	    
	for (std::string::iterator it = _string.begin(); it != _string.end(); it++, index++) {
		character = *it - 32;
		
		if (character > 0) {
			sumLength += 0.5f * StringImage::_fontPixelWidths.at(character);			
		}
		
		// remember last possible break point
		if (character == 0) {
			lastSpace = index;
			sumLengthLastSpace = sumLength;
		}
		
		// create new row and corresponding StringImage
		if (sumLength >= rowLength || index == _string.length()-1) {
			_numRows++;
			
			// create StringImage from substring: rowStart -> lastSpace
			_strings.push_back(new StringImage(_string.substr(rowStart, lastSpace-rowStart), color));
			
			rowStart = lastSpace + 1;
			sumLength -= sumLengthLastSpace;
		}
	}
}
コード例 #5
0
ファイル: HexMap.cpp プロジェクト: johanekholm/hex-game
GPoint HexMap::getSEBoundary() {
	return GPointMake(64.0f + (_width * HEX_WIDTH - HEX_HALF_WIDTH) * _scale, 64.0f + (_height * (HEX_HEIGHT + HEX_POINTINESS) - HEX_HALF_HEIGHT - HEX_POINTINESS) * _scale);	
}
コード例 #6
0
ファイル: HexMap.cpp プロジェクト: johanekholm/hex-game
GPoint HexMap::getNWBoundary() {
	return GPointMake(64.0f, 64.0f - HEX_HALF_HEIGHT * _scale);
}
コード例 #7
0
ファイル: EAGLView.cpp プロジェクト: mickeprag/hex-game
void EAGLView::mouseReleaseEvent ( QMouseEvent * event ) {
	d->centralControl->touchesEnded(GPointMake(event->x(), event->y()));
}
コード例 #8
0
ファイル: EAGLView.cpp プロジェクト: mickeprag/hex-game
void EAGLView::mousePressEvent ( QMouseEvent * event ) {
	d->centralControl->touchesBegan(GPointMake(event->x(), event->y()));
}
コード例 #9
0
ファイル: MessageView.cpp プロジェクト: johanekholm/hex-game
MessageView::MessageView(const GPoint& pos, const std::string& string) : ViewController(pos, 0.0f, 0.0f, MapLayer::GUI) {
    _posOffset = GPointMake(0.0f, -10.0f);
    _counter = 0;

	_stringImage = new StringImage(string, RGBAMake(1.0f, 1.0f, 1.0f, 1.0f));
}