Beispiel #1
0
void Feature::resetFeatureScript(uint16 enabled, uint16 scrbId) {
	if (!scrbId)
		scrbId = _scrbId;
	if (scrbId != _scrbId || _needsReset) {
		if (_needsReset)
			_data.bounds = Common::Rect();
		_scrbId = scrbId;
		_view->getnthScriptSetGroup(_data.scrbIndex, _data.compoundSHAPIndex, scrbId);
	}
	if (_data.scrbIndex == 0xFFFF) {
		_data.enabled = 0;
		_data.bitmapIds[0] = 0;
		_data.scrbIndex = 0;
		_data.compoundSHAPIndex = 0;
		resetFrame();
		return;
	}

	resetScript();
	resetFrame();
	_nextTime = 0; // New feature code uses _view->_lastIdleTime, but should be equivalent.
	_data.enabled = enabled;
	_dirty = 1;

	finishResetFeatureScript();

	_needsReset = 0;

	if (_region) {
		// TODO: mark _region as dirty
	} else {
		// TODO: mark _data.bounds as dirty
	}
}
bool Controller::init(cocos2d::Layer *layer, float positionY){
	_layer = layer;
	_positionY = positionY;
	visibleSize = Director::getInstance()->getVisibleSize();

	//创建边界框
	edge = Edge::create();
	edge->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2+positionY));
	edge->setContentSize(visibleSize);
	_layer->addChild(edge);

	//创建地板
	auto ground = Sprite::create();
	ground->setTextureRect(Rect(0, 0, visibleSize.width, 3));
	ground->setPosition(Vec2(visibleSize.width / 2, 1.5 + positionY));
	ground->setColor(Color3B(0, 0, 0));
	_layer->addChild(ground);

	//创建圆圈
	circle = Sprite::create("circle.png");
	auto circleBody = PhysicsBody::createCircle(circle->getContentSize().width / 2);
	circle->setPhysicsBody(circleBody);
	circle->setPosition(Vec2(50, circle->getContentSize().height/2+positionY+80));
	_layer->addChild(circle);
	circle->getPhysicsBody()->setContactTestBitmask(1);

	resetFrame();

	return true;
}
bool GameController::init(Layer* layer, float positionY)
{
	this->layer = layer;
	this->positionY = positionY;
	this->size = Director::getInstance()->getWinSize();

	//¿ØÖÆÆ÷±ßÔµ
	edge = Edge::create();
	edge->setPosition(Point(0, positionY));
	layer->addChild(edge);

	//½µØ
	auto ground = Sprite::create();
	ground->setTextureRect(Rect(0, 0, size.width, 3));
	ground->setColor(Color3B(0, 0, 0));
	ground->setPosition(Point(size.width / 2, positionY + 1.5));
	layer->addChild(ground);

	//СÈË
	hero = Hero::create();
	hero->setPosition(Point(100, hero->getContentSize().height / 2 + positionY));
	layer->addChild(hero);

	//ÉèÖÃ֡ƵÂÊ
	resetFrame();

	return true;
}
//
// must be called inside a draw routine
// requires a valid graphics context
//
void gstTextureManager::glinit() {
  //
  // create a checkered texture for the invalid regions
  GLubyte checkImage[CHECK_IMAGE_SIZE][CHECK_IMAGE_SIZE][3];
  GLubyte c;
  for (int i = 0; i < CHECK_IMAGE_SIZE; i++) {
    for (int j = 0; j < CHECK_IMAGE_SIZE; j++) {
      c = ((((i & 0x8) == 0) ^ ((j & 0x8)) == 0)) * 100;  // + 100;
      checkImage[i][j][0] = c;
      checkImage[i][j][1] = c;
      checkImage[i][j][2] = c;
    }
  }

  glBindTexture(GL_TEXTURE_2D, CHECK_IMAGE_ID);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
               CHECK_IMAGE_SIZE, CHECK_IMAGE_SIZE, 0,
               GL_RGB, GL_UNSIGNED_BYTE, checkImage);


  // indicate no texture loads are pending
  resetFrame();
}
/**
  Constructor.

  \param outerGap Distance between the frame and the surrounding parts of the chart.
  \param innerGap Distance between the frame and inner area.
  \param addFrameWidthToLayout If true, shrink inner area so the area AND its frame will occupy
  the same space of the chart as the area would occupy if no frame were drawn.
  If false, the frame is drawn around the area without taking care not to override other
  content of the chart.
  \param frame The frame settings to be used for this area. The values of this parameter
  will be copied into a KDFrame object stored internally in this KDChartFrameSettings so
  it is save to use the same KDFrame object for specifying the settings of more than one area.
  */
KDChartParams::KDChartFrameSettings::KDChartFrameSettings(
        uint           dataRow,
        uint           dataCol,
        uint           data3rd,
        const KDFrame& frame,
        int            outerGapX,
        int            outerGapY,
        int            innerGapX,
        int            innerGapY,
        bool           addFrameWidthToLayout,
        bool           addFrameHeightToLayout )
  : _dataRow( dataRow ),
    _dataCol( dataCol ),
    _data3rd( data3rd ),
    _frame( 0 ),
    _outerGapX( outerGapX ),
    _outerGapY( outerGapY ),
    _innerGapX( innerGapX ),
    _innerGapY( innerGapY ),
    _addFrameWidthToLayout(  addFrameWidthToLayout ),
_addFrameHeightToLayout( addFrameHeightToLayout )
{
    resetFrame();
    KDFrame::deepCopy(*_frame, frame);
}
Beispiel #6
0
void GameController::update() {
//    log("<<<1update, %d, %d", _currenFrame, _nextFrameCount);
    _currenFrame++;
    if (_currenFrame >= _nextFrameCount) {
        resetFrame();
        addBlock();
    }
}
Beispiel #7
0
////////////////////////////////////////////////////////////////////////////////
// Animation Info Methods                                                     //
////////////////////////////////////////////////////////////////////////////////
void Paddle::AnimationInfo::start()
{
    KABOOM_DLOG("Starting paddle hit timer");

    resetFrame();

    timer.stop();
    timer.start();
}
void GameController::onUpdate()
{
	//Ìí¼Ó¿é
	curFrame++;
	if (curFrame >= nextFrame)
	{
		resetFrame();
		addBlock();
	}
}
Beispiel #9
0
void Composition::setActiveMarker(Marker *marker, float speed)
{
	int from = marker->getFrom();
	int length = max(marker->getLength(), 1);
	frame_.setSpeed(speed);
	frame_.setRange(from, length);
	frame_.setLoopState(FrameCounter::LOOP_NONE);
	frame_.setLoopState(marker->getLoopState());
	active_marker_ = marker;
	resetFrame(0);
}
Beispiel #10
0
	bool Output::startDeckLink(BMDDisplayMode mode)
	{
		IDeckLinkDisplayModeIterator* pDLDisplayModeIterator = NULL;
		IDeckLinkDisplayMode* pDLDisplayMode = NULL;

		if (pDLOutput->GetDisplayModeIterator(&pDLDisplayModeIterator) == S_OK)
		{
			while (pDLDisplayModeIterator->Next(&pDLDisplayMode) == S_OK)
			{
				if (pDLDisplayMode->GetDisplayMode() == mode)
				{
					break;
				}
			}

			pDLDisplayModeIterator->Release();
		}

		if (!pDLDisplayMode)
		{
			ofLogError("ofxDeckLinkAPI::Output") << "invalid display mode";
			return false;
		}

		uiFrameWidth = pDLDisplayMode->GetWidth();
		uiFrameHeight = pDLDisplayMode->GetHeight();

		pixels[0].allocate(uiFrameWidth, uiFrameHeight, 4);
		pixels[1].allocate(uiFrameWidth, uiFrameHeight, 4);

		front_buffer = &pixels[0];
		back_buffer = &pixels[1];

		pDLDisplayMode->GetFrameRate(&frameDuration, &frameTimescale);

		uiFPS = ((frameTimescale + (frameDuration - 1)) / frameDuration);

		if (pDLOutput->EnableVideoOutput(pDLDisplayMode->GetDisplayMode(), bmdVideoOutputFlagDefault) != S_OK)
			return false;

		if (pDLOutput->CreateVideoFrame(uiFrameWidth, uiFrameHeight, uiFrameWidth * 4, bmdFormat8BitARGB, bmdFrameFlagDefault, &pDLVideoFrame) != S_OK)
			return false;

		uiTotalFrames = 0;

		resetFrame();
		setPreroll();

		pDLOutput->StartScheduledPlayback(0, frameTimescale, 1);

		return true;
	}
void SimpleAnimator::setSettings(QPixmap &sprite, bool enables, int framesq, int fspeed, int First, int Last, bool rev, bool bid)
{
    m_texture = &sprite;
    m_animated = enables;
    m_frameFirst = First;
    m_frameLast = Last;
    m_currentFrame = 0;
    ticks_left = 0.0f;

    m_frame_sequance_enabled=false;
    m_frame_sequance_cur=0;

    m_bidirectional = bid;
    m_reverce = rev;

    m_frameDelay = fspeed;
    frame_delay = fspeed;
    m_framesCount = framesq;

    if(m_texture->isNull())
    {
        m_animated=false;
        LogWarning("SimpleAnimator can't work with null images");
        return;
    }

    m_frameWidth = m_texture->width();
    m_spriteHeight = m_texture->height();

    // Frame must not be less than 1 pixel
    if( m_framesCount > m_spriteHeight)
        m_framesCount = m_frameHeight;

    if(m_framesCount <= 0) //Avoid SIGFPE if so small image while so much frames
        m_framesCount = 1;

    if(m_animated)
        m_frameHeight = qRound(qreal(m_spriteHeight/m_framesCount));
    else
        m_frameHeight = m_spriteHeight;
    m_framePos = QPoint(0,0);

    //createAnimationFrames();

    resetFrame();

//    connect(
//                &timer, SIGNAL(timeout()),
//                this,
//                SLOT( nextFrame() ) );
}
/**
  Constructor. Setting default values.
  */
KDChartParams::KDChartFrameSettings::KDChartFrameSettings()
{
    _dataRow = 0;
    _dataCol = 0;
    _data3rd = 0;
    _frame   = 0;
    resetFrame();
    _outerGapX = 0;
    _outerGapY = 0;
    _innerGapX = 0;
    _innerGapY = 0;
    _addFrameWidthToLayout = true;
    _addFrameHeightToLayout = true;
}
bool GifDecoder::readBitmap(DataBlock* dataBlock)
{
	uint8_t packed;
	if (!dataBlock->read(&ix) || !dataBlock->read(&iy) ||  // (sub)image position & size
		!dataBlock->read(&iw) || !dataBlock->read(&ih) || !dataBlock->read(&packed, 1)) {
		return false;
	}

	bool lctFlag = (packed & 0x80) != 0; // 1 - local color table flag interlace
	int32_t lctSize = 2 << (packed & 0x07);
	// 3 - sort flag
	// 4-5 - reserved lctSize = 2 << (packed & 7); // 6-8 - local color
	// table size
	interlace = (packed & 0x40) != 0;
	uint32_t lct[256];
	uint32_t* act;
	if (lctFlag) {
		if (!readColorTable(dataBlock, lct, lctSize)) { // read table
			return false;
		}
		act = lct; // make local table active
	} else {
		act = gct; // make global table active
		if (bgIndex == transIndex) {
			bgColor = 0;
		}
	}
	uint32_t save;
	if (transparency) {
		save = act[transIndex];
		act[transIndex] = 0; // set transparent color if specified
	}

	if (!decodeBitmapData(dataBlock) || !skip(dataBlock)) { // decode pixel data
		return false;
	}

	frameCount++;
	// create new image to receive frame data
	setPixels(act); // transfer pixel data to image

	if (transparency) {
		act[transIndex] = save;
	}
	resetFrame();
	return true;
}
//分别生成上面和下面的障碍物
void Controller::obstacleUpdate(float dt){
	currentFrameIndex++;

	if (currentFrameIndex >= nextFrameCount)
	{
		if (currentFrameIndex % 2 == 0)
		{
			downObstacle1();
			upObstacle1();
		}
		else
		{
			downObstacle2();
			upObstacle2();
		}
		resetFrame();
	}
}
Beispiel #15
0
void GrManagerImpl::endFrame()
{
	LockGuard<Mutex> lock(m_globalMtx);

	PerFrame& frame = m_perFrame[m_frame % MAX_FRAMES_IN_FLIGHT];

	// Wait for the fence of N-2 frame
	U waitFrameIdx = (m_frame + 1) % MAX_FRAMES_IN_FLIGHT;
	PerFrame& waitFrame = m_perFrame[waitFrameIdx];
	if(waitFrame.m_presentFence)
	{
		waitFrame.m_presentFence->wait();
	}

	resetFrame(waitFrame);

	if(!frame.m_renderSemaphore)
	{
		ANKI_LOGW("Nobody draw to the default framebuffer");
	}

	// Present
	VkResult res;
	VkPresentInfoKHR present = {};
	present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
	present.waitSemaphoreCount = (frame.m_renderSemaphore) ? 1 : 0;
	present.pWaitSemaphores = (frame.m_renderSemaphore) ? &frame.m_renderSemaphore->getHandle() : nullptr;
	present.swapchainCount = 1;
	present.pSwapchains = &m_swapchain;
	present.pImageIndices = &m_crntBackbufferIdx;
	present.pResults = &res;

	ANKI_VK_CHECKF(vkQueuePresentKHR(m_queue, &present));
	ANKI_VK_CHECKF(res);

	m_transientMem.endFrame();

	// Finalize
	++m_frame;
}
void SimpleAnimator::stop()
{
    if(!m_animated) return;
    resetFrame();
}
Beispiel #17
0
void AnimatedSprite::setCurrentAnimation(unsigned short anim_id)
{
    current_animation = anim_id;
    resetFrame();
}
Beispiel #18
0
void Composition::resetFrameByRatio(float ratio)
{
	resetFrame(ofMap(ratio, 0, 1, 0, frame_.getLength()-1));
}
void GameplayFrame::DrawGame(Core::Graphics& graphics)
{
	PROFILE("Total Draw");
	myBackground.DrawBackdrop(graphics);
	graphics.SetColor( RGB( 255, 255, 255));
	char buf[50];
	sprintf_s(buf, "%f", debugTime);
	graphics.DrawString(35,980, buf);
	graphics.DrawString(5, 980, "FPS:");
	healthBar.DrawHealth(graphics);
	fuelGauge.DrawPlayerFuel(graphics);
	graphics.SetColor(RGB(51,51,51));
	boundaries.Draw(graphics);
	{
		PROFILE("Draw Planets");
		creator.DrawPlanets(graphics);
	}
	graphics.SetColor( RGB( 255, 255, 255));
	{
		PROFILE("Draw Enemies");
		tester.drawShips(graphics);
	}
	{
		PROFILE("Draw Particles");
		myParticles.drawEffect(graphics);
	}
	myText.drawText(graphics);
	graphics.SetColor(RGB(255,255,255));
	Vector2D fuel(fuelStation[1].x+(fuelStation[3].x-fuelStation[1].x)/4.5f, (fuelStation[0].y + ((fuelStation[2].y-fuelStation[0].y)/2.5f)));
	gameText.drawText(graphics, 4.0f, RGB(255,255,255), "Fueling", 20.0f, 5.0f, 0, fuel);
	gameText.drawText(graphics, 4.0f, RGB(255,255,255), "Station", 20.0f, 5.0f, 0, Vector2D(fuel.x, fuel.y + 35.0f));
	myCash.DrawCash(graphics, 5.0f);
	healthDrop.DrawHealthPickup(graphics);
	graphics.SetColor( RGB(255, 255, 255));
	graphics.DrawString(30, 100, "PRESS I TO OPEN/CLOSE THE LIST OF INSTRUCTIONS.");
	DebugFrameMemory(graphics);
	graphics.SetColor( RGB( 255, 100, 0));
	{
		ranger.Draw(graphics);
	}
	//rapidFirePowerup.drawPowerup(graphics);
	if(alreadyKilled)
	{
		char buf[50];
		sprintf_s(buf, "You survived for %i seconds!", (int)totalTime);
		Core::RGB textColor = RGB(255, 149, 0);
		gameText.drawText(graphics,  5.0f, textColor, "GAME OVER...", 30.0f, 5.0f, 0, Vector2D(250.0f, 250.0f));
		gameText.drawText(graphics,  5.0f, textColor, buf, 30.0f, 5.0f, 0, Vector2D(680.0f, 250.0f));
		graphics.SetColor(RGB(255,100,0));
		graphics.DrawString(700, 500, "Game over, you have died and as thus you are");
		graphics.DrawString(700, 520, "reading this screen. If you wish to try again");
		graphics.DrawString(700, 540, "simply press the space bar to reset the game. Yep...");
		graphics.DrawString(700, 560, "why are you still reading this?? I mean I");
		graphics.DrawString(700, 580, "don't care but you are kind of wasting your");
		graphics.DrawString(700, 600, "time at this point.");
		if(Core::Input::IsPressed(32))
		{
			resetFrame();
		}
	}
	if(paused && upgradesPause)
	{
		armorUpgrade.DrawUpgrade(graphics, mouse, 3.0f);
		healthDropUpgrade.DrawUpgrade(graphics, mouse, 3.0f);
		bulletsUpgrade.DrawUpgrade(graphics, mouse, 3.0f);
		fuelUpgrade.DrawUpgrade(graphics, mouse, 3.0f);
	}
	else if(paused && instructionsPause)
	{
		graphics.DrawString(825, 430, "	(Press I to close/open the list of instructions.)");
		graphics.DrawString(800, 450, "	Instructions: use up, down, W or S to move the ship. A and D");
		graphics.DrawString(800, 470, "or left and right to rotate the spaceship. Use the left mouse");
		graphics.DrawString(800, 490, "to fire your turret. Keep in mind that only ten bullets can");
		graphics.DrawString(800, 510, "be on the screen at once and that the sun in the background");
		graphics.DrawString(800, 530, "is simply for ambiance.");
		graphics.DrawString(800, 570, "	Upgrades: Use the cash that you have earned to purchase");
		graphics.DrawString(800, 590, "the upgrades. To open the upgrade menu press R. You can");
		graphics.DrawString(800, 610, "view individual upgrade information by hovering over the tiles.");
		graphics.DrawString(800, 650, "Fueling: Your fuel will slowly decrease as time goes on...because");
		graphics.DrawString(800, 670, "you know.....space....well anyway drive over the aptly named");
		graphics.DrawString(800, 690, "'FUELING STATION' to fuel your ship. You can't, however, fire");
		graphics.DrawString(800, 710, "your turret while you are fueling, because that is illegal.");
		graphics.DrawString(800, 750, "Damage: When an enemy ship collides with you, you'll take");
		graphics.DrawString(800, 770, "some damage. If you have the armor upgrades then your armor");
		graphics.DrawString(800, 790, "will absorb the first chuncks of damage. Each ship has a");
		graphics.DrawString(800, 810, "one second spawn delay from being able to damage your ship");
		graphics.DrawString(800, 830, "as well as a three second delay from the game starting to");
		graphics.DrawString(800, 850, "being able to damage your spacecraft.");
	}

}
Beispiel #20
0
Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
{
	ANKI_LOGI("Initializing Vulkan backend");
	ANKI_CHECK(initInstance(init));
	ANKI_CHECK(initSurface(init));
	ANKI_CHECK(initDevice(init));
	vkGetDeviceQueue(m_device, m_queueIdx, 0, &m_queue);
	ANKI_CHECK(initSwapchain(init));

	{
		VkPipelineCacheCreateInfo ci = {};
		ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
		vkCreatePipelineCache(m_device, &ci, nullptr, &m_pplineCache);
	}

	ANKI_CHECK(initMemory(*init.m_config));
	ANKI_CHECK(m_dsetAlloc.init(getAllocator(), m_device));
	m_pplineLayFactory.init(getAllocator(), m_device, &m_dsetAlloc.getDescriptorSetLayoutFactory());

	for(PerFrame& f : m_perFrame)
	{
		resetFrame(f);
	}

	glslang::InitializeProcess();
	m_fences.init(getAllocator(), m_device);
	m_semaphores.init(getAllocator(), m_device);

	m_queryAlloc.init(getAllocator(), m_device);

	m_samplerCache = getAllocator().newInstance<GrObjectCache>(m_manager);

	// Set m_r8g8b8ImagesSupported
	{
		VkImageFormatProperties props = {};
		VkResult res = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice,
			VK_FORMAT_R8G8B8_UNORM,
			VK_IMAGE_TYPE_2D,
			VK_IMAGE_TILING_OPTIMAL,
			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
			0,
			&props);

		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
		{
			ANKI_LOGI("R8G8B8 Images are not supported. Will workaround this");
			m_r8g8b8ImagesSupported = false;
		}
		else
		{
			ANKI_ASSERT(res == VK_SUCCESS);
			ANKI_LOGI("R8G8B8 Images are supported");
			m_r8g8b8ImagesSupported = true;
		}
	}

	// Set m_s8ImagesSupported
	{
		VkImageFormatProperties props = {};
		VkResult res = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice,
			VK_FORMAT_S8_UINT,
			VK_IMAGE_TYPE_2D,
			VK_IMAGE_TILING_OPTIMAL,
			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
			0,
			&props);

		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
		{
			ANKI_LOGI("S8 Images are not supported. Will workaround this");
			m_s8ImagesSupported = false;
		}
		else
		{
			ANKI_ASSERT(res == VK_SUCCESS);
			ANKI_LOGI("S8 Images are supported");
			m_s8ImagesSupported = true;
		}
	}

	// Set m_d24S8ImagesSupported
	{
		VkImageFormatProperties props = {};
		VkResult res = vkGetPhysicalDeviceImageFormatProperties(m_physicalDevice,
			VK_FORMAT_D24_UNORM_S8_UINT,
			VK_IMAGE_TYPE_2D,
			VK_IMAGE_TILING_OPTIMAL,
			VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
			0,
			&props);

		if(res == VK_ERROR_FORMAT_NOT_SUPPORTED)
		{
			ANKI_LOGI("D24S8 Images are not supported. Will workaround this");
			m_d24S8ImagesSupported = false;
		}
		else
		{
			ANKI_ASSERT(res == VK_SUCCESS);
			ANKI_LOGI("D24S8 Images are supported");
			m_d24S8ImagesSupported = true;
		}
	}

	return ErrorCode::NONE;
}