void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) { (void)ev; en.each<Position, Direction>([dt](entityx::Entity entity, Position &position, Direction &direction) { position.x += direction.x * dt; position.y += direction.y * dt; if (entity.has_component<Animate>() && entity.has_component<Sprite>()) { auto animate = entity.component<Animate>(); entity.component<Sprite>()->sprite = (direction.x != 0) ? animate->nextFrame() : animate->firstFrame(); } if (entity.has_component<Dialog>() && entity.component<Dialog>()->talking) { direction.x = 0; } else { if (entity.has_component<Sprite>()) { auto& fl = entity.component<Sprite>()->faceLeft; if (direction.x != 0) fl = (direction.x < 0); } if (entity.has_component<Wander>()) { auto& countdown = entity.component<Wander>()->countdown; if (countdown > 0) { countdown--; } else { countdown = 5000 + randGet() % 10 * 100; direction.x = (randGet() % 3 - 1) * 0.02f; } } } }); }
void V8Proxy::reportUnsafeAccessTo(Document* targetDocument) { if (!targetDocument) return; // FIXME: We should pass both the active and target documents in as arguments. Frame* source = firstFrame(BindingState::instance()); if (!source) return; Document* sourceDocument = source->document(); if (!sourceDocument) return; // Ignore error if the source document is gone. // FIXME: This error message should contain more specifics of why the same // origin check has failed. String str = "Unsafe JavaScript attempt to access frame with URL " + targetDocument->url().string() + " from frame with URL " + sourceDocument->url().string() + ". Domains, protocols and ports must match.\n"; RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true); // NOTE: Safari prints the message in the target page, but it seems like // it should be in the source page. Even for delayed messages, we put it in // the source page. sourceDocument->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, str, stackTrace.release()); }
void ArchiveClip::loadFromPath( ) { loadMovie( path , OF_QTKIT_DECODE_TEXTURE_ONLY ) ; w = getWidth() ; h = getHeight() ; firstFrame() ; }
bool ParallelTransportFrames::addPoint(const ofVec3f& point) { points.push_back(point); while (points.size() > maxPoints) points.pop_front(); if (points.size() == 3) firstFrame(); else if (points.size() > 3) { nextFrame(); return true; } return false; }
BRect TElementsSorter::GetScrollArea() { BRect firstFrame(0,0,0,0); BRect lastFrame(0,0,0,0); BRect bounds = Bounds(); // Get first sorter in list TSorterContainer* firstSorter = static_cast<TSorterContainer*>(fSorterList->FirstItem() ); firstFrame = firstSorter->Frame(); // Get last sorter in list TSorterContainer* lastSorter = static_cast<TSorterContainer*>(fSorterList->ItemAt( fSorterList->CountItems() - 1) ); if (lastSorter) lastFrame = lastSorter->Frame(); bounds.left = firstFrame.left; bounds.right = lastFrame.right; return bounds; }
void Tube::buildPTF() { mFrames.clear(); int n = mPs.size(); // Make sure we have at least 3 points because the first frame requires it if( n >= 3 ) { mFrames.resize( n ); // Make the parallel transport frame mFrames[0] = firstFrame( mPs[0], mPs[1], mPs[2] ); // Make the remaining frames - saving the last for( int i = 1; i < n - 1; ++i ) { Vec3f prevT = mTs[i - 1]; Vec3f curT = mTs[i]; mFrames[i] = nextFrame( mFrames[i - 1], mPs[i - 1], mPs[i], prevT, curT ); } // Make the last frame mFrames[n - 1] = lastFrame( mFrames[n - 2], mPs[n - 2], mPs[n - 1] ); } }
Surface *Animation::currentFrame(int dt) { if (paused) return firstFrame(); if (frames == NULL || frames_count == 0) return NULL; Surface *r; if (data != NULL) { uint32 frame = 3 * index; //debug(0, "%u/%u", index, data_size / 3); index += dt; if (!loop && index >= data_size / 3) { return NULL; } if (data[frame] - 1 >= frames_count) { warning("invalid frame %u(0x%x) (max %u) index %u, mod %u", frame, frame, frames_count, index - 1, data_size / 3); return NULL; } r = frames + data[frame] - 1; uint16 pos = READ_LE_UINT16(data + frame + 1); index %= (data_size / 3); if (pos != 0) { x = r->x = pos % 320; y = r->y = pos / 320; } } else { //debug(0, "index %u", index); r = frames + index; index += dt; index %= frames_count; } return r; }
QPixmap Game::image() { if(!m_currentLevelImageReady) m_image = *firstFrame(); return m_image; }