Exemplo n.º 1
0
void credits() {
	cpct_memset(SCR_VMEM, 0, 0x4000);
	cpct_drawStringM0 ("CREDITS", getScreenPosition(6, 0), 15, 0);

	cpct_drawStringM0 ("DEVELOPERS", getScreenPosition(5, 3), 15, 0);
	cpct_drawStringM0 ("Cesar Ivorra Oliver", getScreenPosition(1, 5), 15, 0);
	cpct_drawStringM0 ("Alex Almira Molla", getScreenPosition(1, 7), 15, 0);

	cpct_drawStringM0 ("GAME POWERED BY", getScreenPosition(2, 11), 15, 0);
	cpct_drawStringM0 ("CPCtelera", getScreenPosition(5, 13), 15, 0);

	cpct_drawStringM0 ("SPECIAL THANKS", getScreenPosition(3, 18), 15, 0);
	cpct_drawStringM0 ("Francisco Gallego", getScreenPosition(1, 20), 15, 0);

	cpct_drawStringM0 ("Press Space", getScreenPosition(4, 23), 15, 0);
	cpct_drawStringM0 ("to go main menu", getScreenPosition(2, 24), 15, 0);
	cpct_scanKeyboard_f ();
	while (!cpct_isKeyPressed(Key_Space)) {
		cpct_waitVSYNC();
		cpct_akp_musicPlay();

		cpct_scanKeyboard_f ();
	}
	gameScene=MENUSCREEN;
}
Exemplo n.º 2
0
void newLevel() {
	u8 str[6];
	initLevel();
	sprintf(str, "%2u", level);
	cpct_memset(SCR_VMEM, 0, 0x4000);
	cpct_drawStringM0 ("LEVEL", getScreenPosition(7, 11), 15, 0);
	cpct_drawStringM0 (str, getScreenPosition(13, 11), 15, 0);
	cpct_drawStringM0 ("Press Space", getScreenPosition(4, 23), 15, 0);
	cpct_drawStringM0 ("to go next level", getScreenPosition(2, 24), 15, 0);
	cpct_scanKeyboard_f ();
	while (!cpct_isKeyPressed(Key_Space)) {
		cpct_scanKeyboard_f ();
	}
	levelMode();
}
Exemplo n.º 3
0
void MainComponent::toggleMotorControl(const bool setVisible)
{
	if (setVisible)
	{
		if (benderMotorControlUIWindow == nullptr)
		{
			benderMotorControlUIWindow = new BenderMotorControlUIWindow(*this);

			if (benderMotorControlWindowState != String::empty)
			{
				benderMotorControlUIWindow->restoreWindowStateFromString (benderMotorControlWindowState);
			}
			else
			{
				benderMotorControlUIWindow->setTopLeftPosition (getScreenPosition().translated (getWidth() + 16, 0));
			}
		}
		else
		{
			benderMotorControlUIWindow->toFront (true);
		}
	}
	else
	{
		benderMotorControlWindowState = benderMotorControlUIWindow->getWindowStateAsString();
		delete benderMotorControlUIWindow.release();
	}
}
Exemplo n.º 4
0
void OpenGLComponent::paint (Graphics&)
{
    ComponentPeer* const peer = getPeer();

    if (useThread)
    {
        if (peer != nullptr && isShowing())
        {
           #if ! JUCE_LINUX
            updateContext();
           #endif

            if (! threadStarted)
            {
                threadStarted = true;
                startRenderThread();
            }
        }
    }
    else
    {
        updateContext();

        if (! renderAndSwapBuffers())
            return;
    }

    if (peer != nullptr)
    {
        const Point<int> topLeft (getScreenPosition() - peer->getScreenPosition());
        peer->addMaskedRegion (topLeft.getX(), topLeft.getY(), getWidth(), getHeight());
    }
}
Exemplo n.º 5
0
	void Menu::openMenu()
	{
		// Close all SubMenus
		for(std::vector<Menu*>::iterator it = mSubMenus.begin(); it != mSubMenus.end(); ++it)
			(*it)->closeMenu();

		Point p = getScreenPosition();

		if(mParentWidget->getClass() == "ToolBar")
		{
			ToolBar* tb = mDesc->toolBar;
			if(tb == NULL)
				throw Exception(Exception::ERR_INVALID_STATE,"Parent ToolBar reference is NULL!","Menu::openMenu");

			if(tb->getOrientation() == TOOLBAR_ORIENTATION_HORIZONTAL)
			{
				// Position the MenuList above or below the MenuTextItem - below is desired
				if((getScreenPosition().y + mDesc->widget_dimensions.size.height + mMenuPanel->getSize().height) > mDesc->guiManager->getViewport()->getActualHeight())
					p.y = mParentWidget->getScreenPosition().y - mMenuPanel->getSize().height;
				else
					p.y = mParentWidget->getScreenPosition().y + mParentWidget->getSize().height;
			}
			else // orientation is TOOLBAR_ORIENTATION_VERTICAL
			{
				// Position the MenuList to the left or right of the MenuTextItem - right is desired
				if((getScreenPosition().x + mDesc->widget_dimensions.size.width + mMenuPanel->getSize().width) > mDesc->guiManager->getViewport()->getActualWidth())
					p.x = mParentWidget->getScreenPosition().x - mMenuPanel->getSize().width;
				else
					p.x = mParentWidget->getScreenPosition().x + mParentWidget->getSize().width;
			}
		}
		else // parent class is "MenuPanel", which means this menu is a SubMenu of another Menu, or menu of a ContextMenu
		{
			// Position the MenuList to the left or right of the MenuTextItem - right is desired
			if((getScreenPosition().x + getSize().width + mMenuPanel->getSize().width) > mDesc->guiManager->getViewport()->getActualWidth())
				p.x = mParentWidget->getScreenPosition().x - mMenuPanel->getSize().width + mDesc->menu_subMenuOverlap;
			else
				p.x = mParentWidget->getScreenPosition().x + mParentWidget->getSize().width - mDesc->menu_subMenuOverlap;

			p.y = getScreenPosition().y - mMenuPanel->mSkinElement->getBorderThickness(BORDER_TOP);
		}

		mMenuPanel->setPosition(p);
		mMenuPanel->setVisible(true);
	}
Exemplo n.º 6
0
void playMenu() {
		u8 option=0;

		cpct_etm_setTileset2x4(g_tile_tileset_bg);
		cpct_etm_drawTilemap2x4_f(MAP_WIDTH_TILES, MAP_HEIGHT_TILES, SCR_VMEM, g_background);

		cpct_drawSprite (g_tile_titulo, getScreenPosition(5, 2), 32, 16);
		cpct_drawStringM0 ("PLAY GAME", getScreenPosition(5, 5), 15, 7);
		cpct_drawStringM0 ("INFINITY MODE", getScreenPosition(6, 7), 15, 7);
		cpct_drawStringM0 ("LEVELS MODE", getScreenPosition(6, 9), 15, 7);

		initScroll();
		initPlayer();
		cpct_scanKeyboard_f ();
		do {
			waitNVSYNCs(3);
			cpct_akp_musicPlay();
			Road();
			drawPlayer();
			if ( cpct_isKeyPressed (Key_Esc)) {
				gameScene=MENUSCREEN;
				return;
			}
			else if ( cpct_isKeyPressed (Key_CursorUp) && option != 0) {
				--option;
			}
			else if ( cpct_isKeyPressed (Key_CursorDown) && option != 1) {
				++option;
			}

			switch (option) {
				case 0:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(4, 9), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(4, 7), 4, 8);
					break;
				case 1:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(4, 7), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(4, 9), 4, 8);
					break;
			}
			cpct_scanKeyboard_f ();
//			waitNVSYNCs(5);
	} while (!cpct_isKeyPressed(Key_Return));

		switch (option) {
			case 0:
				cpct_akp_stop();
				gameScene=PLAYGAMESCREEN;
				break;
			case 1:
				cpct_akp_stop();
				gameScene=NEXTLEVELSCREEN;
				break;
		}
}
Exemplo n.º 7
0
void TooltipWindow::timerCallback()
{
    auto& desktop = Desktop::getInstance();
    auto mouseSource = desktop.getMainMouseSource();
    auto now = Time::getApproximateMillisecondCounter();

    auto* newComp = mouseSource.isTouch() ? nullptr : mouseSource.getComponentUnderMouse();
    auto newTip = newComp != nullptr ? getTipFor (*newComp) : String();
    bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse);
    lastComponentUnderMouse = newComp;
    lastTipUnderMouse = newTip;

    auto clickCount = desktop.getMouseButtonClickCounter();
    auto wheelCount = desktop.getMouseWheelMoveCounter();
    bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves);
    mouseClicks = clickCount;
    mouseWheelMoves = wheelCount;

    auto mousePos = mouseSource.getScreenPosition();
    bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
    lastMousePos = mousePos;

    if (tipChanged || mouseWasClicked || mouseMovedQuickly)
        lastCompChangeTime = now;

    if (isVisible() || now < lastHideTime + 500)
    {
        // if a tip is currently visible (or has just disappeared), update to a new one
        // immediately if needed..
        if (newComp == nullptr || mouseWasClicked || newTip.isEmpty())
        {
            if (isVisible())
            {
                lastHideTime = now;
                hideTip();
            }
        }
        else if (tipChanged)
        {
            displayTip (mousePos.roundToInt(), newTip);
        }
    }
    else
    {
        // if there isn't currently a tip, but one is needed, only let it
        // appear after a timeout..
        if (newTip.isNotEmpty()
             && newTip != tipShowing
             && now > lastCompChangeTime + (uint32) millisecondsBeforeTipAppears)
        {
            displayTip (mousePos.roundToInt(), newTip);
        }
    }
}
Exemplo n.º 8
0
void OpenGLComponent::paint(Graphics&)
{
  if (!this->isVisible() || getWidth()<=0 || getHeight()<=0)
    return; 
  
  ComponentPeer* const peer = getPeer();

  updateContext();
  if (peer!=nullptr)
  {
    const Point<int> topLeft (getScreenPosition() - peer->getScreenPosition());
    peer->addMaskedRegion(juce::Rectangle<int>(topLeft.getX(), topLeft.getY(), getWidth(), getHeight()));
  }
}
Exemplo n.º 9
0
CGameObject* CGameObject::onTouch(cocos2d::CCPoint point)
{
	float zoomFactor = 1.0f;//cocos2d::CCEGLView::sharedOpenGLView()->getFrameZoomFactor();
	cocos2d::CCRect bound( getScreenPosition().x - getBounds().size.width / (2.0f * zoomFactor), 
					   getScreenPosition().y - getBounds().size.height / (2.0f * zoomFactor),
					   getBounds().size.width / zoomFactor,
					   getBounds().size.height / zoomFactor);
	if (selected)
	{
		selection->removeFromParent();
	} 
	else if (bound.containsPoint(point))
	{
		selection = cocos2d::CCSprite::createWithSpriteFrameName("select-tile2.png");
		selection->setPosition(getScreenPosition());
		selection->setAnchorPoint(cocos2d::CCPoint(0.5f, 0.5f));
		selection->setScale(1.2f);
		scene->addChild(selection);
		selected = true;
		return this;
	}
	selected = false;
	return NULL;
}
Exemplo n.º 10
0
void controls() {
	cpct_memset(SCR_VMEM, 0, 0x4000);
	cpct_drawStringM0 ("CONTROLS", getScreenPosition(5, 3), 15, 0);

	cpct_drawStringM0 ("W: Move Up", getScreenPosition(4, 7), 15, 0);
	cpct_drawStringM0 ("S: Move Down", getScreenPosition(4, 9), 15, 0);
	cpct_drawStringM0 ("A: Move Left", getScreenPosition(4, 11), 15, 0);
	cpct_drawStringM0 ("D: Move Right", getScreenPosition(4, 13), 15, 0);

	cpct_drawStringM0 ("Press Space", getScreenPosition(4, 23), 15, 0);
	cpct_drawStringM0 ("to go main menu", getScreenPosition(2, 24), 15, 0);

	cpct_scanKeyboard_f ();
	while (!cpct_isKeyPressed(Key_Space)) {
		cpct_waitVSYNC();
		cpct_akp_musicPlay();
		cpct_scanKeyboard_f ();
	}
	// gameScene=MENUSCREEN;
	gameScene=MENUSCREEN;
}
Exemplo n.º 11
0
 Point<float> globalToLocal (Point<float> screenPosition) override
 {
     return screenPosition - getScreenPosition().toFloat();
 }
Exemplo n.º 12
0
 Point<float> localToGlobal (Point<float> relativePosition) override
 {
     return relativePosition + getScreenPosition().toFloat();
 }
Exemplo n.º 13
0
 Point<int> localToGlobal (const Point<int>& relativePosition)
 {
     return relativePosition + getScreenPosition();
 }
Exemplo n.º 14
0
int MouseEvent::getScreenY() const                              {
    return getScreenPosition().y;
}
Exemplo n.º 15
0
int MouseEvent::getScreenX() const                              {
    return getScreenPosition().x;
}
Exemplo n.º 16
0
void mainMenu() {
		u8 option=0;
		cpct_etm_setTileset2x4(g_tile_tileset_bg);
		cpct_etm_drawTilemap2x4_f(MAP_WIDTH_TILES, MAP_HEIGHT_TILES, SCR_VMEM, g_background);

		cpct_drawSprite (g_tile_titulo, getScreenPosition(5, 2), 32, 16);
		cpct_drawStringM0 ("PLAY GAME", getScreenPosition(5, 5), 15, 7);
		cpct_drawStringM0 ("CONTROLS", getScreenPosition(5, 7), 15, 7);
		cpct_drawStringM0 ("CREDITS", getScreenPosition(5, 9), 15, 7);

		initScroll();
		initPlayer();
		cpct_scanKeyboard_f ();
		do {
		    waitNVSYNCs(3);
			cpct_akp_musicPlay();

			Road();
			drawPlayer();
			if ( cpct_isKeyPressed (Key_CursorUp) && option != 0) {
				--option;
			}
			else if ( cpct_isKeyPressed (Key_CursorDown) && option != 2) {
				++option;
			}

			switch (option) {
				case 0:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 7), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(3, 5), 4, 8);
					break;
				case 1:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 5), 4, 8);
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 9), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(3, 7), 4, 8);
					break;
				case 2:
					cpct_drawSprite(g_tile_sky_blue, getScreenPosition(3, 7), 4, 8);
					cpct_drawSprite(sprite_skate, getScreenPosition(3, 9), 4, 8);
					break;
			}
			cpct_scanKeyboard_f ();
//			waitNVSYNCs(5);
	} while (!cpct_isKeyPressed(Key_Return));

		switch (option) {
    		case 0:	playMenu();
				break;
    		case 1: 
				gameScene=CONTROLSSCREEN;
				break;
		    case 2: 
				gameScene=CREDITSSCEENE;
				break;
		}
}
Exemplo n.º 17
0
 Point<int> globalToLocal (const Point<int>& screenPosition)
 {
     return screenPosition - getScreenPosition();
 }
Exemplo n.º 18
0
void PolycodeEditor::Resize(int x, int y) {
	editorSize = Vector2(x,y);
	Vector2 pos = getScreenPosition();
	scissorBox.setRect(pos.x,pos.y, x, y);	
}
Exemplo n.º 19
0
 Point<int> globalToLocal (Point<int> screenPosition) override
 {
     return screenPosition - getScreenPosition();
 }