void Game::areDelayHandleEvent(const SDL_Event &event) { if (event.type == SDL_KEYUP){ SDLKey sym = event.key.keysym.sym; if (sym == playerData->moveLeft){ dropStatus = NORMAL; } else if (sym == playerData->moveRight){ dropStatus = NORMAL; } } if (event.type == SDL_KEYDOWN){ SDLKey sym = event.key.keysym.sym; if (sym == playerData->moveLeft){ dropStatus = ARRLEFT; } else if (sym == playerData->moveRight){ dropStatus = ARRRIGHT; } else if (sym == playerData->rotateLeft){ direction = Direction( direction == 3? 0: direction + 1); } else if (sym == playerData->rotateRight){ direction = Direction( direction == 0? 3: direction - 1); } else if (sym == playerData->hardDrop){ pos = getLockPos(); ResourceData::sound->playChunk(Sound::HARDDROP); if (!checkBlock(pos, direction)){ gameOver(); } else{ fillMap(); gameStatus = START; } } else if (sym == playerData->hold){ if (holdStatus == PREPAREHOLD){ ResourceData::sound->playChunk(Sound::HOLD); holdStatus = HOLD; gameStatus = START; } else{ ResourceData::sound->playChunk(Sound::HOLDFAIL); } } } }
void MapSerializer_serialize(void) { gameEngine->_map._map = malloc((4 * 3) * sizeof(char*)); gameEngine->_map.xSize = 4 * 3; gameEngine->_map.ySize = 6 * 3; for (int i = 0; i != 4 * 3; ++i) { gameEngine->_map._map[i] = malloc(6 * 3); gameEngine->_map._map[i] = memset(gameEngine->_map._map[i], -1, 6 * 3); } for (int i = 0, map_i = 0; i != 4; ++i, map_i += 3) { for (int j = 0, map_j = 0; j != sizeof(__map[i]); ++j, map_j += 3) { fillMap(map_i, map_j, __map[i][j]); } } }
int findAndFill(int rowNum) { int path[MAX_C]; for (int i = 0; i < C; i++) path[i] = -1; int result = 0; if (findPath(rowNum, 0, path)) { result = 1; fillMap(path, C); for (int i = 0; i < C; i++) path[i] = -1; } return result; }
void modePract(int practice_mode) { switch(practice_mode) { case 0: { initMap(); break; } case 1: { fillMap(); break; } } }
int main() { fillMap(); while(1) { car(); turndecide(); scrollRoad(); draw(); score(); Sleep(0); gotoxy(0, 0); roadControl(); if (crash()) return 0; } return 0; }
LoginWidget::LoginWidget(WContainerWidget *parent) : WContainerWidget(parent) { this->setId("login_widget"); this->setStyleClass("login_widget_style"); WText *intro = new WText("Hello! Please, login into Geo2tag " "or view marks from public channels", this); intro->setId("intro"); // WBreak *break1 = new WBreak(this); WLabel *usernameLabel = new WLabel("Username:"******"Password:"******"Login", this); // WBreak *break2 = new WBreak(this); map = new WGoogleMap(this); map->setMinimumSize(WLength(300), WLength(400)); map->setMaximumSize(WLength(500), WLength(400)); map->setCenter(Wt::WGoogleMap::Coordinate(60, 30)); map->enableScrollWheelZoom(); // WBreak *break3 = new WBreak(this); // WOpenStreetMap *map2 = new WOpenStreetMap(this); // map2->setMinimumSize(WLength(300), WLength(400)); // //map2->setMaximumSize(WLength(500), WLength(400)); // // WBreak *break4 = new WBreak(this); // WYandexMap *map3 = new WYandexMap(this); // map3->setMinimumSize(WLength(300), WLength(400)); // loginButton->clicked().connect(this, &LoginWidget::loginClicked); fillMap(); initCons(); // m_con=new Connector<LoginWidget>(&m_loginQuery,LoginQueryConnected,&LoginWidget::userRecieved,this); this->setStyleClass("login_wigdet"); }
Object APCCollection::createObject() const { if (m_arrayHandle->isUncounted()) { Variant local(m_arrayHandle->toLocal()); assert(local.isArray()); return Object::attach( collections::alloc(m_colType, local.getArrayData()) ); } if (UNLIKELY(m_arrayHandle->kind() == APCKind::SerializedArray)) { return createFromSerialized(m_colType, m_arrayHandle); } // We had a counted inner array---we need to do an O(N) copy to get the // collection into the request local heap. auto const apcArr = APCArray::fromHandle(m_arrayHandle); auto const col = Object::attach(collections::alloc(m_colType)); switch (m_colType) { case CollectionType::ImmVector: case CollectionType::Vector: fillCollection(static_cast<BaseVector*>(col.get()), apcArr); break; case CollectionType::ImmSet: case CollectionType::Set: fillCollection(static_cast<BaseSet*>(col.get()), apcArr); break; case CollectionType::ImmMap: case CollectionType::Map: fillMap(static_cast<BaseMap*>(col.get()), apcArr); break; case CollectionType::Pair: always_assert(0); break; } return col; }
int initMap(int sy, int sx, int nr, int ft, int wt){ // logEntry("Begin initMap()"); if(MAP != NULL){ // logEntry("[WARNING] MAP not NULL."); MAP = mapFree(MAP); } // logEntry("Begin mapAllocate()"); MAP = mapAllocate(MAP, sy, sx); if(MAP == NULL) return ERR_MALLOC; // logEntry("mapAllocate() OK!"); int y, x; // logEntry("Begin bspNew()"); BSPROOT = bspNew(BSPROOT, sy, sx, 4); if(BSPROOT == NULL) return ERR_MALLOC; // logEntry("bspNew() OK!"); // logEntry("Begin bspRecursive()"); bspRecursive(BSPROOT, nr); // logEntry("bspRecursive() OK!"); // logEntry("Begin bspResize()"); bspDoResize(BSPROOT, nr); // logEntry("bspResize() OK!"); // logEntry("Begin fillMap()"); fillMap(MAP, sy, sx, TILE_BLANK); // logEntry("fillMap() OK!"); MAPTAIL = &MAP[(sy * sx) - 1]; // logEntry("Begin bspDrawRooms()"); bspDrawRooms(BSPROOT, MAP, nr, sy, sx, ft, wt); // logEntry("bspDrawRooms() OK!"); int r = nr - 1; // logEntry("Begin bspLinkRooms()"); for(r; r >= 0; r--){ bspLinkRooms(BSPROOT, MAP, r, sy, sx, ft); } // logEntry("bspLinkRooms() OK!"); int d; // logEntry("Begin bspAddDoors(()"); bspAddDoors(BSPROOT, MAP, nr, sx, ft, wt); // logEntry("bspAddDoors() OK!"); // logEntry("Begin fillWall()"); fillWall(MAP, sy, sx, ft, wt); // logEntry("fillWall() OK!"); // logEntry("Begin fillStairs()"); fillStairs(MAP, sy, sx, ft); // logEntry("fillStairs() OK!"); // logEntry("Seeking suitable position to start player."); do{ y = getRand_i(0, sy); x = getRand_i(0, sx); }while(MAP[CM(y,sx,x)].tT != ft); // logEntry("Suitable position found."); player->locY = y; player->locX = x; // logEntry("Recording map maximum values to ENGINE."); genesis->maxY = sy; genesis->maxX = sx; // logEntry("Begin bspDel()"); bspDel(BSPROOT); // logEntry("bspDel() OK!"); int i; // logEntry("begin seedCreature()"); for(i = 0; i < 25; i++){ seedCreature(genesis->floor, ft); // Keep this out until seedCreature is revised to use spawnCreatur() } // logEntry("seedCreature() OK!"); TEST_seedItem(); // logEntry("initMap() OK!"); return ERR_NONE; }
void Game::dropUpdate() { show->mapShow(mapData); show->ghostShow(getLockPos(), shape, direction); show->dropBlockShow(pos, shape, direction); switch (dropStatus){ case NORMAL: break; case DASLEFT: if (dasDelayTimer->checkTimeOut()){ dropStatus = ARRLEFT; } break; case ARRLEFT: if (horizontalLeftCounter == NULL){ dropDistancePerFrame += Vector2<int>(-playerData->horizontalSpeed, 0); } else if (!horizontalLeftCounter->getRemain()){ dropDistancePerFrame += Vector2<int>(-1, 0); horizontalLeftCounter->reset(); } break; case DASRIGHT: if (dasDelayTimer->checkTimeOut()){ dropStatus = ARRRIGHT; } break; case ARRRIGHT: if (horizontalRightCounter == NULL) dropDistancePerFrame += Vector2<int>(playerData->horizontalSpeed, 0); else if (!horizontalRightCounter->getRemain()){ dropDistancePerFrame += Vector2<int>(1, 0); horizontalRightCounter->reset(); } break; } if (!lockStatus){ Uint8 *keyState = SDL_GetKeyState(NULL); if (keyState[playerData->softDrop]){ if (softDropCounter == NULL) dropDistancePerFrame += Vector2<int>( 0, (int)playerData->softDropSpeed); else { if (!softDropCounter->getRemain()){ dropDistancePerFrame += Vector2<int>(0, 1); softDropCounter->reset(); } } } if (normalDropCounter == NULL) dropDistancePerFrame += Vector2<int>( 0, (int)playerData->normalDropSpeed); else { if (!normalDropCounter->getRemain()){ dropDistancePerFrame += Vector2<int>(0, 1); normalDropCounter->reset(); } } } Vector2<int> newPos = findPos(pos, pos + dropDistancePerFrame, direction); if (pos != newPos && lockStatus){ lockDelayTimer->reset(); } pos = newPos; dropDistancePerFrame = Vector2<int>(0, 0); if (pos == getLockPos()){ if (!lockStatus){ lockStatus = true; lockDelayTimer->reset(); } }else { lockStatus = false; } if (lockStatus && lockDelayTimer->checkTimeOut()){ lockStatus = false; fillMap(); gameStatus = START; } }
void Game::dropHandleEvent(const SDL_Event &event) { Uint8 *keyState = SDL_GetKeyState(NULL); if (event.type == SDL_KEYUP){ SDLKey sym = event.key.keysym.sym; if (sym == playerData->moveLeft){ if (keyState[playerData->moveRight]) dropStatus = ARRRIGHT; else dropStatus = NORMAL; } else if (sym == playerData->moveRight){ if (keyState[playerData->moveLeft]) dropStatus = ARRLEFT; else dropStatus = NORMAL; } } if (event.type == SDL_KEYDOWN){ SDLKey sym = event.key.keysym.sym; if (sym == playerData->moveLeft){ dropDistancePerFrame += Vector2<int>(-1, 0); if (keyState[playerData->moveRight]) dropStatus = ARRLEFT; else{ dropStatus = DASLEFT; dasDelayTimer->reset(); } } else if (sym == playerData->moveRight){ dropDistancePerFrame += Vector2<int>(1, 0); if (keyState[playerData->moveLeft]) dropStatus = ARRRIGHT; else { dropStatus = DASRIGHT; dasDelayTimer->reset(); } } else if (sym == playerData->rotateLeft){ int newDirection = (direction == 3? 0: direction + 1); if (SRSRotate(direction, (Direction)newDirection)){ ResourceData::sound->playChunk(Sound::TURN); if (lockStatus) lockDelayTimer->reset(); } } else if (sym == playerData->rotateRight){ int newDirection = (direction == 0? 3: direction - 1); if (SRSRotate(direction, (Direction)newDirection)){ ResourceData::sound->playChunk(Sound::TURN); if (lockStatus) lockDelayTimer->reset(); } } else if (sym == playerData->hardDrop){ lockStatus = false; pos = getLockPos(); ResourceData::sound->playChunk(Sound::HARDDROP); fillMap(); gameStatus = START; } else if (sym == playerData->hold){ if (holdStatus == PREPAREHOLD){ ResourceData::sound->playChunk(Sound::HOLD); holdStatus = HOLD; gameStatus = START; } else{ ResourceData::sound->playChunk(Sound::HOLDFAIL); } } } }
int main(int argc, char **argv) { char* attributeFile = 0; bool verbose = false; int seqGroup = 0; int seqElement = 0; int group = 0; int element = 0; char* language = ""; // Language of messages for evaluation int level = 1; // Level 1 is errors only while (--argc > 0 && (*++argv)[0] == '-') { switch (*(argv[0] + 1)) { case 'l': argc--; argv++; if (argc < 1) usage(); level = atoi(*argv); if (level > 2) verbose = true; break; case 'L': argc--; argv++; if (argc < 1) usage(); language = *argv; break; case 's': argc--; argv++; if (argc < 2) usage(); if (::sscanf(*argv, "%x", &seqGroup) != 1) { cerr << "Unable to scan group: " << *argv << endl; usage(); } argc--; argv++; if (::sscanf(*argv, "%x", &seqElement) != 1) { cerr << "Unable to scan element: " << *argv << endl; usage(); } break; case 'v': verbose = true; level = 3; break; default: break; } } if (argc < 5) usage(); if (::sscanf(argv[0], "%x", &group) != 1) { cerr << "Unable to scan group: " << argv[0] << endl; usage(); } if (::sscanf(argv[1], "%x", &element) != 1) { cerr << "Unable to scan group: " << argv[1] << endl; usage(); } DCM_TAG tag = DCM_MAKETAG(group, element); DCM_TAG seqTag = DCM_MAKETAG(seqGroup, seqElement); MString maskName(argv[2]); MStringVector testFiles; fillFileVector(testFiles, argv[3]); MStringVector stdFiles; fillFileVector(stdFiles, argv[4]); if (stdFiles.size() != testFiles.size()) { cout << "ERR: The number of responses in the test directory (" << argv[3] << ")" << endl << "ERR: does not match responses in the std directory (" << argv[4] << ")" << endl; cout << "ERR: The counts are: " << testFiles.size() << " and " << stdFiles.size() << endl; return 1; } int rtnStatus = 0; int evaluationCount = stdFiles.size(); int failureCount = 0; MStringMap testMap; MStringMap stdMap; fillMap(testMap, testFiles, seqTag, tag); fillMap(stdMap, stdFiles, seqTag, tag); MStringMap::iterator it = stdMap.begin(); for (it; it != stdMap.end(); it++) { MString key = (*it).first; MString stdFile = (*it).second; MString tstFile = testMap[key]; if (verbose) cout << key << " " << tstFile << " " << stdFile << endl; int testStatus = evaluate(tstFile, stdFile, maskName, verbose, level, language); if (testStatus != 0) { cout << "ERR: C-Find resp evaluate failed for: " << tstFile << endl; rtnStatus = 1; failureCount++; } } return rtnStatus; }
void EmissionMap::fillMap(const ParticleState& state, double weight) { fillMap(state.getId(), state.getEnergy(), state.getDirection(), weight); }