Lightning::Lightning(void) { //Random point between 16, 22, 16 && -16, 22, -16 startingPoint = glm::vec3(util::randF(-26.0f,26.0f),30.0f,util::randF(-26.0f,26.0f)); position = glm::vec3(0.0f,0.0f,0.0f); //is this the first branch of lightning firstBranch = true; //set all default values VAOcore, VAObranch = 0; program = 0; predessingIndex = 0; strikeBranchPercentage = 30; branchedStart = -1; shaderModelMatLocation = shaderViewMatLocation = shaderProjMatLocation = 0; hitGround = false; drawBranch = false; finishedBranches = false; Strike(); coreToDraw = m_vCoreVerts.size(); branchesToDraw = m_vBranchedVerts.size(); // Create the model initaliseVAO(); // Create the shaders initaliseShaders(); }
//----------------------------------------------------------------------------- // Purpose: Think function for striking at intervals. //----------------------------------------------------------------------------- void CEnvBeam::StrikeThink( void ) { if ( m_life != 0 ) { if ( m_spawnflags & SF_BEAM_RANDOM ) SetNextThink( gpGlobals->curtime + m_life + random->RandomFloat( 0, m_restrike ) ); else SetNextThink( gpGlobals->curtime + m_life + m_restrike ); } m_active = 1; if (!m_iszEndEntity) { if (!m_iszStartEntity) { RandomArea( ); } else { CBaseEntity *pStart = RandomTargetname( STRING(m_iszStartEntity) ); if (pStart != NULL) { RandomPoint( pStart->GetAbsOrigin() ); } else { Msg( "env_beam: unknown entity \"%s\"\n", STRING(m_iszStartEntity) ); } } return; } Strike(); }
void Miner::MineCoal(CoalTypeB *_coal) { if (!Strike()) { _coal->Add((1 + experience * 0.03) * 8); if(this->experience<1000) this->experience+=1; } }
void InputBoard::HandleMessage( const SDL_Event& event ) { switch( event.type ) { case SDL_MOUSEMOTION: MoveMouse( event.motion ); break; case SDL_KEYDOWN: Strike( event.key, ZOYAINPUT_STRIKEDOWN ); break; case SDL_KEYUP: Strike( event.key, ZOYAINPUT_STRIKEUP ); break; case SDL_MOUSEBUTTONDOWN: StrikeMouse( event.button, ZOYAINPUT_STRIKEDOWN ); break; case SDL_MOUSEBUTTONUP: StrikeMouse( event.button, ZOYAINPUT_STRIKEUP ); break; case SDL_MOUSEWHEEL: ScrollMouse( event.wheel ); break; } }
void Lightning::Init() { m_vCoreVerts.clear(); m_vBranchedVerts.clear(); lightningStrike.clear(); branchedStart = -1; predessingIndex = 0; //* Random point between 16, 22, 16 && -16, 22, -16 startingPoint = glm::vec3(util::randF(-26.0f,26.0f),30.0f,util::randF(-26.0f,26.0f)); position = glm::vec3(0.0f,0.0f,0.0f); //is this the first branch of lightning firstBranch = true; strikeBranchPercentage = 30; drawBranch = false; hitGround = false; finishedBranches = false; Strike(); coreToDraw = m_vCoreVerts.size(); branchesToDraw = m_vBranchedVerts.size(); //resend the data for positions. //for (int i = m_vCoreVerts.size(); i >= 0; i--){ // for (int x = 0; x < 60; x++){ // if (x != 59){ // continue; // }; glBindBuffer(GL_ARRAY_BUFFER, corePositionBuffer); glBufferData(GL_ARRAY_BUFFER, (m_vCoreVerts.size()) * sizeof(glm::vec3), &m_vCoreVerts[0], GL_DYNAMIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3), 0); glEnableVertexAttribArray(0); glBindVertexArray(0); // } //} glBindBuffer(GL_ARRAY_BUFFER, branchPositionBuffer); glBufferData(GL_ARRAY_BUFFER, m_vBranchedVerts.size() * sizeof(glm::vec3), &m_vBranchedVerts[0] ,GL_DYNAMIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(glm::vec3), 0 ); glEnableVertexAttribArray(0); glBindVertexArray( 0 ); }
//----------------------------------------------------------------------------- // Purpose: Input handler for making the beam strike once. This will not affect // any interval refiring that might be going on. If the lifetime is set // to zero (infinite) it will turn on and stay on. //----------------------------------------------------------------------------- void CEnvBeam::InputStrikeOnce( inputdata_t &inputdata ) { Strike(); }