Command *Command::opIsAnimAtTime(const ResourceReference &animRef, int32 time) { Anim *anim = animRef.resolve<Anim>(); bool condition = !anim->isInUse() || anim->isAtTime(time); return nextCommandIf(condition); }
/** * Draw episode 1 guardian. * * @param ticks Time * @param change Time since last iteration */ void MedGuardian::draw(unsigned int ticks, int change) { Anim *stageAnim; unsigned char frame; if (next) next->draw(ticks, change); fixed xChange = getDrawX(change); fixed yChange = getDrawY(change); frame = ticks / (set->animSpeed << 5); if (stage == 0) stageAnim = anim; else stageAnim = level->getAnim(set->anims[E_LFINISHANIM | (animType & 1)] & 0x7F); if (ticks < flashTime) stageAnim->flashPalette(0); drawnX = x + anim->getXOffset(); drawnY = y + anim->getYOffset() + stageAnim->getOffset(); stageAnim->draw(xChange, yChange); if (ticks < flashTime) stageAnim->restorePalette(); return; }
Command *Command::opAnimSetFrame(const ResourceReference &animRef, const ResourceReference &knowledgeRef) { Anim *anim = animRef.resolve<Anim>(); Knowledge *knowledge = knowledgeRef.resolve<Knowledge>(); anim->selectFrame(knowledge->getIntegerValue()); return nextCommand(); }
// Get an Anim from an Image Anim GetAnimFromImage(const sf::Image& img, float height, float width, int howMany) { // Add each frame Anim anim; for (int i=0; i<howMany; i++) anim.PushFrame(Frame(img, sf::IntRect(width*i, 0, width * (i+1), height))); return anim; }
/** * Draw spring event. * * @param ticks Time * @param change Time since last iteration */ void SpringJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); switch (type) { case 60: // Frozen green spring an = jj2Level->getAnim(animSet, 5, flipped); break; case 62: // Spring crate an = jj2Level->getAnim(animSet, 0, flipped); break; case 85: // Red spring an = jj2Level->getAnim(animSet, 7, flipped); break; case 86: // Green spring an = jj2Level->getAnim(animSet, 5, flipped); break; case 87: // Blue spring an = jj2Level->getAnim(animSet, 0, flipped); break; default: return; } an->setFrame(0, true); an->draw(drawX + F16, drawY + F16); return; }
Command *Command::opItemSetActivity(Script *script, const ResourceReference &itemRef, int32 animActivity, bool wait) { Item *item = itemRef.resolve<Item>(); ItemVisual *sceneItem = item->getSceneInstance(); Anim *actionAnim = sceneItem->getActionAnim(); if (wait && actionAnim) { assert(actionAnim->getSubType() == Anim::kAnimSkeleton || actionAnim->getSubType() == Anim::kAnimVideo); script->suspend(actionAnim); return this; } else { resumeItemSetActivity(); return nextCommand(); } }
/** * Draw the bird. * * @param ticks Time * @param change Time since last step */ void JJ1Bird::draw (unsigned int ticks, int change) { Anim *anim; if (next) next->draw(ticks, change); anim = level->getAnim((player->getFacing() || fleeing)? BIRD_RIGHTANIM: BIRD_LEFTANIM); anim->setFrame(ticks / 80, true); anim->draw(getDrawX(change), getDrawY(change)); return; }
void EasingApp::mouseDown(MouseEvent event) { end_pos = event.getPos(); timeline().apply(¤t_pos, end_pos.value(), 1.0f, easeOutInCirc); }
Command *Command::opPlayAnimation(Script *script, const ResourceReference &animRef, bool suspend) { Anim *anim = animRef.resolve<Anim>(); Item *item = anim->findParent<Item>(); ItemVisual *sceneItem = item->getSceneInstance(); sceneItem->setMovement(nullptr); sceneItem->playActionAnim(anim); if (suspend) { anim->shouldResetItem(false); // The script system will take care of that when resuming script->suspend(anim); return this; // Stay on the same command while suspended } else { return nextCommand(); } }
/** * @fn Anim* createAnim(const char filename[], std::vector< sf::Rect<int> > rects, const char name[]) * * @brief Creates an animation but do not add it for update & draw. * * @param filename Filename of the file. * @param rects The rectangles. * @param name The name. * * @return null if it fails, else the new animation. */ Anim* createAnim(const char filename[], std::vector< sf::Rect<int> > rects, const char name[]) { sf::Image image; image = MediaManager<sf::Image>::getInstance().getMedia(filename); Anim* anim; anim = new Anim; std::vector< sf::Rect<int> >::iterator it(rects.begin()); for(; it != rects.end(); it++) { anim->pushFrame(Frame(image, *(it))); } return anim; }
void PhotoBoothApp::touchesBegan( TouchEvent event ){ TouchEvent::Touch touch = event.getTouches().front(); Vec2f cameraButtonTargetPos = Vec2f(mCameraButtonPos.value()); float touchX = touch.getX() / DISPLAY_SCALE; float touchY = touch.getY() / DISPLAY_SCALE; switch(mCurrentState) { case STATE_PREVIEW: // see if the camera icon has been tapped (touch coordinates are reversed for landscape mode) cameraButtonTargetPos.x += mCameraButtonTexture.getWidth() / 2.0f; cameraButtonTargetPos.y += mCameraButtonTexture.getHeight() / 2.0f; if( cameraButtonTargetPos.distance( Vec2f(touchX, touchY) ) < (mCameraButtonTexture.getWidth() * 2) ) { mCountDownStartTime = getElapsedSeconds(); mCurrentState = STATE_COUNT_DOWN; } break; case STATE_COUNT_DOWN: // stub.. break; case STATE_ACCEPT: if(touchY > 1280) { // only look for touches near the bottom of the screen. // just split the screen in half, no need to do precise hit detection for save/cancel buttons.. if(touchX > width / 2){ ip::flipVertical( &mCameraSurface ); cinder::cocoa::SafeUiImage img = cocoa::createUiImage( mCameraSurface ); // Call into objective C to do upload via cocoa FileSender::sendFile(img); timeline().apply( &mPreviewTexturePos, Vec2f(0, -height ), 1.0f, EaseInCubic() ); }else{ timeline().apply( &mPreviewTexturePos, Vec2f(0, height ), 1.0f, EaseInBack() ); } mCurrentState = STATE_PREVIEW; timeline().apply( &mDarkBgAlpha, 0.0f, 1.0f, EaseInCubic() ); // Hide buttons timeline().apply( &mDiscardPos, Vec2f(100, height + 100 ), 1.0f, EaseInCubic() ); timeline().apply( &mSavePos, Vec2f(width-700, height + 100 ), 1.0f, EaseInCubic() ); } break; } }
void InstascopeApp::resetSample() { // reset sample pos mSampleSize = randInt(100, 300); mSamplePt.value().y = randFloat(0, getWindowWidth() - mSampleSize); mSamplePt.value().x = randFloat(0, getWindowHeight() - mSampleSize); vec2 newPos; int count = 0; // Try to find a good sample location thats within the window's frame. // Give up if we try and settle after a bunch of times, no big deal. do { newPos.x = randFloat(0, getWindowWidth() - mSampleSize/2); newPos.y = randFloat(0, getWindowHeight() - mSampleSize/2); count++; } while(count < 150 && ((mSamplePt.value().x - newPos.x) < 100 || (mSamplePt.value().y - newPos.y) < 100)); timeline().apply(&mSamplePt, newPos, MIRROR_DUR - 1, EaseInOutQuad()).delay(.5); }
/** * Draw food pickup event. * * @param ticks Time * @param change Time since last iteration */ void FoodJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); // Use look-up table if (!endTime) an = jj2Level->getAnim(animSet, pickupAnims[type], flipped); else an = jj2Level->getAnim(animSet, 86, flipped); an->setFrame((int)ticks / 60, true); an->draw(drawX + F16, drawY + F16 + F32); return; }
/** * Draw ammo pickup event. * * @param ticks Time * @param change Time since last iteration */ void AmmoJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); /// @todo Check if ammo is powered up if (!endTime) an = jj2Level->getAnim(0, ammoAnims[type - 33], flipped); else an = jj2Level->getAnim(animSet, 86, flipped); an->setFrame((int)ticks / 60, true); an->draw(drawX + F16, drawY + F16 + F32); return; }
/** * Draw the event's energy bar * * @param ticks Time */ void Event::drawEnergy (unsigned int ticks) { Anim* anim; int hits; if (!set || set->modifier != 8) { if (next) next->drawEnergy(ticks); return; } else if (set->strength) { // Draw boss energy bar hits = level->getEventHits(gridX, gridY) * 100 / set->strength; // Devan head anim = level->getMiscAnim(1); anim->setFrame(0, true); if (ticks < flashTime) anim->flashPalette(0); anim->draw(ITOF(viewW - 44), ITOF(hits + 48)); if (ticks < flashTime) anim->restorePalette(); // Bar drawRect(viewW - 40, hits + 40, 12, 100 - hits, (ticks < flashTime)? 0: 32); } return; }
void Costume::load(string dirPath) { Log::write(LOG_INFO, "Costume\n"); Log::indent(); XMLFile xmlFile; xmlFile.open(dirPath + XML_FILE_NAME); XMLNode *rootNode = xmlFile.getRootNode(); _name = rootNode->getChild("name")->getStringContent(); Log::write(LOG_INFO, "name: %s\n", _name.c_str()); _mirror = rootNode->getChild("mirror")->getBooleanContent(); Log::write(LOG_INFO, "mirror: %d\n", _mirror); int i = 0; XMLNode *child; while ((child = rootNode->getChild("anim", i++)) != NULL) { Anim *anim = new Anim(); anim->load(child); _anims.push_back(anim); } i = 0; while ((child = rootNode->getChild("frame", i++)) != NULL) { Frame *frame = new Frame(); frame->load(child, dirPath); _frames.push_back(frame); } _paletteData = new PaletteData(); _paletteData->load(dirPath); Log::unIndent(); }
/** * Draw placeholder event. * * @param ticks Time * @param change Time since last iteration */ void OtherJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); switch (type) { default: if ((type <= 221) && pickupAnims[type]) { an = jj2Level->getAnim(animSet, pickupAnims[type], flipped); an->setFrame((int)ticks / 60, true); an->draw(drawX + F16, drawY + F16 + F32); } else if (!endTime) { drawRect(FTOI(drawX) + 8, FTOI(drawY) + 8, 16, 16, type); } panelBigFont->showNumber(type, FTOI(drawX) + 24, FTOI(drawY) + 12); return; } an->draw(drawX + F16, drawY + F16); return; }
/** * Draw current frame. * * @param x X-coordinate at which to draw * @param y Y-coordinate at which to draw */ void Anim::draw (fixed x, fixed y, int accessories) { Anim* anim; sprites[frame]->draw( FTOI(x) + (xOffsets[frame] << 2), FTOI(y) + yOffsets[frame] - yOffset); if (accessories && accessory) { anim = level->getAnim(accessory); anim->setFrame(frame, true); anim->draw( x + ITOF(accessoryX << 2), y + ITOF(accessoryY - yOffset) - anim->getOffset(), accessories - 1); } return; }
/** * Draw episode B guardian. * * @param ticks Time * @param change Time since last iteration */ void DeckGuardian::draw (unsigned int ticks, int change) { Anim* anim; if (next) next->draw(ticks, change); // If the event has been removed from the grid, do not show it if (!set) return; // Draw the boss if (stage < 3) { // Draw unit anim = level->getAnim(29 + stage); if (stage == 0) { width = F8; drawnX = x - F64; } else if (stage == 1) { width = F8; drawnX = x + F32 - F8; } else if (stage == 2) { width = F64 + F32; drawnX = x - F64; } drawnY = y + F32; height = F32; if (ticks < flashTime) anim->flashPalette(0); if (stage == 0) anim->draw(getDrawX(change) - F64, getDrawY(change) + F32); else if (stage == 1) anim->draw(getDrawX(change) + F32 - F8 - F4, getDrawY(change) + F32); else anim->draw(getDrawX(change) + F8 - F64, getDrawY(change) + F32); if (ticks < flashTime) anim->restorePalette(); } return; }
void InstascopeApp::updateMirrors( vector<TrianglePiece> *vec ) { if( ! mMirrorTexture ) return; vec2 mSamplePt1( -0.5, -(sin(M_PI/3)/3) ); vec2 mSamplePt2( mSamplePt1.x + 1, mSamplePt1.y); vec2 mSamplePt3( mSamplePt1.x + (cos(M_PI/3)), mSamplePt1.y + (sin(M_PI/3))); mat3 mtrx( 1.0f ); mtrx = glm::translate( mtrx, mSamplePt.value() ); mtrx = glm::scale( mtrx, vec2( mSampleSize ) ); mtrx = glm::rotate( mtrx, float((getElapsedFrames()*4)/2*M_PI) ); mSamplePt1 = vec2( mtrx * vec3( mSamplePt1, 1.0 ) ); mSamplePt2 = vec2( mtrx * vec3( mSamplePt2, 1.0 ) ); mSamplePt3 = vec2( mtrx * vec3( mSamplePt3, 1.0 ) ); mSamplePt1 /= mMirrorTexture->getSize(); mSamplePt2 /= mMirrorTexture->getSize(); mSamplePt3 /= mMirrorTexture->getSize(); // loop through all the pieces and pass along the current texture and it's coordinates int outCount = 0; int inCount = 0; for( int i = 0; i < vec->size(); i++ ) { (*vec)[i].update( mMirrorTexture, mSamplePt1, mSamplePt2, mSamplePt3 ); if( (*vec)[i].isOut() ) outCount++; if( (*vec)[i].isIn() ) inCount++; } // if all are out, then make a new mirror grid if( outCount > 0 && outCount == mTriPieces.size() ) { mirrorOut(); } // if all the pieces are in if( inCount > 0 && inCount == mTriPieces.size() && ! mPiecesIn ) { mPiecesIn = true; mirrorIn(); } }
/// @todo Repair major memory leaks when returning FALSE sint32 UnitSpriteGroup::Parse(uint16 id, GROUPTYPE type) { MBCHAR scriptName[k_MAX_NAME_LENGTH]; MBCHAR *facedImageNames[k_NUM_FACINGS][k_MAX_NAMES]; MBCHAR *facedShadowNames[k_NUM_FACINGS][k_MAX_NAMES]; MBCHAR *imageNames[k_MAX_NAMES]; MBCHAR *shadowNames[k_MAX_NAMES]; size_t i; size_t j; char prefixStr[80]; for (j=0; j<k_NUM_FACINGS; j++) { for (i=0; i<k_MAX_NAMES; i++) { facedImageNames[j][i] = new MBCHAR[2 * k_MAX_NAME_LENGTH]; facedShadowNames[j][i] = new MBCHAR[2 * k_MAX_NAME_LENGTH]; } } for (i=0; i<k_MAX_NAMES; i++) { imageNames[i] = new MBCHAR[2 * k_MAX_NAME_LENGTH]; shadowNames[i] = new MBCHAR[2 * k_MAX_NAME_LENGTH]; } sprintf(prefixStr, ".%s%d%s", FILE_SEP, id, FILE_SEP); if (type == GROUPTYPE_UNIT) { sprintf(scriptName, "GU%.3d.txt", id); if (!c3files_PathIsValid(scriptName)) sprintf(scriptName, "GU%.2d.txt", id); } else sprintf(scriptName, "GC%.3d.txt", id); printf("Processing '%s'\n", scriptName); Token * theToken = new Token(scriptName, C3DIR_SPRITES); Assert(theToken); if (!theToken) return FALSE; sint32 tmp; if (!token_ParseKeywordNext(theToken, TOKEN_UNIT_SPRITE)) return FALSE; if (!token_ParseAnOpenBraceNext(theToken)) return FALSE; if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_MOVE, tmp)) return FALSE; if (tmp) { Assert(type == GROUPTYPE_UNIT); if (type != GROUPTYPE_UNIT) { printf("\n Illegal unit action (Move) for a city sprite.\n"); return FALSE; } FacedSprite *moveSprite = new FacedSprite; moveSprite->ParseFromTokens(theToken); printf(" [Move"); for (j=0; j<k_NUM_FACINGS; j++) { for (size_t k = 0; k < moveSprite->GetNumFrames(); ++k) { if (!GetImageFileName(facedShadowNames[j][k],"%sGU%#.3dMS%d.%d", prefixStr, id, j+1, k+moveSprite->GetFirstFrame())) GetImageFileName(facedShadowNames[j][k] ,"%sGU%#.2dMS%d.%d", prefixStr, id, j+1, k+moveSprite->GetFirstFrame()); if (!GetImageFileName(facedImageNames[j][k], "%sGU%#.3dMA%d.%d", prefixStr, id, j+1, k+moveSprite->GetFirstFrame())) GetImageFileName(facedImageNames[j][k] , "%sGU%#.2dMA%d.%d", prefixStr, id, j+1, k+moveSprite->GetFirstFrame()); } } moveSprite->Import(moveSprite->GetNumFrames(), facedImageNames, facedShadowNames); delete m_sprites[UNITACTION_MOVE]; m_sprites[UNITACTION_MOVE] = moveSprite; printf("]\n"); Anim *moveAnim = new Anim; moveAnim->ParseFromTokens(theToken); delete m_anims[UNITACTION_MOVE]; m_anims[UNITACTION_MOVE] = moveAnim; } if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_ATTACK, tmp)) return FALSE; if (tmp) { Assert(type == GROUPTYPE_UNIT); if (type != GROUPTYPE_UNIT) { printf("\n Illegal unit action (Attack) for a city sprite.\n"); return FALSE; } if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_ATTACK_IS_DIRECTIONAL, tmp)) return FALSE; if (tmp) m_hasDirectional = TRUE; else m_hasDirectional = FALSE; FacedSprite *attackSprite = new FacedSprite; attackSprite->ParseFromTokens(theToken); printf(" [Attack"); for (j=0; j<k_NUM_FACINGS; j++) { for(i=0; i<attackSprite->GetNumFrames(); i++) { if (!GetImageFileName(facedShadowNames[j][i],"%sGU%#.3dAS%d.%d", prefixStr, id, j+1, i+attackSprite->GetFirstFrame())) GetImageFileName (facedShadowNames[j][i],"%sGU%#.2dAS%d.%d", prefixStr, id, j+1, i+attackSprite->GetFirstFrame()); if (!GetImageFileName(facedImageNames [j][i],"%sGU%#.3dAA%d.%d", prefixStr, id, j+1, i+attackSprite->GetFirstFrame())) GetImageFileName (facedImageNames [j][i],"%sGU%#.2dAA%d.%d", prefixStr, id, j+1, i+attackSprite->GetFirstFrame()); } } attackSprite->Import(attackSprite->GetNumFrames(), facedImageNames, facedShadowNames); delete m_sprites[UNITACTION_ATTACK]; m_sprites[UNITACTION_ATTACK] = attackSprite; printf("]\n"); Anim *attackAnim = new Anim; attackAnim->ParseFromTokens(theToken); delete m_anims[UNITACTION_ATTACK]; m_anims[UNITACTION_ATTACK] = attackAnim; } if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_IDLE, tmp)) return FALSE; if (tmp) { Sprite *idleSprite = new Sprite; idleSprite->ParseFromTokens(theToken); if (type == GROUPTYPE_UNIT) { printf(" [Idle"); for (size_t n = 0; n < idleSprite->GetNumFrames(); ++n) { if (!GetImageFileName(imageNames[n] ,"%sGU%#.3dIA%d.%d", prefixStr, id, 4, n + idleSprite->GetFirstFrame())) GetImageFileName (imageNames[n] ,"%sGU%#.2dIA%d.%d", prefixStr, id, 4, n + idleSprite->GetFirstFrame()); if (!GetImageFileName(shadowNames[n],"%sGU%#.3dIS%d.%d", prefixStr, id, 4, n + idleSprite->GetFirstFrame())) GetImageFileName (shadowNames[n],"%sGU%#.2dIS%d.%d", prefixStr, id, 4, n + idleSprite->GetFirstFrame()); } } else if (type == GROUPTYPE_CITY) { printf(" [City"); for (size_t n = 0; n < idleSprite->GetNumFrames(); ++n) { GetImageFileName(shadowNames[n], "%sGC%#.3dS.%d", prefixStr, id, n + idleSprite->GetFirstFrame()); GetImageFileName(imageNames[n] , "%sGC%#.3dA.%d", prefixStr, id, n + idleSprite->GetFirstFrame()); } } else { Assert(FALSE); } idleSprite->Import(idleSprite->GetNumFrames(), imageNames, shadowNames); delete m_sprites[UNITACTION_IDLE]; m_sprites[UNITACTION_IDLE] = idleSprite; printf("]\n"); Anim *idleAnim = new Anim; idleAnim->ParseFromTokens(theToken); delete m_anims[UNITACTION_IDLE]; m_anims[UNITACTION_IDLE] = idleAnim; } if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_VICTORY, tmp)) return FALSE; if (tmp) { Assert(type == GROUPTYPE_UNIT); if (type != GROUPTYPE_UNIT) { printf("\n Illegal unit action (Victory) for a city sprite.\n"); return FALSE; } Sprite *victorySprite = new Sprite; if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_IS_DEATH, tmp)) return FALSE; SetHasDeath(0 != tmp); victorySprite->ParseFromTokens(theToken); printf(" [Victory"); for(size_t n = 0; n < victorySprite->GetNumFrames(); ++n) { if (!GetImageFileName(shadowNames[n],"%sGU%#.3dVS%d.%d", prefixStr, id, 4, n + victorySprite->GetFirstFrame())) GetImageFileName (shadowNames[n],"%sGU%#.2dVS%d.%d", prefixStr, id, 4, n + victorySprite->GetFirstFrame()); if (!GetImageFileName(imageNames[n], "%sGU%#.3dVA%d.%d", prefixStr, id, 4, n + victorySprite->GetFirstFrame())) GetImageFileName (imageNames[n], "%sGU%#.2dVA%d.%d", prefixStr, id, 4, n + victorySprite->GetFirstFrame()); } victorySprite->Import(victorySprite->GetNumFrames(), imageNames, shadowNames); delete m_sprites[UNITACTION_VICTORY]; m_sprites[UNITACTION_VICTORY] = victorySprite; printf("]\n"); Anim *victoryAnim = new Anim; victoryAnim->ParseFromTokens(theToken); delete m_anims[UNITACTION_VICTORY]; m_anims[UNITACTION_VICTORY] = victoryAnim; } if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_WORK, tmp)) return FALSE; if (tmp) { Assert(type == GROUPTYPE_UNIT); if (type != GROUPTYPE_UNIT) { printf("\n Illegal unit action (Work) for a city sprite.\n"); return FALSE; } FacedSprite *workSprite = new FacedSprite; workSprite->ParseFromTokens(theToken); printf(" [Work/A2"); for (j=0; j<k_NUM_FACINGS; j++) { for(size_t n = 0; n < workSprite->GetNumFrames(); ++n) { if (!GetImageFileName(facedShadowNames[j][n],"%sGU%#.3dWS%d.%d", prefixStr, id, j+1, n+workSprite->GetFirstFrame())) GetImageFileName (facedShadowNames[j][n],"%sGU%#.2dWS%d.%d", prefixStr, id, j+1, n+workSprite->GetFirstFrame()); if (!GetImageFileName(facedImageNames[j][n] ,"%sGU%#.3dWA%d.%d", prefixStr, id, j+1, n+workSprite->GetFirstFrame())) GetImageFileName (facedImageNames[j][n] ,"%sGU%#.2dWA%d.%d", prefixStr, id, j+1, n+workSprite->GetFirstFrame()); } } workSprite->Import(workSprite->GetNumFrames(), facedImageNames, facedShadowNames); delete m_sprites[UNITACTION_WORK]; m_sprites[UNITACTION_WORK] = workSprite; printf("]\n"); Anim *workAnim = new Anim; workAnim->ParseFromTokens(theToken); delete m_anims[UNITACTION_WORK]; m_anims[UNITACTION_WORK] = workAnim; } if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_FIREPOINTS, tmp)) return FALSE; if (tmp) { for (sint32 j=0; j<tmp; j++) { if (!token_ParseAnOpenBraceNext(theToken)) return FALSE; for (i=0; i<k_NUM_FACINGS; i++) { token_ParsePoint(theToken); } if (!token_ParseAnCloseBraceNext(theToken)) return FALSE; } } if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_FIREPOINTS_WORK, tmp)) return FALSE; if (tmp) { m_numFirePointsWork = (uint16)tmp; for (sint32 j=0; j<tmp; j++) { if (!token_ParseAnOpenBraceNext(theToken)) return FALSE; for (i=0; i<k_NUM_FACINGS; i++) { token_ParsePoint(theToken); } if (!token_ParseAnCloseBraceNext(theToken)) return FALSE; } } if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_MOVEOFFSETS, tmp)) return FALSE; if (tmp) { if (!token_ParseAnOpenBraceNext(theToken)) return FALSE; for (i=0; i<k_NUM_FACINGS; i++) { m_moveOffsets[i] = token_ParsePoint(theToken); } if (!token_ParseAnCloseBraceNext(theToken)) return FALSE; } if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_SHIELDPOINTS, tmp)) return FALSE; if (tmp) { if (!token_ParseAnOpenBraceNext(theToken)) return FALSE; if (!token_ParseKeywordNext(theToken, TOKEN_UNIT_SPRITE_SHIELDPOINTS_MOVE)) return FALSE; if (tmp) { for (i=0; i<k_NUM_FACINGS; i++) { m_shieldPoints[UNITACTION_MOVE][i] = token_ParsePoint(theToken); } } if (!token_ParseKeywordNext(theToken, TOKEN_UNIT_SPRITE_SHIELDPOINTS_ATTACK)) return FALSE; if (tmp) { for (i=0; i<k_NUM_FACINGS; i++) { m_shieldPoints[UNITACTION_ATTACK][i] = token_ParsePoint(theToken); } } if (!token_ParseKeywordNext(theToken, TOKEN_UNIT_SPRITE_SHIELDPOINTS_IDLE)) return FALSE; if (tmp) { for (i=0; i<k_NUM_FACINGS; i++) { m_shieldPoints[UNITACTION_IDLE][i] = token_ParsePoint(theToken); } } if (!token_ParseKeywordNext(theToken, TOKEN_UNIT_SPRITE_SHIELDPOINTS_VICTORY)) return FALSE; if (tmp) { for (i=0; i<k_NUM_FACINGS; i++) { m_shieldPoints[UNITACTION_VICTORY][i] = token_ParsePoint(theToken); } } if (!token_ParseKeywordNext(theToken, TOKEN_UNIT_SPRITE_SHIELDPOINTS_WORK)) return FALSE; if (tmp) { for (i=0; i<k_NUM_FACINGS; i++) { m_shieldPoints[UNITACTION_WORK][i] = token_ParsePoint(theToken); } } if (!token_ParseAnCloseBraceNext(theToken)) return FALSE; } delete theToken; for (j=0; j<k_NUM_FACINGS; j++) { for (i=0; i<k_MAX_NAMES; i++) { delete [] facedImageNames[j][i]; delete [] facedShadowNames[j][i]; } } for (i = 0; i < k_MAX_NAMES; i++) { delete [] imageNames[i]; delete [] shadowNames[i]; } return TRUE; }
void PhotoBoothApp::draw() { gl::enableAlphaBlending(); gl::clear(); gl::color(1, 1, 1, 1); glDepthMask( GL_FALSE ); // Set up the view for landscape mode. gl::setMatricesWindow(width * DISPLAY_SCALE, height * DISPLAY_SCALE); gl::scale(DISPLAY_SCALE, DISPLAY_SCALE); // draw the live camera preview if( mCameraTexture ) { // flip the texture vertically mCameraTexture.setFlipped(false); // draw the texture mirrored. gl::draw( mCameraSurface, Rectf(width, 0, 0, height) ); } // draw "idle" stuff (text and images overlayed on the live camera preview) if(mCurrentState == STATE_PREVIEW){ gl::color(1, 1, 1, 0.75f); gl::draw(mLightBg, Rectf(0, 0, width, height)); gl::color(1, 1, 1, 1); gl::draw(mIntroTexture, Rectf(0,0,width, height)); gl::draw(mCameraButtonTexture, mCameraButtonPos.value() - Vec2f(0, abs( sin(getElapsedSeconds() * 3) * 30))); //gl::draw(mCameraButtonTexture, Rectf(mCameraButtonPos.value().x,mCameraButtonPos.value().y, mCameraButtonTexture.getWidth() * 0.5 + mCameraButtonPos.value().x, mCameraButtonTexture.getHeight() * 0.5 + mCameraButtonPos.value().y) );// mCameraButtonPos.value() ); } // Draw the preview image with dark background. if(mPreviewTexture){ // draw background image and prompt text. if(mDarkBgAlpha > 0){ gl::color(1, 1, 1, mDarkBgAlpha); gl::draw(mDarkBg, Vec2f::zero()); gl::draw(mConfirmMessage, Vec2f(width/2 - mConfirmMessage.getWidth() / 2, 125 - mConfirmMessage.getHeight() / 2)); } float aspect = mPreviewTexture.getAspectRatio(); float imageHeight = height - 500; // margins are keyed off of hard-coded height, this is not very multi-resolution friendly. float imageWidth = imageHeight * aspect; float marginX = (width - imageWidth) / 2; float marginY = (height - imageHeight) / 2; gl::draw(mPreviewTexture, Rectf(marginX, marginY, width - marginX, height - marginY) + mPreviewTexturePos); // Draw semi-transparent pillar boxes to show how the sqare version of the image will look. if(mCurrentState == STATE_ACCEPT) { float pillarWidth = (imageWidth - imageHeight) / 2; gl::color(0, 0, 0, 0.35f); gl::drawSolidRect( Rectf( marginX, height - marginY, pillarWidth + marginX, marginY ) ); gl::drawSolidRect( Rectf( width - marginX - pillarWidth, height - marginY, width - marginX, marginY ) ); } } // draw the "flash" if(mCurrentState == STATE_ACCEPT){ gl::color(1, 1, 1, mCameraFlash); gl::drawSolidRect( Rectf(0, 0, width, height)); } // draw count-down timer if(mCurrentState == STATE_COUNT_DOWN){ // draw dark circle background Vec2f centerPos = Vec2f(width / 2 - mNumberBg.getWidth() / 2, height / 2 - mNumberBg.getHeight() / 2); gl::draw( mNumberBg, centerPos); // background ring that "fills up" for each second. gl::draw(mNumberProgress, Area(0, mNumberProgress.getHeight() * mCountDownFractional, mNumberProgress.getWidth(), mNumberProgress.getHeight()), Rectf(centerPos.x,centerPos.y+mNumberProgress.getHeight() * mCountDownFractional, mNumberBg.getWidth()+centerPos.x, centerPos.y+mNumberBg.getHeight())); // Draw number. gl::enableAdditiveBlending(); gl::draw( mNumberTextures[mCountDownNumber], centerPos); } gl::color(1, 1, 1, 1); gl::draw(mSaveTexture, mSavePos); gl::draw(mDiscardTexture, mDiscardPos); }
void LayerAnim::Render(sf::RenderTarget& Target) const { Anim* th = const_cast<LayerAnim*>(this); th->update(); Target.Draw(*at(currentFrame())); }
void MyAppli::onInit () { Network::startCli(10'000, 10'001,sf::IpAddress::LocalHost); TextureManager<> &tm = cache.resourceManager<Texture, std::string>("TextureManager"); Vec2f pos (getView().getPosition().x - getView().getSize().x * 0.5f, getView().getPosition().y - getView().getSize().y * 0.5f); BoundingBox bx (pos.x, pos.y, 0, getView().getSize().x, getView().getSize().y, 0); theMap = new Map(&getRenderComponentManager(), "Map test", 100, 50); BaseChangementMatrix bcm; bcm.set2DIsoMatrix(); theMap->setBaseChangementMatrix(bcm); World::addEntityManager(theMap); World::setCurrentEntityManager("Map test"); eu = new EntitiesUpdater(false); World::addWorker(eu); au = new AnimUpdater(false); au->setInterval(sf::seconds(0.01f)); World::addTimer(au); tiles.push_back(new Tile(tm.getResourceByAlias("GRASS"), Vec3f(0, 0, 0), Vec3f(120, 60, 0),sf::IntRect(0, 0, 100, 50))); walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 0, 100, 100))); walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 100, 100, 100))); walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 200, 100, 100))); walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 300, 100, 100))); walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 400, 100, 100))); walls.push_back(new Tile(tm.getResourceByAlias("WALLS"), Vec3f(0, 0, 0), Vec3f(100, 100, 0), sf::IntRect(100, 500, 100, 100))); tiles[0]->getFaces()[0]->getMaterial().setTexId("GRASS"); walls[0]->getFaces()[0]->getMaterial().setTexId("WALLS"); walls[1]->getFaces()[0]->getMaterial().setTexId("WALLS"); walls[2]->getFaces()[0]->getMaterial().setTexId("WALLS"); walls[3]->getFaces()[0]->getMaterial().setTexId("WALLS"); walls[4]->getFaces()[0]->getMaterial().setTexId("WALLS"); walls[5]->getFaces()[0]->getMaterial().setTexId("WALLS"); std::ifstream ifs("FichierDeSerialisation"); BoundingBox mapZone(0, 0, 0, 1500, 1000, 0); World::generate_map(tiles, walls, Vec2f(100, 50), mapZone, false); w = new g2d::Wall(3, 80, walls[3],&g2d::AmbientLight::getAmbientLight(), Shadow::SHADOW_TYPE::SHADOW_TILE); w->setPosition(Vec3f(0, 130, 130 + w->getSize().y * 0.5f)); World::addEntity(w); Tile* thouse = new Tile(tm.getResourceByAlias("HOUSE"), Vec3f(0, 0, 0), Vec3f(250, 300, 0), sf::IntRect(0, 0, 250, 300)); thouse->getFaces()[0]->getMaterial().setTexId("HOUSE"); g2d::Decor* decor = new g2d::Decor(thouse, &g2d::AmbientLight::getAmbientLight(), 300, Shadow::SHADOW_TYPE::SHADOW_TILE); decor->setPosition(Vec3f(-100, 250, 400)); BoundingVolume *bb = new BoundingBox(decor->getGlobalBounds().getPosition().x, decor->getGlobalBounds().getPosition().y + decor->getGlobalBounds().getSize().y * 0.4f, 0, decor->getGlobalBounds().getSize().x, decor->getGlobalBounds().getSize().y * 0.25f, 0); decor->setCollisionVolume(bb); decor->setShadowCenter(Vec3f(-10, 500, 0)); World::addEntity(decor); Anim* fire = new Anim(0.1f, Vec3f(0, 100, 150), Vec3f(100, 100, 0), 0); Tile* tf1 = new Tile(tm.getResourceByAlias("FIRE1"), Vec3f(0, 100, 150), Vec3f(100, 100, 0), sf::IntRect(0, 0, 150, 200)); tf1->getFaces()[0]->getMaterial().setTexId("FIRE1"); g2d::Decor *fire1 = new g2d::Decor(tf1, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE); fire1->setShadowCenter(Vec3f(0, 400, 0)); //decor->setShadowCenter(Vec2f(0, 60)); //decor->changeGravityCenter(Vec3f(50, 50, 0)); Tile* tf2 = new Tile(tm.getResourceByAlias("FIRE2"), Vec3f(0, 100, 150), Vec3f(100, 100, 0), sf::IntRect(0, 0, 150, 200)); tf2->getFaces()[0]->getMaterial().setTexId("FIRE2"); g2d::Decor *fire2 = new g2d::Decor(tf2, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE); fire2->setShadowCenter(Vec3f(0, 400, 0)); //decor->setShadowCenter(Vec2f(0, 60)); //decor->changeGravityCenter(Vec3f(50, 50, 0)); Tile* tf3 = new Tile(tm.getResourceByAlias("FIRE3"), Vec3f(0, 100, 150), Vec3f(100, 100, 0), sf::IntRect(0, 0, 150, 200)); tf3->getFaces()[0]->getMaterial().setTexId("FIRE3"); g2d::Decor *fire3 = new g2d::Decor(tf3, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE); fire3->setShadowCenter(Vec3f(0, 400, 0)); //decor->setShadowCenter(Vec2f(0, 60)); //decor->changeGravityCenter(Vec3f(50, 50, 0)); //fire1->setShadowCenter(Vec2f(80, 100)); //fire2->setShadowCenter(Vec2f(80, 100)); //fire3->setShadowCenter(Vec2f(80, 100)); fire->addFrame(fire1); fire->addFrame(fire2); fire->addFrame(fire3); fire->play(true); World::addEntity(fire); au->addAnim(fire); //PonctualLight* light = new PonctualLight(Vec2f(50, 150),100,50,0,200,sf::Color(255,255,0),16,0); //World::addEntity(light); SymEncPacket packet; packet<<"GETCARINFOS"; Network::sendTcpPacket(packet); std::string response = Network::waitForLastResponse("CARINFOS", sf::seconds(10.f)); std::istringstream iss(response); ITextArchive ia(iss); ia(hero); std::string path = "tilesets/vlad_sword.png"; cache.resourceManager<Texture, std::string>("TextureManager").fromFileWithAlias(path, "VLADSWORD"); const Texture *text = cache.resourceManager<Texture, std::string>("TextureManager").getResourceByPath(path); int textRectX = 0, textRectY = 0, textRectWidth = 50, textRectHeight = 100; int textWidth = text->getSize().x; Vec3f tmpCenter = hero->getCenter(); hero->setCenter(Vec3f(0, 0, 0)); for (unsigned int i = 0; i <= 56; i+=8) { Anim* animation = new Anim(0.1f, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), 0); for (unsigned int j = 0; j < 8; j++) { sf::IntRect textRect (textRectX, textRectY, textRectWidth, textRectHeight); Tile *tile = new Tile(text, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), textRect); tile->getFaces()[0]->getMaterial().setTexId("VLADSWORD"); g2d::Decor *frame = new g2d::Decor(tile, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE); frame->setShadowCenter(Vec3f(0, 100, 0)); //decor->setShadowCenter(Vec2f(80, 130)); //decor->changeGravityCenter(Vec3f(50, 50, 0)); textRectX += textRectWidth; if (textRectX + textRectWidth > textWidth) { textRectX = 0; textRectY += textRectHeight; } animation->addFrame(frame); } hero->addAnimation(animation); au->addAnim(animation); } for (unsigned int i = 0; i <= 88; i+= 8) { Anim* animation = new Anim(0.1f, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), 0); for (unsigned int j = 0; j < 11; j++) { sf::IntRect textRect (textRectX, textRectY, textRectWidth, textRectHeight); Tile *tile = new Tile(text, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), textRect); tile->getFaces()[0]->getMaterial().setTexId("VLADSWORD"); g2d::Decor *frame = new g2d::Decor(tile, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE); frame->setShadowCenter(Vec3f(0, 100, 0)); //decor->setShadowCenter(Vec2f(80, 130)); //decor->changeGravityCenter(Vec3f(50, 50, 0)); textRectX += textRectWidth; if (textRectX + textRectWidth > textWidth) { textRectX = 0; textRectY += textRectHeight; } animation->addFrame(frame); } hero->addAnimation(animation); au->addAnim(animation); } hero->setCenter(tmpCenter); getView().move(hero->getCenter().x, hero->getCenter().y, hero->getCenter().z - 300); BoundingVolume* bb2 = new BoundingBox(hero->getGlobalBounds().getPosition().x, hero->getGlobalBounds().getPosition().y + hero->getGlobalBounds().getSize().y * 0.4f, 0, hero->getGlobalBounds().getSize().x, hero->getGlobalBounds().getSize().y * 0.25f, 0); hero->setCollisionVolume(bb2); World::addEntity(hero); Network::sendTcpPacket(packet); response = Network::waitForLastResponse("MONSTERSINFOS", sf::seconds(10.f)); iss.clear(); iss.str(response); ia(monster); path = "tilesets/ogro.png"; //for (unsigned int n = 0; n < monsters.size(); n++) { tmpCenter = monster->getCenter(); monster->setCenter(Vec3f(0, 0, 0)); cache.resourceManager<Texture, std::string>("TextureManager").fromFileWithAlias(path, "OGRO"); text = cache.resourceManager<Texture, std::string>("TextureManager").getResourceByPath(path); textRectX = 0, textRectY = 0, textRectWidth = 50, textRectHeight = 100; textWidth = text->getSize().x; for (unsigned int i = 0; i <= 56; i+=8) { Anim* animation = new Anim(0.1f, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), 0); for (unsigned int j = 0; j < 8; j++) { sf::IntRect textRect (textRectX, textRectY, textRectWidth, textRectHeight); Tile *tile = new Tile(text, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), textRect); tile->getFaces()[0]->getMaterial().setTexId("OGRO"); g2d::Decor *frame = new g2d::Decor(tile, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE); frame->setShadowCenter(Vec3f(0, 100, 0)); //decor->changeGravityCenter(Vec3f(50, 50, 0)); textRectX += textRectWidth; if (textRectX + textRectWidth > textWidth) { textRectX = 0; textRectY += textRectHeight; } animation->addFrame(frame); } monster->addAnimation(animation); au->addAnim(animation); } for (unsigned int i = 0; i <= 80; i++) { Anim* animation = new Anim(0.1f, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), 0); for (unsigned int j = 0; j < 10; j++) { sf::IntRect textRect (textRectX, textRectY, textRectWidth, textRectHeight); Tile *tile = new Tile(text, Vec3f(-25, -50, 0), Vec3f(50, 100, 0), textRect); tile->getFaces()[0]->getMaterial().setTexId("OGRO"); g2d::Decor *frame = new g2d::Decor(tile, &g2d::AmbientLight::getAmbientLight(), 100, Shadow::SHADOW_TYPE::SHADOW_TILE); frame->setShadowCenter(Vec3f(0, 100, 0)); //decor->changeGravityCenter(Vec3f(50, 50, 0)); textRectX += textRectWidth; if (textRectX + textRectWidth > textWidth) { textRectX = 0; textRectY += textRectHeight; } animation->addFrame(frame); } monster->addAnimation(animation); au->addAnim(animation); } monster->setCenter(tmpCenter); World::addEntity(monster); //} //caracter->setCenter(Vec3f(getView().getPosition().x, getView().getPosition().y, 300)); g2d::PonctualLight* light1 = new g2d::PonctualLight(Vec3f(0, 420, 420), 100, 50, 50, 255, sf::Color::Yellow, 16); light2 = new g2d::PonctualLight(Vec3f(50, 160, 160), 100, 50, 50, 255, sf::Color::Yellow, 16); World::addEntity(light1); World::addEntity(light2); OITRenderComponent *frc1 = new OITRenderComponent(getRenderWindow(),0, "E_BIGTILE", false); OITRenderComponent *frc2 = new OITRenderComponent(getRenderWindow(),1, "E_WALL+E_DECOR+E_ANIMATION+E_CARACTER+E_MONSTER", false); getRenderComponentManager().addComponent(frc1); getRenderComponentManager().addComponent(frc2); //getView().move(d.x * 0.5f, d.y * 0.5f, 0); //World::computeIntersectionsWithWalls(); World::update(); //World::computeIntersectionsWithWalls(); Action a1 (Action::EVENT_TYPE::KEY_HELD_DOWN, sf::Keyboard::Key::Z); Action a2 (Action::EVENT_TYPE::KEY_HELD_DOWN, sf::Keyboard::Key::Q); Action a3 (Action::EVENT_TYPE::KEY_HELD_DOWN, sf::Keyboard::Key::S); Action a4 (Action::EVENT_TYPE::KEY_HELD_DOWN, sf::Keyboard::Key::D); Action a5 (Action::EVENT_TYPE::MOUSE_BUTTON_PRESSED_ONCE, sf::Mouse::Left); Action a6 (Action::EVENT_TYPE::MOUSE_BUTTON_PRESSED_ONCE, sf::Mouse::Right); Action combined = a1 || a2 || a3 || a4; Command moveAction(combined, FastDelegate<void>(&MyAppli::keyHeldDown, this, sf::Keyboard::Key::Unknown)); getListener().connect("MoveAction", moveAction); g2d::AmbientLight::getAmbientLight().setColor(sf::Color(0, 0, 255)); Command mouseInsideAction(FastDelegate<bool>(&MyAppli::mouseInside,this, sf::Vector2f(-1, -1)), FastDelegate<void>(&MyAppli::onMouseInside, this, sf::Vector2f(-1,-1))); getListener().connect("MouseInside",mouseInsideAction); Command leftMouseButtonPressedCommand (a5, FastDelegate<void>(&MyAppli::leftMouseButtonPressed, this, sf::Vector2f(-1, -1))); Command rightMouseButtonPressedCommand (a6, FastDelegate<void>(&MyAppli::rightMouseButtonPressed, this, sf::Vector2f(-1, -1))); getListener().connect("LeftMouseButtonPressedAction", leftMouseButtonPressedCommand); getListener().connect("RightMouseButtonPressedAction", rightMouseButtonPressedCommand); packet.clear(); packet<<"GETCARPOS"; hero->getClkTransfertTime().restart(); getClock("RequestTime").restart(); Network::sendTcpPacket(packet); received = false; }
Command *Command::opIsAnimPlaying(const ResourceReference &animRef) { Anim *anim = animRef.resolve<Anim>(); return nextCommandIf(anim->isInUse()); }
/** * Draw coin/gem pickup event. * * @param ticks Time * @param change Time since last iteration */ void CoinGemJJ2Event::draw (unsigned int ticks, int change) { Anim* an; int drawX, drawY; if (prepareDraw(ticks, change)) return; drawX = getDrawX(change); drawY = getDrawY(change); if (endTime) { an = jj2Level->getAnim(animSet, 86, flipped); an->setFrame((int)ticks / 60, true); an->draw(drawX + F16, drawY + F16 + F32); } if (type == 44) an = jj2Level->getAnim(animSet, 84, flipped); // Silver coin else if (type == 45) an = jj2Level->getAnim(animSet, 37, flipped); // Gold coin else an = jj2Level->getAnim(animSet, 35, flipped); // Gem an->setFrame((int)ticks / 60, true); switch (type) { case 63: // Red gem mapPalette(an, 48); break; case 64: // Green gem mapPalette(an, 80); break; case 65: // Blue gem mapPalette(an, 32); break; case 66: // Purple gem mapPalette(an, 88); break; } if (endTime) { drawX += (ticks + 500 - endTime) << 8; drawY += (ticks + 500 - endTime) << 10; } an->draw(drawX + F16, drawY + F16 + F32); return; }