improve spawning rate and separate behaviour for start and end wall
This commit is contained in:
parent
7e437daf75
commit
e74b258795
2 changed files with 23 additions and 13 deletions
|
|
@ -683,7 +683,11 @@ void loop_achterbahn(){
|
||||||
lastCheckspawn=loopmillis;
|
lastCheckspawn=loopmillis;
|
||||||
Serial.print("Checking Spawning, wagons ");
|
Serial.print("Checking Spawning, wagons ");
|
||||||
Serial.println(wagoncount);
|
Serial.println(wagoncount);
|
||||||
if (random(0,SPAWNCHANCE)==0 && wagoncount<MAXWAGONS) { //by chance, exclusive SPAWNCHANCE
|
uint8_t spawnchance=SPAWNCHANCE;
|
||||||
|
if (wagoncount<=0) { //no wagons present
|
||||||
|
spawnchance/=2; //double spawnchance
|
||||||
|
}
|
||||||
|
if (random(0,spawnchance)==0 && wagoncount<MAXWAGONS) { //by chance, exclusive SPAWNCHANCE
|
||||||
spawnWagon();
|
spawnWagon();
|
||||||
if (random(0,SPAWNCHANCEDOUBLE)==0){
|
if (random(0,SPAWNCHANCEDOUBLE)==0){
|
||||||
spawnWagon();
|
spawnWagon();
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,16 @@
|
||||||
|
|
||||||
#define WAGONLENGTH 3
|
#define WAGONLENGTH 3
|
||||||
|
|
||||||
//#define EDGE_KILL
|
//#define EDGE_KILL_END
|
||||||
#define EDGE_WALL
|
#define EDGE_WALL_END
|
||||||
//#define EDGE_BOUNCE
|
//#define EDGE_BOUNCE_END
|
||||||
//#define EDGE_WRAP
|
//#define EDGE_WRAP_END
|
||||||
|
|
||||||
|
#define EDGE_KILL_START
|
||||||
|
//#define EDGE_WALL_START
|
||||||
|
//#define EDGE_BOUNCE_START
|
||||||
|
//#define EDGE_WRAP_START
|
||||||
|
|
||||||
#define WRAPLEDENDPOS _numpixels //default
|
#define WRAPLEDENDPOS _numpixels //default
|
||||||
//#define WRAPLEDENDPOS (_numpixels-5) //led index which is last led
|
//#define WRAPLEDENDPOS (_numpixels-5) //led index which is last led
|
||||||
#define WRAPLEDSTARTPOS 0 //default
|
#define WRAPLEDSTARTPOS 0 //default
|
||||||
|
|
@ -171,32 +177,32 @@ void Wagon::updatePhysics(float updatedelayms)
|
||||||
|
|
||||||
|
|
||||||
if (_pos>=WRAPLEDENDPOS){
|
if (_pos>=WRAPLEDENDPOS){
|
||||||
#ifdef EDGE_WRAP
|
#ifdef EDGE_WRAP_END
|
||||||
_pos-=WRAPLEDENDPOS; //Wrap around edges
|
_pos-=WRAPLEDENDPOS; //Wrap around edges
|
||||||
#endif
|
#endif
|
||||||
#ifdef EDGE_BOUNCE
|
#ifdef EDGE_BOUNCE_END
|
||||||
_vel*=-1; //bounce at edges
|
_vel*=-1; //bounce at edges
|
||||||
#endif
|
#endif
|
||||||
#ifdef EDGE_WALL
|
#ifdef EDGE_WALL_END
|
||||||
//nothing
|
//nothing
|
||||||
#endif
|
#endif
|
||||||
#ifdef EDGE_KILL
|
#ifdef EDGE_KILL_END
|
||||||
if (_pos>=WRAPLEDENDPOS+(_trainlength*WAGONLENGTH)){
|
if (_pos>=WRAPLEDENDPOS+(_trainlength*WAGONLENGTH)){
|
||||||
_health=0;
|
_health=0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (_pos<WRAPLEDSTARTPOS){
|
if (_pos<WRAPLEDSTARTPOS){
|
||||||
#ifdef EDGE_WRAP
|
#ifdef EDGE_WRAP_START
|
||||||
_pos=WRAPLEDENDPOS+_pos; //warp around edges
|
_pos=WRAPLEDENDPOS+_pos; //warp around edges
|
||||||
#endif
|
#endif
|
||||||
#ifdef EDGE_BOUNCE
|
#ifdef EDGE_BOUNCE_START
|
||||||
_vel*=-1;; //bounce at edges
|
_vel*=-1;; //bounce at edges
|
||||||
#endif
|
#endif
|
||||||
#ifdef EDGE_WALL
|
#ifdef EDGE_WALL_START
|
||||||
//nothing
|
//nothing
|
||||||
#endif
|
#endif
|
||||||
#ifdef EDGE_KILL
|
#ifdef EDGE_KILL_START
|
||||||
_health=0;
|
_health=0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue