void editor::listenToMouse() { if (levelLoaded) { if (pressedL) { int x = floor((xMouseReal-xCorner)/double(tilesize)); int y = level.h - floor((yMouseReal-yCorner)/double(tilesize)) - 1; switch (mode) { case 0: case 1: case 2: try { setTile(x, y, mode, mode?selectedColor:(char *)"#ffffff", selectedDurability); } catch (...) {} updateTile(x, y); break; case 3: if (x>=0 && y>=0 && x<level.w && y<level.h && tileType(x, y)) { int h=0, s=0, v=0; int c = 0; for (int i=-1; i<2; i++) for (int j=-1; j<2; j++, c++) { try { QColor tmp(tileColor(x+i, y+j)); h += tmp.hue(); s += tmp.saturation(); v += tmp.value(); } catch (...) { QColor tmp(tileColor(x+(-1*i), y+(-1*j))); h += tmp.hue(); s += tmp.saturation(); v += tmp.value(); } } h /= c; s /= c; v /= c; QColor q; q.setHsv(h, s, v); char m[8]; for (int i=0; i<8; i++) m[i] = (q.name().constData()+i)->toAscii(); qstrcpy(tileColor(x, y), m); updateTile(x, y); break; } } } } }
void CMapWidget::mouseMoveEvent(QMouseEvent *event) { if (!m_map || !m_patches) return; event->accept(); // Figure out the hovered position const QPoint &rawScreenPos = event->pos(); CMapPoint newHover = calculateClickedPosition(rawScreenPos); // If it hasn't changed, do nothing! if (!(hovered == newHover)) { // Mark the old position as modified, if it was valid if (isHovering) updateTile(hovered, CEditableMap::HighlightUpdate); bool newFlag = m_map->positionValid(newHover); // before we clobber "hovered", call the tool's hoverstatus emit hoverStatusChanged(isHovering, hovered, newFlag, newHover, event); m_currentTool->hoverStatusChanged(isHovering, hovered, newFlag, newHover, event); // now update + write the new position's info isHovering = newFlag; hovered = newHover; if (newFlag) updateTile(newHover, CEditableMap::HighlightUpdate); } // Now, do drag processing! if (m_isDraggingMap && m_scrollArea) { // translate this position to the one clicked on-screen, // not the position in "world space" ... this is a bad explanation // oh well QPoint scrollOffset = QPoint(m_scrollArea->horizontalScrollBar()->value(), m_scrollArea->verticalScrollBar()->value()); QPoint newPos = rawScreenPos - scrollOffset; // now that they're both on the same base, the delta is easy to figure // out QPoint delta = newPos - m_dragStart; delta *= 1.5f; m_roughDragDistance += delta.manhattanLength(); QPoint newOffset = scrollOffset - delta; m_scrollArea->horizontalScrollBar()->setValue(newOffset.x()); m_scrollArea->verticalScrollBar()->setValue(newOffset.y()); m_dragStart = newPos; } }
void writeByte(unsigned short address, unsigned char value) { // Set write breakpoints here //if(address == 0xff00) { // realtimeDebugEnable = 1; //} if(address >= 0xa000 && address <= 0xbfff) sram[address - 0xa000] = value; else if(address >= 0x8000 && address <= 0x9fff) { vram[address - 0x8000] = value; if(address <= 0x97ff) updateTile(address, value); } if(address >= 0xc000 && address <= 0xdfff) wram[address - 0xc000] = value; else if(address >= 0xe000 && address <= 0xfdff) wram[address - 0xe000] = value; else if(address >= 0xfe00 && address <= 0xfeff) oam[address - 0xfe00] = value; else if(address >= 0xff80 && address <= 0xfffe) hram[address - 0xff80] = value; else if(address == 0xff40) gpu.control = value; else if(address == 0xff42) gpu.scrollY = value; else if(address == 0xff43) gpu.scrollX = value; else if(address == 0xff46) copy(0xfe00, value << 8, 160); // OAM DMA else if(address == 0xff47) { // write only int i; for(i = 0; i < 4; i++) backgroundPalette[i] = palette[(value >> (i * 2)) & 3]; }
ZombieHandler::ZombieHandler() { // load the zombies loadZombies(); for(int i = 0; i < MAXZOMBIES; i++){ m_ZombieList[i] = new Zombie; } updateTile(START_TILE); }
void CoordinatedGraphicsLayer::createTile(uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const IntRect& tileRect) { ASSERT(m_coordinator); ASSERT(m_coordinator->isFlushingLayerChanges()); TileCreationInfo creationInfo; creationInfo.tileID = tileID; creationInfo.scale = updateInfo.scaleFactor; m_layerState.tilesToCreate.append(creationInfo); updateTile(tileID, updateInfo, tileRect); }
TilesMap::TilesMap(LatLon center, int zoom, bool online, QWidget *parent) : QWidget(parent), m_center(center), m_zoom(zoom), m_online(online) { m_emptyTile = QPixmap(TILE_SIZE, TILE_SIZE); m_emptyTile.fill(Qt::lightGray); m_sources["osm"] = new OSMTilesSource(); m_source = m_sources["osm"]; connect(&m_loaderThread, SIGNAL(tileLoaded(QPoint)), SLOT(updateTile(QPoint))); connect(&m_loaderThread, SIGNAL(tilesLoading(int)), SIGNAL(tilesLoading(int))); }
void CMapWidget::leaveEvent(QEvent *) { if (!m_map || !m_patches) return; CMapPoint nullp; emit hoverStatusChanged(isHovering, hovered, false, nullp, 0); m_currentTool->hoverStatusChanged(isHovering, hovered, false, nullp, 0); isHovering = false; updateTile(hovered, CEditableMap::HighlightUpdate); hovered = nullp; }
// Constructor RoadTile::RoadTile(TextureManager* textureManager, sf::Vector2i tilePosition): mTextureManager(textureManager) { mTrafficLight = NULL; // Setting position setTilePosition(tilePosition); // Setting rotational/positional origin mSprite.setOrigin(10.0f, 10.0f); // Update tile texture updateTile(); }
void TiledDrawingArea::tileUpdateTimerFired() { ASSERT(!m_pendingUpdates.isEmpty()); UpdateMap::iterator it = m_pendingUpdates.begin(); TileUpdate update = it->second; m_pendingUpdates.remove(it); updateTile(update.tileID, update.dirtyRect, update.scale); if (m_pendingUpdates.isEmpty()) WebProcess::shared().connection()->send(DrawingAreaProxyLegacyMessage::AllTileUpdatesProcessed, m_webPage->pageID(), CoreIPC::In()); else m_tileUpdateTimer.startOneShot(0.001); }
void FoW::set(int x0, int y0, int radius, FogStatus value) { /* FIXME: split this method into two and don't update the neighbours of * internal tiles */ if (radius == 0) { int x = x0, y = y0; if (!contains(x, y) || status[y][x] == value) return; status[y][x] = value; if (value == REVEALED) setTile(x, y, NONE); else updateTile(x, y); updateNeighbours(x, y); } else { int f = 1 - radius; int ddF_x = 1; int ddF_y = -2 * radius; int x = 0; int y = radius; set(x0, y0 - radius, 0, value); set(x0, y0 + radius, 0, value); setRow(x0 - radius, x0 + radius, y0, value); while (x < y) { // ddF_x == 2 * x + 1; // ddF_y == -2 * y; // f == x*x + y*y - radius*radius + 2*x - y + 1; if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x; setRow(x0 - x, x0 + x, y0 + y, value); setRow(x0 - x, x0 + x, y0 - y, value); setRow(x0 - y, x0 + y, y0 + x, value); setRow(x0 - y, x0 + y, y0 - x, value); } } }
void EmptyField::revealField() { if (!discovered && !flagged) { this->discovered = true; emit updateTile(x, y, numOfMinesAround, discovered); emit revealField(x, y); emit addToDiscoveredFields(); if (numOfMinesAround == 0) { for (int i=x-1; i<= x+1; i++) { for (int j = y-1; j<= y+1; j++) { emit revealField(i, j); } } } } }
void Tile::mine(int damage, Player& underlord) { if (isWall_ == false) return; if (isDestructable_ == false) if (damage > 0) return; health.getHealthRef() -= damage; if (health.getHealthRef() <= 0) { isWall_ = false; setGraphic(TG_StoneFloor); setColor(TGC_StoneFloor); setBackground(TGB_StoneFloor); isWalkable_ = true; isDestructable_ = false; isClaimable_ = true;; canFlyOver_ = true; health.getMaxHealthRef() = 100; if (hasGold_) { underlord.addGold(gold_); hasGold_ = false; gold_ = 0; } health.getHealthRef() = health.getMaxHealthRef(); } else if (health.getHealthRef() > health.getMaxHealthRef()) { health.getHealthRef() = health.getMaxHealthRef(); } updateTile(pos_); }
std::vector<TilePosition> TileCachedRecastMeshManager::updateObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform, const AreaType areaType) { const auto object = mObjectsTilesPositions.find(id); if (object == mObjectsTilesPositions.end()) return std::vector<TilePosition>(); auto& currentTiles = object->second; const auto border = getBorderSize(mSettings); std::vector<TilePosition> changedTiles; std::set<TilePosition> newTiles; { auto tiles = mTiles.lock(); const auto onTilePosition = [&] (const TilePosition& tilePosition) { if (currentTiles.count(tilePosition)) { newTiles.insert(tilePosition); if (updateTile(id, transform, areaType, tilePosition, tiles.get())) changedTiles.push_back(tilePosition); } else if (addTile(id, shape, transform, areaType, tilePosition, border, tiles.get())) { newTiles.insert(tilePosition); changedTiles.push_back(tilePosition); } }; getTilesPositions(shape, transform, mSettings, onTilePosition); for (const auto& tile : currentTiles) if (!newTiles.count(tile) && removeTile(id, tile, tiles.get())) changedTiles.push_back(tile); } std::swap(currentTiles, newTiles); if (!changedTiles.empty()) ++mRevision; return changedTiles; }
void LayerTreeHostProxy::syncRemoteContent() { // We enqueue messages and execute them during paint, as they require an active GL context. ensureRootLayer(); while (OwnPtr<LayerTreeMessageToRenderer> nextMessage = m_messagesToRenderer.tryGetMessage()) { switch (nextMessage->type()) { case LayerTreeMessageToRenderer::SetRootLayer: { const SetRootLayerMessageData& data = static_cast<SetRootLayerMessage*>(nextMessage.get())->data(); setRootLayerID(data.layerID); break; } case LayerTreeMessageToRenderer::DeleteLayer: { const DeleteLayerMessageData& data = static_cast<DeleteLayerMessage*>(nextMessage.get())->data(); deleteLayer(data.layerID); break; } case LayerTreeMessageToRenderer::SyncLayerParameters: { const SyncLayerParametersMessageData& data = static_cast<SyncLayerParametersMessage*>(nextMessage.get())->data(); syncLayerParameters(data.layerInfo); break; } case LayerTreeMessageToRenderer::CreateTile: { const CreateTileMessageData& data = static_cast<CreateTileMessage*>(nextMessage.get())->data(); createTile(data.layerID, data.remoteTileID, data.scale); break; } case LayerTreeMessageToRenderer::RemoveTile: { const RemoveTileMessageData& data = static_cast<RemoveTileMessage*>(nextMessage.get())->data(); removeTile(data.layerID, data.remoteTileID); break; } case LayerTreeMessageToRenderer::UpdateTile: { const UpdateTileMessageData& data = static_cast<UpdateTileMessage*>(nextMessage.get())->data(); updateTile(data.layerID, data.remoteTileID, data.sourceRect, data.targetRect, data.image); break; } case LayerTreeMessageToRenderer::CreateImage: { const CreateImageMessageData& data = static_cast<CreateImageMessage*>(nextMessage.get())->data(); createImage(data.imageID, data.image); break; } case LayerTreeMessageToRenderer::DestroyImage: { const CreateImageMessageData& data = static_cast<CreateImageMessage*>(nextMessage.get())->data(); destroyImage(data.imageID); break; } case LayerTreeMessageToRenderer::FlushLayerChanges: flushLayerChanges(); break; } } }
void gamePlay() { // detect the movement of the cursor int initHoriz = analogRead(HORIZ); int initVerti = analogRead(VERT); while(true) { oldCursorX = cursorX; oldCursorY = cursorY; int finalHoriz = analogRead(HORIZ); int finalVerti = analogRead(VERT); int select = digitalRead(SEL); // HIGH(1) if not pressed, LOW(0) if pressed int deltaHoriz = (finalHoriz - initHoriz)/100; int deltaVerti = -(finalVerti - initVerti)/100; cursorX += deltaHoriz; cursorY += deltaVerti; int whetherFull = full(); //int whetherMove = blockMoved(); // cursur has moved if (oldCursorX!=cursorX || oldCursorY!=cursorY) { // backup the current grid before updating the tiles, for undo() function gridBackup(); updateTile(deltaVerti, deltaHoriz); // check if any further movements can be made if(whetherFull && noMoreAdd) {continueGame = 0;} else { continueGame = 1; createNew(); } displayGrid(); delay(50); } // Undo: button of joystick has been pressed if (select == 0) { score-=plus; undo(); displayGrid(); } // if the game is over, display game over screen and break the while loop int gameEnd = gameOverCheck(); if (gameEnd) {break;} // test: print out the values of coordinates to serial-mon //Serial.print(" whetherMove: "); //Serial.print(whetherMove); Serial.print(" continueGame: "); Serial.print(continueGame); Serial.print(" cursorX: "); Serial.print(cursorX); Serial.print(" cursorY: "); Serial.print(cursorY); Serial.print(" SEL= "); Serial.print(select,DEC); Serial.println(); delay(10); } }
void EmptyField::showField() { emit updateTile(x, y, numOfMinesAround, true); }
// Add a neighbouring tile void RoadTile::addNeighbour(Tile *neighbour) { Tile::addNeighbour(neighbour); // Updating tile texture/direction updateTile(); }
void FoW::updateNeighbours(int x, int y) { for (size_t i = 0; i < neighbours_len; i++) updateTile(x + neighbours[i].j, y + neighbours[i].i); }
void TiledDrawingAreaProxy::createTile(int tileID, const UpdateInfo& updateInfo) { int nodeID = m_webView->sceneGraphUpdateQueue()->createTileNode(updateInfo.updateScaleFactor); m_tileNodeMap.set(tileID, nodeID); updateTile(tileID, updateInfo); }