void NickScene::shootGlobeHit(NickButton *button) { // shoot cannon at the globe m_globeCannon->shootCannon(); //// create a platform Platform *platform = new Platform(this, Vector3(30.0f, 1.0f, 30.0f)); if ( !platform->initialize(new LightShader(0.2f, 1.0f, 4, RAND_COLOR))) { GLOG("ERROR: Could not initialize second to last platform\n"); } platform->setPosition(Vector3(-60.0f, 50.0f, -560.0f)); platform->addToDynamicWorld(m_dynamicsWorld); m_graph->attach(platform); ParticleSystem *system = new RandomParticleSystem(400); system->moveToPoint(0.0f, 50.0f, -600.0f); system->speed = 4.0f; system->speedVar = 3.0f; system->startSystem(); m_graph->attach(system); // create a checkpoint now that user has gotten through trampolines FinishCheckPoint *cp = new FinishCheckPoint(this, "Objects/goal.obj", 0.125f); if ( !cp->initialize(new LightShader(0.1f, 1.0, 8, RAND_COLOR))) { GLOG("ERROR: could not create OBJmodel\n");} cp->setPosition(Vector3(0.0f, 32.0f, -600.0f)); m_allCheckpoints.push_back(cp); cp->addToDynamicWorld(m_dynamicsWorld); m_graph->attach(cp); }
void Pickup::Update(float dt, XNA::AxisAlignedBox *player, World* w) { Platform* p = w->getPlatform(this->getCPID()); if(p != NULL) { XMFLOAT3 pos = p->getPos(); pos.x += this->mPos.x; pos.y += this->mPos.y; pos.z += this->mPos.z; mEntity->SetPosition(pos); this->mSphere.Center = pos; } if(XNA::IntersectSphereAxisAlignedBox(&mSphere, player)) { struct Data { int id; //dummy }; Data* data = new Data; data->id = this->mID; Network::GetInstance()->Push(new Package(Package::Header(9, this->mID, sizeof(Data)), Package::Body((char*)(data)))); } }
QList<Platform*>* MainWindow::loadPlatforms() { QList<Platform*>* platfList = new QList<Platform*>; QString fileName("platforms.bin"); QFile file(fileName); if(file.open(QIODevice::ReadOnly)) { QDataStream stream(&file); stream.setVersion(QDataStream::Qt_5_3); while(!stream.atEnd()) { Platform* platf = new Platform(this); stream >> platf; platfList->append(platf); qDebug() << "Платформа" << platf->getName() << "загружена"; } if (stream.status() != QDataStream::Ok) { qDebug() << "Ошибка чтения файла"; ui->statusBar->showMessage("Ошибка чтения файла"); } else { qDebug() << "Все платформы загружены"; ui->statusBar->showMessage("Все платформы загружены"); } }
void drawScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -50); draw_meta(); glPushMatrix(); // Establish view glRotatef(35, 1,0, 0); glRotatef(-20, 0, 1, 0); // Display some text // Draws the cube and handles movement c.drawCube(); // Update the board and see if cube didn't fall p.update(); // Draw the level p.draw_level(); glPopMatrix(); glutSwapBuffers(); }
msg_t ControlThread::main() { // Build and initialize the system Platform platform; platform.init(); auto& primaryStream = platform.get<USARTPlatform>().getPrimaryStream(); SDCDriver& sdcd = platform.get<SDCPlatform>().getSDCDriver(); // TODO(yoos): make optional ParameterRepository params; GlobalParameters globalParams(params); // Start the background threads static HeartbeatThread heartbeatThread(params); static Communicator communicator(primaryStream); static Logger logger(sdcd, communicator); heartbeatThread.start(LOWPRIO); communicator.start(); logger.start(); // Build the unit Unit unit(platform, params, communicator, logger); // Loop at a fixed rate forever // NOTE: If the deadline is ever missed then the loop will hang indefinitely. systime_t deadline = chibios_rt::System::getTime(); while(true) { deadline += MS2ST(params.get(GlobalParameters::PARAM_DT) * 1000); unit.getSystem().update(); sleepUntil(deadline); } }
bool Bipedal::FollowGround(Object & object, World & world, Sint8 velocity){ if(velocity == 0 || currentplatformid == 0){ return true; } object.x += velocity; Platform * currentplatform = world.map.platformids[currentplatformid]; Platform * oldplatform = currentplatform; object.y = currentplatform->XtoY(object.x); if(object.x > currentplatform->x2){ velocity = object.x - currentplatform->x2; object.x = currentplatform->x2; currentplatform = currentplatform->adjacentr; }else if(object.x < currentplatform->x1){ velocity = -(Sint8)(currentplatform->x1 - object.x); object.x = currentplatform->x1; currentplatform = currentplatform->adjacentl; }else{ return true; } if(currentplatform){ currentplatformid = currentplatform->id; return FollowGround(object, world, velocity); }else{ Platform * collided = world.map.TestAABB(object.x, object.y - height, object.x, object.y, Platform::RECTANGLE | Platform::STAIRSUP | Platform::STAIRSDOWN, oldplatform); if(collided){ return true; } return false; } return true; }
Platform* PlatformFactory::platform(const std::string &description) { int platform_id; bool is_found = false; Platform *result = NULL; platform_id = read_cpuid(); for (auto it = platforms.begin(); it != platforms.end(); ++it) { if ((*it) != NULL && (*it)->model_supported(platform_id, description)) { result = (*it); break; } } for (auto it = platform_imps.begin(); it != platform_imps.end(); ++it) { if ((*it) != NULL && result != NULL && (*it)->model_supported(platform_id)) { result->set_implementation((*it)); is_found = true; break; } } if (!is_found) { result = NULL; } if (!result) { // If we get here, no acceptable platform was found throw Exception("cpuid: " + std::to_string(platform_id), GEOPM_ERROR_PLATFORM_UNSUPPORTED, __FILE__, __LINE__); } return result; }
bool AtlasResourceCompiler::Should_Compile() { Platform* platform = Platform::Get(); // If input dosen't exist, the wtf. if (!platform->Is_File(m_input_path.c_str())) { DBG_ASSERT_STR(false, "Attempt to compile non-existing resource '%s'.", m_input_path.c_str()); return false; } // If input has been modified, compile is definitely required. if (Check_File_Timestamp(m_input_path)) { return true; } // Read in the XML, so we can determine if there are any other dependent files. if (!Load_Config()) { return false; } // Check dependent files. for (std::vector<std::string>::iterator iter = m_dependent_files.begin(); iter != m_dependent_files.end(); iter++) { std::string& path = *iter; if (Check_File_Timestamp(path.c_str())) { return true; } } return false; }
void GameLayer::loadLevel (int level) { clearLayer(); _currentLevel = level; resetLevel(); CCDictionary * levelData = (CCDictionary *) _levels->objectAtIndex(_currentLevel); int count; CCDictionary * data; //create platforms CCArray * platforms = (CCArray *) levelData->objectForKey("platforms"); Platform * platform; count = platforms->count(); for (int i = 0; i < count; i++) { platform = (Platform *) _platformPool->objectAtIndex(_platformPoolIndex); _platformPoolIndex++; if (_platformPoolIndex == _platformPool->count()) _platformPoolIndex = 0; data = (CCDictionary *) platforms->objectAtIndex(i); platform->initPlatform ( data->valueForKey("width")->intValue() * TILE, data->valueForKey("angle")->floatValue(), ccp(data->valueForKey("x")->floatValue() * TILE, data->valueForKey("y")->floatValue() * TILE) ); } }
void PlatformAddCmd::Run() { ToolSystem* tsystem = GetSubsystem<ToolSystem>(); Project* project = tsystem->GetProject(); Platform* platform = tsystem->GetPlatformByName(platformToAdd_); if (!platform) { Error(ToString("Unknown platform: %s", platformToAdd_.CString())); return; } if (project->ContainsPlatform(platform->GetPlatformID())) { Error(ToString("Project already contains platform: %s", platformToAdd_.CString())); return; } LOGINFOF("Adding platform: %s", platformToAdd_.CString()); project->AddPlatform(platform->GetPlatformID()); Finished(); }
int Ball::Update(){ //if object is alive we update it if(isAlive()){ if(stand_on_platform){ x = dynamic_cast<PlayingState*>(g_GamePtr->GetState())->GetPlatform()->GetX(); y = dynamic_cast<PlayingState*>(g_GamePtr->GetState())->GetPlatform()->GetY()-15; } else{ GameObject::Update(); // we do a boundry checking if( x >= g_Game.GetScreen_W() -boundX || x<= boundX) dirX *= -1; else if( y <= boundY) dirY *= -1; else if ( y >= g_Game.GetScreen_H()){ SetAlive(false); LoseEffect(); Platform* platform = dynamic_cast<PlayingState*>(g_GamePtr->GetState())->GetPlatform(); platform->LoseLife(); platform->MorphPlatform(-1); // calling platform to lose it's effect because ball has just died } } // we also update its animation if it exists if(animation) animation->Animate(); } return 0; }
WebFileSystem* DOMFileSystemBase::fileSystem() const { Platform* platform = Platform::current(); if (!platform) return nullptr; return platform->fileSystem(); }
int main (int argc, char* argv[]) { //check parameters google::ParseCommandLineFlags(&argc, &argv, false); if (FLAGS_binaryFile.compare("")==0) { cerr<<"The input/output file parameters are mandatory"<<endl; return 1; } //architecture definition Platform hw; if (add_processors(hw)<1) { cerr<<"Data not valid."<<endl; return -2; } if (add_links(hw)<1) { cerr<<"Data not valid."<<endl; return -2; } //output - serialization fstream output(FLAGS_binaryFile.c_str(), ios::out|ios::trunc|ios::binary); if (!hw.SerializeToOstream(&output)) { cerr << "Failed to serialize." << endl; return -1; } google::protobuf::ShutdownProtobufLibrary(); return 0; }
int lua_Platform_enterMessagePump(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Platform* instance = getInstance(state); int result = instance->enterMessagePump(); // Push the return value onto the stack. lua_pushinteger(state, result); return 1; } lua_pushstring(state, "lua_Platform_enterMessagePump - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; }
PackagePointerList PackageMatcher::matchPackages(const QString &name, const QString &version, const Platform &host, const Platform &target) const { Platform hst = host; if (hst.isEmpty()) { hst = Util::currentPlatform(); } PackagePointerList result; // pending packages are those where we still have to check whether there isn't any higher // version QMap<QString, PackagePointer> pending; const PackagePointerList packages = m_packages->entities(); for (PackagePointer pkg : packages) { if (pkg->id() == name && pkg->host().fuzzyCompare(hst) && pkg->target().fuzzyCompare(target)) { if (version.isEmpty()) { const QString identifier = QString("%1#%2#%3").arg(pkg->id(), pkg->host().toString(), pkg->target().toString()); if (pending.contains(identifier)) { if (Util::isVersionHigherThan(pkg->version(), pending[identifier]->version())) { pending[identifier] = pkg; } } else { pending[identifier] = pkg; } } else if (version == pkg->version()) { result.append(pkg); } } } result.append(pending.values()); return result; }
WebFileSystem* LocalFileSystem::getFileSystem() const { Platform* platform = Platform::current(); if (!platform) return nullptr; return platform->fileSystem(); }
/** * Main entry point. */ int main(int argc, char** argv) { Game* game = Game::getInstance(); Platform* platform = Platform::create(game); GP_ASSERT(platform); int result = platform->enterMessagePump(); delete platform; return result; }
/** * Main entry point. */ extern "C" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int cmdShow) { Game* game = Game::getInstance(); Platform* platform = Platform::create(game); GP_ASSERT(platform); int result = platform->enterMessagePump(); delete platform; return result; }
void WallProjectile::Tick(World & world){ Uint8 life = 20; if(state_i == 1){ EmitSound(world, world.resources.soundbank["!laserel.wav"], 64); } if(state_i < 7){ res_index = state_i; } if(state_i >= 7){ if(state_i > 12 + life){ world.MarkDestroyObject(id); res_index = 12; return; } if(state_i >= 12 + life - 5){ res_index = state_i - life; }else{ res_index = 7; } } if(state_i >= 7){ Object * object = 0; Platform * platform = 0; if(TestCollision(*this, world, &platform, &object)){ Overlay * overlay = (Overlay *)world.CreateObject(ObjectTypes::OVERLAY); if(overlay){ overlay->res_bank = 222; overlay->x = x; overlay->y = y; if(platform){ if(rand() % 2 == 0){ overlay->EmitSound(world, world.resources.soundbank["strike03.wav"], 96); }else{ overlay->EmitSound(world, world.resources.soundbank["strike04.wav"], 96); } } } float xn = 0, yn = 0; if(platform){ platform->GetNormal(x, y, &xn, &yn); } for(int i = 0; i < 8; i++){ Shrapnel * shrapnel = (Shrapnel *)world.CreateObject(ObjectTypes::SHRAPNEL); if(shrapnel){ shrapnel->x = x; shrapnel->y = y; shrapnel->xv = (rand() % 9) - 4; shrapnel->yv = (rand() % 9) - 8; shrapnel->xv = (xn * abs(shrapnel->xv)) + (rand() % 9) - 4; shrapnel->yv = (yn * abs(shrapnel->yv)) + (rand() % 9) - 8; } } world.MarkDestroyObject(id); } } state_i++; }
void FlipLevelTransformer::transform_platform(float height, Platform& platform) { Path& path = platform.get_path(); for (std::vector<Path::Node>::iterator i = path.nodes.begin(); i != path.nodes.end(); i++) { Vector& pos = i->position; pos.y = height - pos.y - platform.get_bbox().get_height(); } }
int main( int argc, char** argv ) { Table config; Platform* platform = Platform::create( config ); platform->run( new BashDogsGame() ); return 0; }
Platform* MapGenerator::generateFlatPlatform(Vector2d* startVector, int length) { Platform* platform = new Platform(); for (int i = 0; i < length; i++) { PlatformBlock* block = new PlatformBlock(HORIZONTAL, startVector); platform->addPlatformBlock(block); startVector = block->getEndVector(); } return platform; }
Platform* Platform::create(GameLayer * game) { Platform * sprite = new Platform(game); if (sprite && sprite->initWithSpriteFrameName("blank.png")) { sprite->autorelease(); sprite->createTiles(); return sprite; } CC_SAFE_DELETE(sprite); return NULL; }
Platform* Platform::create(cocos2d::Node *node) { Platform *pf = new (std::nothrow) Platform; if (pf && pf->init(node)) { pf->autorelease(); return pf; } CC_SAFE_DELETE(pf); return nullptr; }
/** \param platform The platform which all devices in this list should be associated with. \param type The type which all devices in this list should belong to. By default, CL_DEVICE_TYPE_DEFAULT is specified. */ DeviceList(Platform platform, cl_device_type type = CL_DEVICE_TYPE_DEFAULT) { cl_uint num = 0; cl_int err = clGetDeviceIDs(platform.id(), type, 0, NULL, &num); if(num == 0) // check the number before error code return; CLPP_CHECK_ERROR(err); my_list.resize(num); err = clGetDeviceIDs(platform.id(), type, num, &my_list[0], NULL); CLPP_CHECK_ERROR(err); }
AtlasResourceCompiler::AtlasResourceCompiler(const char* url) : m_config_file(NULL) { Platform* platform = Platform::Get(); m_input_path = url; m_input_directory = platform->Extract_Directory(url); m_input_filename = platform->Extract_Filename(url); m_output_directory = Directory_To_Output_Directory(m_input_directory); m_output_path = platform->Join_Path(m_output_directory, m_input_filename); }
void Game::SpawnPlatform(float x, float y) { Platform* plat = new Platform(); Sprite* platSprite = m_pBackBuffer->CreateSprite("assets\\plat.png"); plat->Initialise(platSprite); plat->SetPositionX(x); plat->SetPositionY(y); plat->SetHorizontalVelocity(-0.5f); m_PlatVector.push_back(plat); }
std::string ResourceCompiler::Directory_To_Output_Directory(std::string directory) { Platform* platform = Platform::Get(); std::string path = Platform::Get()->Join_Path(".compiled", directory); if (!platform->Is_Directory(path.c_str())) { platform->Create_Directory(path.c_str(), true); } return path; }
/*! Virtual method indicating the the particle has reached it target. The player score will be updated here. The fadeout animation is started. */ void ExplosionParticle::targetReached() { Platform *platform = static_cast<Platform*>(m_UserData); if (platform) { platform->addScore(1); m_UserData = 0; } if (m_LifeTime > 2.0f) { // Start fadeout animation m_LifeTime = 1.0f; } }
bool Bipedal::FindCurrentPlatform(Object & object, World & world){ if(currentplatformid){ return true; } int xv2 = 0; int yv2 = 1; Platform * platform = world.map.TestIncr(object.x, object.y - height, object.x, object.y, &xv2, &yv2, Platform::RECTANGLE | Platform::STAIRSUP | Platform::STAIRSDOWN); if(platform){ currentplatformid = platform->id; object.y = platform->XtoY(object.x); return true; } return false; }