コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: ginozh/my_wmm
void GraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
    //QMessageBox::information(NULL, "info", QString(tr("MainWindow::hoverEnterEvent")));
    hitFrame(event);
    QGraphicsTextItem::hoverEnterEvent(event);

}
コード例 #2
0
ファイル: main.cpp プロジェクト: bong0/school
bool mv_snake(WINDOW *w_game, frame *game, frame *term, snake *snake, int *xPos, int *yPos, char *vector, int cookie[], FILE *urandom, bool vec_diff){
	bool mod_length=FALSE;
	//save last head position
	snake->lastPos_h[0] = *xPos;
	snake->lastPos_h[1] = *yPos;
	//save last tail pos
	snake->lastPos_t[0] = snake->body[0][0];
	snake->lastPos_t[1] = snake->body[1][0];

	*xPos = snake->body[0][(snake->length)-1] + vector[0];
	*yPos = snake->body[1][(snake->length)-1] + vector[1];
	
	if(outOfBounds(xPos, yPos, game)){ //check whether new position is in the field
        hitFrame(term, urandom);
	}
	if(*yPos == cookie[1] && *xPos == cookie[0]){
		placeCookie(w_game, game, cookie, urandom);
		cookie[0]=-1; //invalidate position
		cookie[1]=-1;
		(snake->length)++;
		mod_length = TRUE;
		xPos=&(snake->body[0][(snake->length)-1]); // need to renew position of head in arr temporary
		yPos=&(snake->body[1][(snake->length)-1]);
		*xPos = snake->lastPos_h[0];
		*yPos = snake->lastPos_h[1];
		return mod_length;
	}
	snake->body[0][(snake->length)-2] = snake->lastPos_h[0];
	snake->body[1][(snake->length)-2] = snake->lastPos_h[1];
	for(int i=0; i<(snake->length)-1; i++){ //move all snake elements one pos left
		snake->body[0][i] = snake->body[0][i+1];
		snake->body[1][i] = snake->body[1][i+1];
	}

	return mod_length;
}
コード例 #3
0
ファイル: mainwindow.cpp プロジェクト: ginozh/my_wmm
void GraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
    hitFrame(event);
    QGraphicsTextItem::hoverLeaveEvent(event);
}