bool EnvironmentHandler::loadContent( ) { if( !m_bitmap.loadFromFile( "../../Resources/levelOne.png" ) ) { return EXIT_FAILURE; } m_iHorizontalBitmapSize = m_bitmap.getSize().x; m_iVerticalBitmapSize = m_bitmap.getSize().y; if(!m_tiles.loadFromFile( "../../Resources/tiles.png" ) ) { return EXIT_FAILURE; } m_floorArray.reserve( m_iHorizontalBitmapSize * m_iVerticalBitmapSize ); bitmapToArray( ); m_sprites.reserve( m_floorArray.size( ) ); createLevel( ); checkWalls( ); if(!m_objectBitmap.loadFromFile( "../../Resources/levelOneObjects.png" ) ) { return EXIT_FAILURE; } m_objects.reserve( m_floorArray.size( ) ); findObjects(); return EXIT_SUCCESS; }
//-------------------------------------------------------------- void ofApp::draw(){ for(int i=0; i<numBalls; i++){ Ball* ball = balls[i]; ball->x += ball->vx; ball->y += ball->vy; checkWalls(ball); ball->update(); } for(int i=0; i<numBalls - 1; i++){ Ball* ballA = balls[i]; for(int j=i+1; j<numBalls; j++){ Ball* ballB = balls[j]; checkCollision(ballA, ballB); } } }
void Boid::update() { flock(); //attraction(); checkCollisionsAndAttraction(); // checkCollisions(); predatorCharacter(); checkPredator(); checkWalls(); //noWalls(); velocity = velocity.operator+(acceleration); acceleration = ofVec2f(0,0); // velocity.operator*=(damping_); if(velocity.length()>maxSpeed){ velocity = velocity.getNormalized().operator*(maxSpeed); } position.operator+=(velocity); }
bool Mouse::is_mouse_blocked(Direction dir){ SensorReading sr = checkWalls(); return sr.isWall(dir); }