void pickLocation()
    {
        int cols = P5JSExtension.floor(P5JSExtension.width / scl);
        int rows = P5JSExtension.floor(P5JSExtension.height / scl);

        food = new Vector2(P5JSExtension.random(0, cols), P5JSExtension.random(0, rows));
        food.Scale(new Vector2(scl, scl));
    }
    public Star()
    {
        P5JSExtension.background(0);

        x  = P5JSExtension.random(-P5JSExtension.width, P5JSExtension.width);
        y  = P5JSExtension.random(-P5JSExtension.height, P5JSExtension.height);
        z  = P5JSExtension.random(0, P5JSExtension.width);
        pz = z;
    }
 public void Update()
 {
     z = z - Starfield.speed;
     if (z < 1)
     {
         z  = P5JSExtension.width;
         x  = P5JSExtension.random(-P5JSExtension.width, P5JSExtension.width);
         y  = P5JSExtension.random(-P5JSExtension.height, P5JSExtension.height);
         pz = z;
     }
 }
    public void fall()
    {
        y = y + yspeed;
        float grav = P5JSExtension.map(z, 0, 20, 0, 0.2f);

        yspeed = yspeed + 0.2f + grav;

        if (y > P5JSExtension.height)
        {
            y      = P5JSExtension.random(-200, -100);
            yspeed = P5JSExtension.random(4, 10);
        }
    }
    void OnGUI()
    {
        P5JSExtension.resetMatrix();
        P5JSExtension.background(51);

        for (int i = 0; i < tree.Count; i++)
        {
            tree[i].show();
            //tree[i].jitter();
        }
        for (var i = 0; i < leaves.Count; i++)
        {
            P5JSExtension.fill(255, 0, 100, 100);
            P5JSExtension.noStroke(); //cause error for somereason
            P5JSExtension.ellipse(leaves[i].x, leaves[i].y, 8, 8);
            leaves[i].y += P5JSExtension.random(0, 2);
        }
    }
Пример #6
0
 public Cell(Vector2?pos, float r = 60, Color32 c = new Color32())
 {
     if (pos.HasValue)
     {
         this.pos = pos.Value;
     }
     else
     {
         this.pos = new Vector2(P5JSExtension.random(P5JSExtension.width), P5JSExtension.random(P5JSExtension.height));
     }
     this.r = r;
     if (c.r == 0 && c.g == 0 && c.b == 0 && c.a == 0)
     {
         this.c = new Color32((byte)P5JSExtension.random(100, 255), 0, (byte)P5JSExtension.random(100, 255), 100);
     }
     else
     {
         this.c = c;
     }
 }
 public Leaf()
 {
     this.pos     = new Vector2(P5JSExtension.random(P5JSExtension.width), P5JSExtension.random(P5JSExtension.height - 100));
     this.reached = false;
 }
Пример #8
0
 public Leaf()
 {
     pos          = P5JSExtension.random3D();
     pos         *= P5JSExtension.random(P5JSExtension.width / 2);
     this.reached = false;
 }
 public void jitter()
 {
     this.end.x += P5JSExtension.random(-1f, 1f);
     this.end.y += P5JSExtension.random(-1f, 1f);
 }