Beispiel #1
0
void FViewer::moveAllSelectedBoxes(Frame& currentFrame, int defaultStep, bool shiftHeld, DIRECTION direction)
{
	if(DRAW_HITBOXES_FLAG && selectedHitBoxList->Count>0)//if we're even drawing the Hitboxes & it isn't empty
	{
		for(int i = 0; i<selectedHitBoxList->Count; i++)
		{
			if(currentFrame.hitBoxes.size() >= selectedHitBoxList[i] && selectedHitBoxList[i] >= 0)//make sure the object in the selected list is within the range of the hitbox vector
			{
				moveBox(currentFrame.hitBoxes.at(selectedHitBoxList[i]),defaultStep, shiftHeld, direction);
			}
		}
	}

	if(DRAW_HURTBOXES_FLAG && selectedHurtBoxList->Count>0)//if we're even drawing the Hitboxes & it isn't empty
	{
		for(int i = 0; i<selectedHurtBoxList->Count; i++)
		{
			if(currentFrame.hurtBoxes.size() >= selectedHurtBoxList[i] && selectedHurtBoxList[i] >= 0)//make sure the object in the selected list is within the range of the hitbox vector
			{
				moveBox(currentFrame.hurtBoxes.at(selectedHurtBoxList[i]),defaultStep, shiftHeld, direction);
			}
		}
	}
	
}
Beispiel #2
0
void AGOSEngine::o_moveBox() {
	// 111: set hitarea xy
	uint hitarea_id = getVarOrWord();
	uint x = getVarOrWord();
	uint y = getVarOrWord();
	moveBox(hitarea_id, x, y);
}
Beispiel #3
0
void OverlayEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
	QGraphicsScene::mouseReleaseEvent(e);

	if (e->isAccepted())
		return;

	if (e->button() == Qt::LeftButton) {
		e->accept();

		QRectF rect = qgriSelected->rect();

		if (! qgpiSelected || (rect == selectedRect())) {
			return;
		}

		QRectF scaled(rect.x() / (uiSize * uiZoom), rect.y() / (uiSize * uiZoom), rect.width() / (uiSize * uiZoom), rect.height() / (uiSize * uiZoom));

		if (qgpiSelected == qgpiMuted) {
			os.qrfMutedDeafened = scaled;
			updateMuted();
		} else if (qgpiSelected == qgpiAvatar) {
			os.qrfAvatar = scaled;
			updateAvatar();
		} else if (qgpiSelected == qgpiChannel) {
			os.qrfChannel = scaled;
			updateChannel();
		} else if (qgpiSelected == qgpiName) {
			os.qrfUserName = scaled;
			updateUserName();
		}

		moveBox();
	}
}
Beispiel #4
0
void OverlayEditorScene::resync() {
	QRadialGradient gradient(0, 0, 10 * uiZoom);
	gradient.setSpread(QGradient::ReflectSpread);
	gradient.setColorAt(0.0f, QColor(255, 255, 255, 64));
	gradient.setColorAt(0.2f, QColor(0, 0, 0, 64));
	gradient.setColorAt(0.4f, QColor(255, 128, 0, 64));
	gradient.setColorAt(0.6f, QColor(0, 0, 0, 64));
	gradient.setColorAt(0.8f, QColor(0, 128, 255, 64));
	gradient.setColorAt(1.0f, QColor(0, 0, 0, 64));
	setBackgroundBrush(gradient);

	updateMuted();
	updateUserName();
	updateChannel();
	updateAvatar();

	moveMuted();
	moveUserName();
	moveChannel();
	moveAvatar();

	moveBox();

	qgiGroup->setOpacity(os.fUser[tsColor]);

	qgpiSelected = NULL;
	qgriSelected->setVisible(false);
}
void boxesUpdate() {

	for (unsigned int i = 0; i < boxes.size(); ++i) {
		
		//This is an array which stores the coordinates of the box(which takes up 9 spaces)
		unsigned int * boxCoords[9] = {
			&g_worldGrid[boxes[i].boxLocationX][boxes[i].boxLocationY],
			&g_worldGrid[boxes[i].boxLocationX - 1][boxes[i].boxLocationY],
			&g_worldGrid[boxes[i].boxLocationX + 1][boxes[i].boxLocationY],
			&g_worldGrid[boxes[i].boxLocationX][boxes[i].boxLocationY - 1],
			&g_worldGrid[boxes[i].boxLocationX - 1][boxes[i].boxLocationY - 1],
			&g_worldGrid[boxes[i].boxLocationX + 1][boxes[i].boxLocationY - 1],
			&g_worldGrid[boxes[i].boxLocationX][boxes[i].boxLocationY - 2],
			&g_worldGrid[boxes[i].boxLocationX - 1][boxes[i].boxLocationY - 2],
			&g_worldGrid[boxes[i].boxLocationX + 1][boxes[i].boxLocationY - 2]
		};

		//This is to delete everything that the box is overlaping with, such as lava.
		for (unsigned int h = 0; h < 9; ++h) {
			if (canDestroy(*boxCoords[h])) {
				*boxCoords[h] = ' ';
			}
		}

		//This makes the box fall down if there is no ground underneath it.
		boxesGravity(boxes[i]);
		
		//This is to move the box if a player is pushing/pulling it.
		moveBox(boxes[i]);

		//If the box is no longer the same Y coordinates as the player, the box is released if the player was holding it.
		if (mummy.isGrabbing && g_heldBox->boxLocationY != charLocation.Y) {
			releaseBox(*g_heldBox);
		}

		//A new array to get the new coordinates of the box as the box has been moved.
		unsigned int * boxCoordsNew[9] = {
			&g_worldGrid[boxes[i].boxLocationX][boxes[i].boxLocationY],
			&g_worldGrid[boxes[i].boxLocationX - 1][boxes[i].boxLocationY],
			&g_worldGrid[boxes[i].boxLocationX + 1][boxes[i].boxLocationY],
			&g_worldGrid[boxes[i].boxLocationX][boxes[i].boxLocationY - 1],
			&g_worldGrid[boxes[i].boxLocationX - 1][boxes[i].boxLocationY - 1],
			&g_worldGrid[boxes[i].boxLocationX + 1][boxes[i].boxLocationY - 1],
			&g_worldGrid[boxes[i].boxLocationX][boxes[i].boxLocationY - 2],
			&g_worldGrid[boxes[i].boxLocationX - 1][boxes[i].boxLocationY - 2],
			&g_worldGrid[boxes[i].boxLocationX + 1][boxes[i].boxLocationY - 2]
		};

		//This is to 'solidify' the box so that the player and other boxes cannot pass through it.
		for (unsigned int h = 0; h < 9; ++h) {
			if (canDestroy(*boxCoordsNew[h])) {
				*boxCoordsNew[h] = '%';
			}
		}

	}

}
Beispiel #6
0
int check_keys(XEvent *e, Game *game)
{
    //Was there input from the keyboard?
    if (e->type == KeyPress)
    {
        int key = XLookupKeysym(&e->xkey, 0);
        if (key == XK_Escape)
        {
            return 1;
        }
        //You may check other keys here.


        // check game input
        if(key == XK_Up)
            moveBox(game, "up");
        if(key == XK_Down)
            moveBox(game, "down");
        if(key == XK_Left)
            moveBox(game, "left");
        if(key == XK_Right)
            moveBox(game, "right");
        if(key == XK_space && game->space == true)
        {
            moveBox(game, "space");
        }
    }
    else
        // no key pressed so
        // apply gravity
        moveBox(game, "null"); // no movement, kill motion

    return 0;
}
Beispiel #7
0
void announceWinner() 
{
	//announces the winner
	if( turn == 1){
		textout_ex( screen, font, "X Wins!!!!", 300, 240, makecol( 255, 0, 0), makecol( 0, 0, 0));
	}else {
		textout_ex( screen, font, "Y Wins!!!!", 300, 240, makecol( 255, 0, 0), makecol( 0, 0, 0));
}


void checkWin()
{
	//checks for a winner 
}

void drawXO()
{
	//draws in the X and O
}

void moveBox()
{
	//takes input
}

int main()
{
	//now we actually build it
	allegro_init();
	install_keyboard();
	set_color_depth(16);
	set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);

	xSprite = load_bitmap("x.bmp", NULL);

	oSprite = load_bitmap("o.bmp", NULL);

	setupBoard();

	while(!key[KEY_ESC]){
		moveBox();
	}

	destroy_bitmap(xSprite);
	destroy_bitmap(oSprite);

	return 0;

}
Beispiel #8
0
void AGOSEngine_Feeble::linksDown() {
	uint16 i;
	for (i = 700; i < _variableArray[53]; i++) {
		moveBox(i,0, 15);
	}
}
Beispiel #9
0
void AGOSEngine_Feeble::linksUp() {	// Scroll Oracle Links
	uint16 j;
	for (j = 700; j < _variableArray[53]; j++) {
		moveBox(j, 0, -15);
	}
}
Beispiel #10
0
void OverlayEditorScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) {
	QGraphicsScene::contextMenuEvent(e);

	if (e->isAccepted())
		return;

	if (! e->widget())
		return;

	QGraphicsPixmapItem *item = childAt(e->scenePos());

	QMenu qm(e->widget());

	QMenu *qmLayout = qm.addMenu(tr("Layout preset"));
	QAction *qaLayoutLargeAvatar = qmLayout->addAction(tr("Large square avatar"));
	QAction *qaLayoutText = qmLayout->addAction(tr("Avatar and Name"));

	QMenu *qmTrans = qm.addMenu(tr("User Opacity"));
	QActionGroup *qagUser = new QActionGroup(&qm);
	QAction *userOpacity[8];
	for (int i=0;i<8;++i) {
		qreal o = (i + 1) / 8.0;

		userOpacity[i] = new QAction(tr("%1%").arg(o * 100.0f, 0, 'f', 1), qagUser);
		userOpacity[i]->setCheckable(true);
		userOpacity[i]->setData(o);

		if (qFuzzyCompare(qgiGroup->opacity(), o))
			userOpacity[i]->setChecked(true);

		qmTrans->addAction(userOpacity[i]);
	}

	QAction *color = NULL;
	QAction *fontAction = NULL;
	QAction *objectOpacity[8];
	for (int i=0;i<8;++i)
		objectOpacity[i] = NULL;
	QAction *boxpen[4] = { NULL, NULL, NULL, NULL};
	QAction *boxpad[4] = { NULL, NULL, NULL, NULL};
	QAction *boxpencolor = NULL;
	QAction *boxfillcolor = NULL;

	QAction *align[6];
	for (int i=0;i<6;++i)
		align[i] = NULL;

	if (item) {
		qm.addSeparator();
		QMenu *qmObjTrans = qm.addMenu(tr("Object Opacity"));
		QActionGroup *qagObject = new QActionGroup(&qm);
		for (int i=0;i<8;++i) {
			qreal o = i + 1 / 8.0;

			objectOpacity[i] = new QAction(tr("%1%").arg(o * 100.0f, 0, 'f', 1), qagObject);
			objectOpacity[i]->setCheckable(true);
			objectOpacity[i]->setData(o);
			if (qFuzzyCompare(item->opacity(), o))
				objectOpacity[i]->setChecked(true);
			qmObjTrans->addAction(objectOpacity[i]);
		}

		QMenu *qmObjAlign = qm.addMenu(tr("Alignment"));
		Qt::Alignment a;
		if (item == qgpiAvatar)
			a = os.qaAvatar;
		else if (item == qgpiChannel)
			a = os.qaChannel;
		else if (item == qgpiMuted)
			a = os.qaMutedDeafened;
		else
			a = os.qaUserName;

		align[0] = qmObjAlign->addAction(tr("Left"));
		align[0]->setCheckable(true);
		align[0]->setData(Qt::AlignLeft);
		if (a & Qt::AlignLeft)
			align[0]->setChecked(true);
		align[1] = qmObjAlign->addAction(tr("Center"));
		align[1]->setCheckable(true);
		align[1]->setData(Qt::AlignHCenter);
		if (a & Qt::AlignHCenter)
			align[1]->setChecked(true);
		align[2] = qmObjAlign->addAction(tr("Right"));
		align[2]->setCheckable(true);
		align[2]->setData(Qt::AlignRight);
		if (a & Qt::AlignRight)
			align[2]->setChecked(true);

		qmObjAlign->addSeparator();

		align[3] = qmObjAlign->addAction(tr("Top"));
		align[3]->setCheckable(true);
		align[3]->setData(Qt::AlignTop);
		if (a & Qt::AlignTop)
			align[3]->setChecked(true);
		align[4] = qmObjAlign->addAction(tr("Center"));
		align[4]->setCheckable(true);
		align[4]->setData(Qt::AlignVCenter);
		if (a & Qt::AlignVCenter)
			align[4]->setChecked(true);
		align[5] = qmObjAlign->addAction(tr("Bottom"));
		align[5]->setCheckable(true);
		align[5]->setData(Qt::AlignBottom);
		if (a & Qt::AlignBottom)
			align[5]->setChecked(true);

		if ((item != qgpiAvatar) && (item != qgpiMuted)) {
			color = qm.addAction(tr("Color..."));
			fontAction = qm.addAction(tr("Font..."));
		}
	}

	if (qgpiBox->isVisible()) {
		qm.addSeparator();
		QMenu *qmBox = qm.addMenu(tr("Bounding box"));
		QMenu *qmPen = qmBox->addMenu(tr("Pen width"));
		QMenu *qmPad = qmBox->addMenu(tr("Padding"));
		boxpencolor = qmBox->addAction(tr("Pen color"));
		boxfillcolor = qmBox->addAction(tr("Fill color"));

		QActionGroup *qagPen = new QActionGroup(qmPen);
		QActionGroup *qagPad = new QActionGroup(qmPad);
		for (int i=0;i<4;++i) {
			qreal v = (i) ? powf(2.0f, static_cast<float>(-10 + i)) : 0.0f;
			boxpen[i] = new QAction(QString::number(i), qagPen);
			boxpen[i]->setData(v);
			boxpen[i]->setCheckable(true);
			if (qFuzzyCompare(os.fBoxPenWidth, v))
				boxpen[i]->setChecked(true);
			qmPen->addAction(boxpen[i]);

			boxpad[i] = new QAction(QString::number(i), qagPad);
			boxpad[i]->setData(v);
			boxpad[i]->setCheckable(true);
			if (qFuzzyCompare(os.fBoxPad, v))
				boxpad[i]->setChecked(true);
			qmPad->addAction(boxpad[i]);
		}
	}

	QAction *act = qm.exec(e->screenPos());

	if (! act)
		return;

	for (int i=0;i<8;++i) {
		if (userOpacity[i] == act) {
			float o = static_cast<float>(act->data().toReal());
			os.fUser[tsColor] = o;

			qgiGroup->setOpacity(o);
		}
	}

	for (int i=0;i<8;++i) {
		if (objectOpacity[i] == act) {
			qreal o = act->data().toReal();

			if (item == qgpiMuted)
				os.fMutedDeafened = o;
			else if (item == qgpiAvatar)
				os.fAvatar = o;
			else if (item == qgpiChannel)
				os.fChannel = o;
			else if (item == qgpiName)
				os.fUserName = o;

			item->setOpacity(o);
		}
	}

	for (int i=0;i<4;++i) {
		if (boxpen[i] == act) {
			os.fBoxPenWidth = act->data().toReal();
			moveBox();
		} else if (boxpad[i] == act) {
			os.fBoxPad = act->data().toReal();
			moveBox();
		}
	}

	for (int i=0;i<6;++i) {
		if (align[i] == act) {
			Qt::Alignment *aptr;
			if (item == qgpiAvatar)
				aptr = & os.qaAvatar;
			else if (item == qgpiChannel)
				aptr = & os.qaChannel;
			else if (item == qgpiMuted)
				aptr = & os.qaMutedDeafened;
			else
				aptr = & os.qaUserName;

			Qt::Alignment a = static_cast<Qt::Alignment>(act->data().toInt());
			if (a & Qt::AlignHorizontal_Mask) {
				*aptr = (*aptr & ~Qt::AlignHorizontal_Mask) | a;
			} else {
				*aptr = (*aptr & ~Qt::AlignVertical_Mask) | a;
			}

			updateSelected();
		}
	}

	if (act == boxpencolor) {
		QColor qc = QColorDialog::getColor(os.qcBoxPen, e->widget(), tr("Pick pen color"), QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
		if (! qc.isValid())
			return;
		os.qcBoxPen = qc;
		moveBox();
	} else if (act == boxfillcolor) {
		QColor qc = QColorDialog::getColor(os.qcBoxFill, e->widget(), tr("Pick fill color"), QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
		if (! qc.isValid())
			return;
		os.qcBoxFill = qc;
		moveBox();
	} else if (act == color) {
		QColor *col = NULL;
		if (item == qgpiChannel)
			col = & os.qcChannel;
		else if (item == qgpiName)
			col = & os.qcUserName[tsColor];
		if (! col)
			return;

		QColor qc = QColorDialog::getColor(*col, e->widget(), tr("Pick color"), QColorDialog::DontUseNativeDialog);
		if (! qc.isValid())
			return;
		qc.setAlpha(255);

		if (qc == *col)
			return;

		*col = qc;
		updateSelected();
	} else if (act == fontAction) {
		QFont *fontptr = (item == qgpiChannel) ? &os.qfChannel : &os.qfUserName;

		qgpiSelected = NULL;
		qgriSelected->hide();

		// QFontDialog doesn't really like graphics view. At all.

		QFontDialog qfd;
		qfd.setOptions(QFontDialog::DontUseNativeDialog);
		qfd.setCurrentFont(*fontptr);
		qfd.setWindowTitle(tr("Pick font"));

		int ret;
		if (g.ocIntercept) {
			QGraphicsProxyWidget *qgpw = new QGraphicsProxyWidget(NULL, Qt::Window);
			qgpw->setWidget(&qfd);

			addItem(qgpw);

			qgpw->setZValue(3.0f);
			qgpw->setPanelModality(QGraphicsItem::PanelModal);
			qgpw->setPos(- qgpw->boundingRect().width() / 2.0f, - qgpw->boundingRect().height() / 2.0f);
			qgpw->show();

			ret = qfd.exec();

			qgpw->hide();
			qgpw->setWidget(NULL);
			delete qgpw;
		} else {
			Qt::WindowFlags wf = g.mw->windowFlags();
			if (wf.testFlag(Qt::WindowStaysOnTopHint))
				qfd.setWindowFlags(qfd.windowFlags() | Qt::WindowStaysOnTopHint);
			ret = qfd.exec();
		}

		if (! ret)
			return;
		*fontptr = qfd.selectedFont();

		resync();
	} else if (act == qaLayoutLargeAvatar) {
		os.setPreset(OverlaySettings::LargeSquareAvatar);
		resync();
	} else if (act == qaLayoutText) {
		os.setPreset(OverlaySettings::AvatarAndName);
		resync();
	}
}