Last active
          March 26, 2019 16:50 
        
      - 
      
- 
        Save Sunjammer/4fcd93e7b46d59aca6401ca861bfb5f5 to your computer and use it in GitHub Desktop. 
    ECSArticle
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function createParticle(px, py, vx, vy, lifespan) { | |
| return { | |
| type: "Particle", | |
| x: px, | |
| y: py, | |
| vx, | |
| vy, | |
| age: 0, | |
| lifespan, | |
| alive: true | |
| } | |
| } | |
| function updateParticle(particle) { | |
| particle.x += particle.vx | |
| particle.y += particle.vy | |
| particle.alive = particle.age++ < particle.lifespan | |
| return particle | |
| } | |
| ... | |
| particles = particles | |
| .map(updateParticle) | |
| .filter(p => p.alive) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment