Back To Top
  • Hey Guest,
    If you are interested in ghosting, the Ghosting Awards from February 2025 all the way up to June 2025 have just been announced:

    Statement regarding the delays

    Ghosting Awards for February 2025

    Ghosting Awards for March 2025

    Ghosting Awards for April 2025

    Ghosting Awards for May 2025

    Ghosting Awards for June 2025
    Dismiss Notice
  • FRHD-API - FRHD-Lang replacement

    Discussion in 'Anything and everything Free Rider' started by KillerMeemStar, Aug 20, 2016.

    1. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

    2. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

      Another Example
      Example of vertical lines (with easily variables), with alternating between scenery and foreground:
      Code:
      var startX = -40;
      var endX = 80;
      var spacing = 10;
      var topY = 50;
      var bottomY = 130;
      
      var scenery = false;
      for (var x = startX; x <= endX; x += spacing, scenery = !scenery) {
          track.setMode(scenery ? 1 : 0);
          track.addLine(new Line(x, topY, x, bottomY));
      }
      here's how for loops work:

      the format of the for loop in JS and most languages is for (initializeVariablesHere; loopUntilThisIsTrue; doThisEveryTimeItLoops)

      so for example (ha, for. ha.)

      for (var i = 0; i < 10; i++)

      will run the code inside the braces after it. there is a variable called "i" which can be accessed inside the braces.
      so every time it loops, i will equal:
      0, then 1, then 2... etc..... then 9. Since after that (10 < 10) is false (10 is not smaller than 10), the loop stops. You could also do

      for (var i = 0; i < 10; i += 2)

      so this time, instead of i increasing by 1, it increases by two (++ is short for += 1)

      so every time it loops, i equals 0, then 2, then 4, then 6, then 8. since 10 < 10 is false, it stops looping

      Hope that helps... just ask any more questions if you have some ;)

      (Quoted exactly from what I told m1.c3 :p)
       
      m1.c3 likes this.
    3. m1.c3

      m1.c3 Active Member Official Author

      lard grid
      Code:
      var startX = -699245;
      var endX = 699245;
      var spacing = 490;
      var topY = -10000;
      var bottomY = 10000;
      
      for (var y = topY; y <= bottomY; y += spacing) {
          track.addLine(new Line(startX, y, endX, y));
      }
      var startX = -10000;
      var endX = 10000;
      var spacing = 490;
      var topY = -699245;
      var bottomY = 699245;
      
      for (var x = startX; x <= endX; x += spacing) {
          track.addLine(new Line(x, topY, x, bottomY));
      }
       
      Calculus and KillerMeemStar like this.
    4. DeathBob1

      DeathBob1 Active Member Official Author

      Calculus and KillerMeemStar like this.
    5. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

      frhd-lang? that one is simpler, but this one is already an existing program, so ppl who know it can use it right away
      also it has many many more features, since it's already a programming language in use
       
      m1.c3 likes this.
    6. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

      Sierpinski Triangle
      Hello! If you haven't seen my sierpinski triangle track, here it is: https://www.freeriderhd.com/t/297624-sierpinski-triangle

      The code for this is (I translated code from an originally pure JS program):
      Code:
      var width = 600;
      var height = 600;
      var size = 500;
      var dx = -300, dy = -300;
         
      function sierpinski(Ax,Ay,Bx,By,Cx,Cy,d) {
          if(d>0) {
              var pointAx = (Bx + Cx) / 2;
              var pointAy = (By + Cy) / 2;
         
              var pointBx = (Ax + Cx) / 2;
              var pointBy = (Ay + Cy) / 2;
         
              var pointCx = (Ax + Bx) / 2;
              var pointCy = (Ay + By) / 2;
         
              var d2 = d-1;
              sierpinski(Ax,Ay,pointBx,pointBy,pointCx,pointCy,d2);
              sierpinski(pointCx,pointCy,pointAx,pointAy,Bx,By,d2);
              sierpinski(pointBx,pointBy,pointAx,pointAy,Cx,Cy,d2);
          }
          else {
              track.addLine(new Line(Ax + dx, Ay + dy, Bx + dx, By + dy));
              track.addLine(new Line(Bx + dx, By + dy, Cx + dx, Cy + dy));
              track.addLine(new Line(Cx + dx, Cy + dy, Ax + dx, Ay + dy));
          }
      }
         
         
      var midPointX = width/2;
      var midPointY = height/2;
      
      var deep = 6;
      
      var ri = (size/6) * Math.sqrt(3);
      var ru = (size/3) * Math.sqrt(3);
      
      var pointAx = midPointX-(size/2);
      var pointAy = midPointY+ri;
      
      var pointBx = midPointX+(size/2);
      var pointBy = midPointY+ri;
      
      var pointCx = midPointX;
      var pointCy = midPointY-ru;
      
      sierpinski(pointAx,pointAy,pointBx,pointBy,pointCx,pointCy,deep);
      When you see var deep = 6, that represents how many layers will be rendered.
      At the top, width and height are self-explanatory, dx and dy represent the offset (so you can move it around the track)
       
      Calculus and m1.c3 like this.
    7. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

      Another fractal
      Track: https://www.freeriderhd.com/t/297692-another-fractal

      I like to call this a "triangle approximation". Here's the code:
      Code:
      var x = -40;
      var y = 50;
      var size = 1600;
      var layers = 8;
      
      // left side of triangle
      track.addLine(new Line(x, y, x, y + size));
      // bottom side
      track.addLine(new Line(x, y + size, x + size, y + size));
      // hypotenuse
      track.addLine(new Line(x + size, y + size, x, y));
      
      drawLayer(x, y + size / 2, 1, layers);
      
      // layer starts at 1 (not 0)
      function drawLayer(x, y, layer, maxLayers) {
          if (layer > maxLayers)
              return;
          var powerOfTwo = Math.pow(2, layer);
          var endX = x + size / powerOfTwo;
          var endY = y + size / Math.pow(2, layer);
          track.addLine(new Line(x, y, endX, y));
          track.addLine(new Line(endX, y, endX, endY));
        
          layer++;
          // top side
          drawLayer(x, y - size / Math.pow(2, layer), layer, maxLayers);
          // right side
          drawLayer(x + size / Math.pow(2, layer) * 2, y + size / Math.pow(2, layer), layer, maxLayers);
      }
       
      m1.c3 likes this.
    8. m1.c3

      m1.c3 Active Member Official Author

      Click here to see thread
       
      KillerMeemStar likes this.
    9. Sidewalk

      Sidewalk Forum Legend Ghosting Legend Team Helicopter Official Author

      Awarded Medals
      KillerMeemStar why the hell do you have me in your sig saying something I didn't say?
       
      TeamPhantom and m1.c3 like this.
    10. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

      memes
       
      m1.c3 likes this.
    11. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

      do u really want me to remove it? it's kind of obvious u didn't say it, since its a bigger font and different font family
       
      m1.c3 likes this.
    12. Sidewalk

      Sidewalk Forum Legend Ghosting Legend Team Helicopter Official Author

      Awarded Medals
      Uh... you don't have to I was just kinda surprised lol
       
      KillerMeemStar likes this.
    13. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

      i just went to a random track with a bunch of comments, and a meme popped out
       
    14. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

      Added curves! Thanks to Polygon for help with the math!

      Function: track.addBezier(new Point(0,0), new Point(100,-100), new Point(100,0), 10) for example will create a curve starting at (0,0), ending at (100,-100), with the control point (100,0), made up of 10 line segments
       
      m1.c3 likes this.
    15. MaxwellNurzia

      MaxwellNurzia Casual Member

      octo and KillerMeemStar like this.
    16. KillerMeemStar

      KillerMeemStar Well-Known Member Official Author

      Thanks!
      So you are another person who everyone either really hates or really likes? :p
       
    17. MaxwellNurzia

      MaxwellNurzia Casual Member

      Yep, I caused quite a controversy last year when I introduced an image to track converter that I had coded as an experiment, to test how I could generate track code. Needless to say, a lot of people liked it but more people didn't; it ended up getting taken down. Sorta sad because most of the comments weren't about the program but about my age
       
    18. darksmoke11

      darksmoke11 Well-Known Member Official Author

      Awarded Medals
      What you made was awesome but releasing something like that to the public will introduce idiots that'll exploit it
       
      Sidewalk, Nitrogeneric, bolaa and 3 others like this.
    19. Magic_Man101

      Magic_Man101 Casual Member Official Author

      It doesn't work. It brings me to a godaddy thing.
       
      FIREBEATS likes this.

    Share This Page