void Car::setup(){
xPos = ofGetWindowWidth()/2;
yPos = ofGetWindowHeight()/2;
r1=320;
r2=400;
x=100;
thisRadius = ofRandom(r1,r2);
fadeSpeed = ofRandom(0.00001, 0.00045);
addSpeed = ofRandom(0.1, 0.9);
x=ofRandom(-20,20);
}
`void Car::update(){
z=pSensor.BPM;
if(pSensor.BPM>0){
width=ofMap(pSensor.BPM,60,180,100,10);}
if(pSensor.BPM=0){
width=0;}
float timeY = ofGetElapsedTimef() *0.05;
amplitude = thisRadius + ofRandom(-0.5, 0.5);
yPos = ofGetWindowHeight()/2 + amplitude * sin(timeY)+x;
float timeX = ofGetElapsedTimef() * 0.05;
float homeX = ofGetWindowWidth()/2;
xPos = ofGetWindowWidth()/2 + amplitude* cos(timeX);
}
void Car::draw(){
ofSetColor(y,y,y);
ofCircle(xPos, yPos, width);}
}
I wan to use a BPM sent by pulse sensor to control the width , but it doesn’t work ? why ?
I also use the vector of pointers , is it related to this problem ?
void ofApp::update(){
pSensor.update();
thisCar.update();
pSensor.update();
//y=ofMap(pSensor.BPM,70,120,200,40);// it works , BPM can change the y
numCars =2;
//update the list of cars
for (int i =0;i<numCars;i++){
carList[i]->update();
}
}
I can use the BPM change the numCars , but can’t interact with the car class (like width , )