Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function stateToSensorsData(){
- const { bgSpeed } = config.settings
- var obstacles = STATE.cacti.concat(STATE.birds);
- obstacles = obstacles.sort((a, b)=>{
- if (a.x<b.x){
- return -1;
- }
- if (a.x>b.x){
- return 1;
- }
- return 0;
- });
- var sensors = [];
- sensors[0] = obstacles.length>0?obstacles[0].x:Infinity;
- sensors[1] = obstacles.length>0?obstacles[0].width:0;
- sensors[2] = obstacles.length>0?obstacles[0].height:0;
- sensors[3] = obstacles.length>0?obstacles[0].y:0;
- sensors[4] = bgSpeed;
- sensors[5] = obstacles.length>0?obstacles[0].sprite:'';
- return sensors;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement