double TransitionManager::getY(double x) {
    if(x > getStartX() + getChangeX()) x = getStartX() + getChangeX();
    if(x < 0) x = 0;

    x = x - getStartX();

    return transition->getY(x);
}
Beispiel #2
0
void Panel::addControl(Control& control, int x, int y)
{
	items.push_back(&control);
	control.setStartPosition(x + getStartX(), y + getStartY());
	control.setLayer(getLayer() + 1);

}
Beispiel #3
0
void GEllipse::draw(CDC* dc)
{
	CPen pen(this->getPattern(), this->getThick(), this->getLineColor());
	dc->SelectObject(&pen);
	CBrush brush;
	brush.CreateHatchBrush(this->getFillPattern(), this->getFillColor());	
	
	dc->SelectObject(&brush);
	// 처음에 색이 NULL 이면 투명으로
	if (this->getFillColor() == NULL)
		dc->SelectStockObject(NULL_BRUSH);
			
	// 원 그리기는 여기서부터
	dc->MoveTo(getStartX(), getStartY());
	dc->Ellipse(this->getStartX(), this->getStartY(), GetEnd().x, GetEnd().y);
	if (this->getSelected() == TRUE){
		CPen pen2(PS_SOLID, 0, RGB(0, 0, 0));
		dc->SelectObject(&pen2);
		CBrush brush2(RGB(255, 255, 255));
		dc->SelectObject(&brush2);
		m_selectedRect[0] = new CRect(this->getStartX() - 5, this->getStartY() - 5, this->getStartX() + 5, this->getStartY() + 5);
		m_selectedRect[1] = new CRect(this->getEndX() - 5, this->getStartY() - 5, this->getEndX() + 5, this->getStartY() + 5);
		m_selectedRect[2] = new CRect(this->getStartX() - 5, this->getEndY() - 5, this->getStartX() + 5, this->getEndY() + 5);
		m_selectedRect[3] = new CRect(this->getEndX() - 5, this->getEndY() - 5, this->getEndX() + 5, this->getEndY() + 5); // 메모리 누수의 위험 있음. 수정바람!
		dc->Rectangle(m_selectedRect[0]);
		dc->Rectangle(m_selectedRect[1]);
		dc->Rectangle(m_selectedRect[2]);
		dc->Rectangle(m_selectedRect[3]);
	}
}
Beispiel #4
0
/**
 * Compares two areas with the == operator. Two uninitialized areas
 *   are equal to each other.
 *
 * @param otherArea This is the area we're comparing to, i.e. on
 *     the right hand side of the operator when used
 * @return True if this area is the same as the given area
 */
bool Area3D::operator ==(const Area3D &otherArea) const {
    return getStartX() == otherArea.getStartX() &&
           getStartY() == otherArea.getStartY() &&
           getStartZ() == otherArea.getStartZ() &&
           getEndX() == otherArea.getEndX() &&
           getEndY() == otherArea.getEndY() &&
           getEndZ() == otherArea.getEndZ();
}
	// The heart and core of StarCraft's unit search engine.
	// Based on BWAPI's Shared/Templates.h
	void UnitFinder::search(int left, int top, int right, int bottom) {
		//0: No match, 1: Passed X iteration, 2: Passed Y iteration
		//(Necessary because each UnitFinderData array has 2 entries per unit)
		u8 unitSearchFlags[UNIT_ARRAY_LENGTH + 1] = { 0 };

		int r = right, b = bottom;
		const bool isWidthExtended = right - left - 1 < *MAX_UNIT_WIDTH;
		const bool isHeightExtended = top - bottom - 1 < *MAX_UNIT_HEIGHT;

		// Check if the location is smaller than the largest unit
		if (isWidthExtended)
			r += *MAX_UNIT_WIDTH;
		if (isHeightExtended)
			b += *MAX_UNIT_HEIGHT;

		// Create UnitFinderData elements for compatibility with stl functions
		UnitFinderData finderVal;

		// Search for the values using built-in binary search algorithm and comparator
		finderVal.position = left;
		UnitFinderData *pLeft = std::lower_bound(getStartX(), getEndX(), finderVal);

		finderVal.position = top;
		UnitFinderData *pTop = std::lower_bound(getStartY(), getEndY(), finderVal);

		finderVal.position = r;
		UnitFinderData *pRight = std::lower_bound(pLeft, getEndX(), finderVal);

		finderVal.position = b;
		UnitFinderData *pBottom = std::lower_bound(pTop, getEndY(), finderVal);

		// Iterate the Y entries of the finder
		for (UnitFinderData *py = pTop; py < pBottom; ++py) {
			if (unitSearchFlags[py->unitIndex] == 0) {
				// If height is small, check unit bounds
				if (!isHeightExtended
					|| CUnit::getFromIndex(py->unitIndex)->getTop() < bottom)
					unitSearchFlags[py->unitIndex] = 1;
			}
		}

		// Iterate the X entries of the finder
		this->unitCount = 0;
		for (UnitFinderData *px = pLeft; px < pRight; ++px) {
			if (unitSearchFlags[px->unitIndex] == 1) {
				// If width is small, check unit bounds
				if (!isWidthExtended
					|| CUnit::getFromIndex(px->unitIndex)->getLeft() < right)
				{
					CUnit *unit = CUnit::getFromIndex(px->unitIndex);
					if (unit)
						this->units[this->unitCount++] = unit;
				}
				unitSearchFlags[px->unitIndex] = 0; //Prevent duplicates
			}
		}
	}
Beispiel #6
0
void drawPlayer(void)
{
    /* Gestion du timer */

    /* Si notre timer (un compte à rebours en fait) arrive à zéro */
    if(player.state <= WALK_DOWN) walkFrameTimer();
    else attackFrameTimer();

    /* Ensuite, on peut passer la main à notre fonction */

    /* Rectangle de destination à dessiner */
    SDL_Rect dest;

    /* On soustrait des coordonnées de notre héros, ceux du début de la map,
    pour qu'il colle au scrolling : */
    dest.x = player.x - getStartX();
    dest.y = player.y - getStartY();
    dest.w = player.w;
    dest.h = player.h;

    /* Rectangle source */
    SDL_Rect src;

    /* Pour connaître le X de la bonne frame à dessiner, il suffit de multiplier
    la largeur du sprite par le numéro de la frame à afficher -> 0 = 0; 1 = 40; 2 = 80... */

    src.x = player.frameNumber * player.w;
    src.w = player.w;
    src.h = player.h;

    /* On calcule le Y de la bonne frame à dessiner, selon la valeur de l'état du héros :
    Aucun mouvement (Idle) = 0, marche (walk) = 1, etc...
    Tout cela en accord avec notre spritesheet, of course ;) */

    src.y = player.state * player.h;

    /* Si on a été touché, et qu'on est invincible */
    int q;

    if(player.invincibleTimer > 0) q = 2;
    else q = 1;

    /* On fait clignoter le héros une frame sur deux; Pour ça, on calcule
    si le numéro de la frame est un multiple de deux */
    if(player.frameNumber % q == 0)
    {
        /* Gestion du flip (retournement de l'image selon que le sprite regarde à droite ou
        à gauche */
        const SDL_RendererFlip flip =
            player.direction == LEFT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;

        SDL_RenderCopyEx(getRenderer(), playerSpriteSheet, &src, &dest, 0, 0, flip);
    }

}
Beispiel #7
0
void Panel::setStartPosition(int x, int y)
{
	vector<Control*>::iterator it;
	for (it = items.begin(); it != items.end(); it++)
	{
		(*it)->setStartPosition((*it)->getStartX() + x, (*it)->getStartY() + y);
	}
	setStartX(getStartX() + x);
	setStartY(getStartY() + y);

}
Beispiel #8
0
void CameraSystem::fixBoundaries()
{
	auto stageSize = Constants::UI::stageSize;
	if (getEndX() > stageSize.width)
	{
		_lookAtX -= getEndX() - stageSize.width;
	}
	else if (getStartX() < 0) 
	{
		_lookAtX -= getStartX();
	}

	if (getEndY() > stageSize.height)
	{
		_lookAtY -= getEndY() - stageSize.height;
	}
	else if (getStartY() < 0) 
	{
		_lookAtY -= getStartY();
	}
}
Beispiel #9
0
void Panel::mousePressed(int x, int y, bool isLeft)
{
	int _x = getGlobalInFocus()->getStartX();
	int _y = getGlobalInFocus()->getStartY();
	int _w = getGlobalInFocus()->getWidth();
	int _h = getGlobalInFocus()->getHeight();


	if (getGlobalInFocus() != 0 && getGlobalInFocus()!=this && isInside(x, y, _x,
		_y,_w, _h))
	{
		getGlobalInFocus()->mousePressed(x, y, isLeft);
	}
	else
	{
		bool flag = false;
		
		//Moves the focus to the appropriate control
		for (vector<Control*>::iterator it = items.begin(); it != items.end(); it++)
		{
			if (isInside(x, y, (*it)->getStartX(), (*it)->getStartY(), (*it)->getWidth(), (*it)->getHeight())&& flag==false)
			{
				flag = true;
				if ((*it)->canGetFocus())
				{
					
					Control::setGlobalFocus(*it);
					getGlobalInFocus()->mousePressed(x, y, isLeft);
				}
				else
				{
					panelControlInFocus = *it;
					panelControlInFocus->mousePressed(x, y, isLeft);
				}
			}
		}

		//If the click is in the panel and not on any of its widgets set focused to this
		if (!flag && isInside(x, y, getStartX(), getStartY()+1, getWidth(), getHeight()))
		{
			//if (this->canGetFocus)
			panelControlInFocus = this;
			//Control::setGlobalFocus(this);
		}
	}
	
}
Beispiel #10
0
void CameraSystem::processEntities( artemis::ImmutableBag<artemis::Entity*>& bag )
{
	ensurePlayerEntity();
	if (nullptr != _player)
	{
		updatePosition();
		updateZoom();
		fixBoundaries();
		if (_dirty)
		{
			_graphics->setPosition(-getStartX(), -getStartY());
		}		

		// TODO:待实现Input后再补充 
		// input.setOffset(getStartX(), getStartY());
	}
}
Beispiel #11
0
/**
 * Returns the intersection of this 3D area with another 3D area. If there is
 *   no intersection, an invalid 3D area will be returned.
 *
 * @param otherArea the area to intersect this 3D area with
 * @return the 3D area that is the intersection
 */
Area3D Area3D::intersect(const Area3D &otherArea) const {
    Area3D result;

    // Check validity because of comparison operators.
    if (isValid() && otherArea.isValid()) {
        Displacement startX(std::max(getStartX(), otherArea.getStartX()));
        Displacement startY(std::max(getStartY(), otherArea.getStartY()));
        Displacement startZ(std::max(getStartZ(), otherArea.getStartZ()));
        Displacement endX(std::min(getEndX(), otherArea.getEndX()));
        Displacement endY(std::min(getEndY(), otherArea.getEndY()));
        Displacement endZ(std::min(getEndZ(), otherArea.getEndZ()));


        if (startX <= endX && startY <= endY && startZ <= endZ)
            result = Area3D(startX, startY, startZ, endX, endY, endZ);
    }

    return result;
}
Beispiel #12
0
/**
 * Moves the leftmost X position of the 3D area. This method will not change
 *   the width of the 3D area.
 *
 * @param startX the new leftmost X position
 */
void Area3D::moveStartX(const Displacement &startX) {
    setArea(startX, getStartY(), getStartZ(),
            getEndX() + (startX - getStartX()), getEndY(), getEndZ());
}
Beispiel #13
0
/**
 * Changes the height of the 3D area.
 *
 * @param height the new height of the 3D area
 */
void Area3D::setHeight(const Distance &height) {
    setArea(getStartX(), getStartY(), getStartZ(),
            getEndX(), getStartY() + height, getEndZ());
}
Beispiel #14
0
/**
 * Changes the width of the 3D area.
 *
 * @param width the new width of the 3D area
 */
void Area3D::setWidth(const Distance &width) {
    setArea(getStartX(), getStartY(), getStartZ(),
            getStartX() + width, getEndY(), getEndZ());
}
Beispiel #15
0
/**
 * Sets the bottommost Y position. This method may change the height of the
 *   3D area.
 *
 * @param endY the new bottommost Y position
 */
void Area3D::setEndY(const Displacement &endY) {
    setArea(getStartX(), getStartY(), getStartZ(),
            getEndX(), endY, getEndZ());
}
Beispiel #16
0
/**
 * Changes the depth of the 3D area.
 *
 * @param depth the new depth of the 3D area
 */
void Area3D::setDepth(const Distance &depth) {
    setArea(getStartX(), getStartY(), getStartZ(),
            getEndX(), getEndY(), getStartZ() + depth);
}
Beispiel #17
0
/**
 * Moves the backmost Z position of the 3D area. This method will not
 *   change the depth of the 3D area.
 *
 * @param endZ the new backmost Z position
 */
void Area3D::moveEndZ(const Displacement &endZ) {
    setArea(getStartX(), getStartY(), getStartZ() + (endZ - getEndZ()),
            getEndX(), getEndY(), endZ);
}
Beispiel #18
0
float CameraSystem::getWidth() const
{
	return getEndX() - getStartX();
}
Beispiel #19
0
void centerScrollingOnPlayer(void)
{
    /* Nouveau scrolling à sous-boîte limite :
    Pour éviter les effets de saccades dus à une caméra qui se centre
    automatiquement et constamment
    sur le joueur, on crée
    une "boîte" imaginaire autour du joueur.
    Quand on dépasse un de ses bords (en haut, en bas, à gauche ou à
    droite), on scrolle.
    Mais là encore, au lieu de centrer sur le joueur, on déplace
    simplement la caméra jusqu'à arriver au joueur.
    On a choisi la valeur de 3 pixels pour pouvoir avoir le plaisir
    d'aller plus vite que le cameraman
    On accélère aussi la vitesse de la caméra
    en cas de chute rapide (pour ne pas
    perdre le joueur de vue non plus. */

    int cxperso = player.x + player.w / 2;
    int cyperso = player.y + player.h / 2;
    int xlimmin = getStartX() + LIMITE_X;
    int xlimmax = xlimmin + LIMITE_W;
    int ylimmin = getStartY() + LIMITE_Y;
    int ylimmax = ylimmin + LIMITE_H;

    /* Effet de retour en arrière quand on est mort :
    Si on est très loin de la caméra, plus loin que le bord
    de la map, on accélère le scrolling : */
    if(cxperso < getStartX()) setStartX(getStartX() - 30);

    /* Si on dépasse par la gauche, on recule la caméra de 3 pixels (vous
    pouvez modifier cette valeur) */
    if(cxperso < xlimmin) setStartX(getStartX() - 3);

    /* Effet de retour en avant quand on est mort (au
    cas où le joueur s'amuse à faire le niveau à rebours
    après une checkpoint) :
    Si on est très loin de la caméra, plus loin que le bord
    de la map, on accélère le scrolling : */
    if(cxperso > getStartX() + SCREEN_WIDTH) setStartX(getStartX() + 30);

    /* Si on dépasse par la droite, on avance la caméra de 3 pixels (vous
    pouvez modifier cette valeur) */
    if(cxperso > xlimmax) setStartX(getStartX() + 3);

    /*Si on arrive au bout de la map à gauche, on stoppe le scrolling */
    if(getStartX() < 0) setStartX(0);

    /* Si on arrive au bout de la map à droite, on stoppe le scrolling à la
    valeur Max de la map - la moitié d'un écran (pour ne pas afficher du noir). */
    else if(getStartX() + SCREEN_WIDTH >= getMaxX())
        setStartX(getMaxX() - SCREEN_WIDTH);

    /* Si on dépasse par le haut, on remonte la caméra de 3 pixels (vous
    pouvez modifier cette valeur) */
    if(cyperso < ylimmin) setStartY(getStartY() - 3);

    /* Si on dépasse par le bas, on descend la caméra de 3 pixels (vous
    pouvez modifier cette valeur) */
    if(cyperso > ylimmax) setStartY(getStartY() + 3);

    /*Si on arrive au bout de la map en haut, on stoppe le scrolling */
    if (getStartY() < 0) setStartY(0);

    /*Si on arrive au bout de la map en bas, on stoppe le scrolling à la
    valeur Max de la map - la moitié d'un écran (pour ne pas afficher du noir). */
    else if (getStartY() + SCREEN_HEIGHT >= getMaxY())
        setStartY(getMaxY() - SCREEN_HEIGHT);

}
Beispiel #20
0
/**
 * Sets the Y dimension of the 3D area. This method may change the Y
 *   positions and the height of the 3D area.
 *
 * @param startY the new topmost Y position
 * @param height the new height of the 3D area
 */
void Area3D::setYDimension(const Displacement &startY,
                           const Distance &height) {
    setArea(getStartX(), startY, getStartZ(),
            getEndX(), startY + height, getEndZ());
}
Beispiel #21
0
/**
 * Sets the Z dimension of the 3D area. This method may change the Z
 *   positions and the depth of the 3D area.
 *
 * @param startZ the new frontmost Z position
 * @param depth the new depth of the 3D area
 */
void Area3D::setZDimension(const Displacement &startZ,
                           const Distance &depth) {
    setArea(getStartX(), getStartY(), startZ,
            getEndX(), getEndY(), startZ + depth);
}
Beispiel #22
0
/**
 * Moves the frontmost Z position of the 3D area. This method will not change
 *   the depth of the 3D area.
 *
 * @param startZ the new frontmost Z position
 */
void Area3D::moveStartZ(const Displacement &startZ) {
    setArea(getStartX(), getStartY(), startZ,
            getEndX(), getEndY(), getEndZ() + (startZ - getStartZ()));
}
Beispiel #23
0
/**
 * Returns the width (in the X dimension) of the 3D area.
 */
Distance Area3D::getWidth() const {
    return Distance(
               (getEndX() - getStartX()).meters(),
               Distance::Meters);
}