Dismiss Notice
Hey Guest,
If you are interested in ghosting, the Ghosting Awards for January 2025 has just been announced:

Click here to check it out!

Automatically Generated Track (Distance Challenge)

Discussion in 'Have an idea? Post it here!' started by pssst, Nov 11, 2014.

  1. pssst

    pssst Forum Legend Elite Author Team Blob Official Author

    Awarded Medals
    On another version of free rider, there was a mini game of sorts where a track would be automatically generated and increasing in difficulty as it progressed. I found this to be very fun and I think it would be a nifty addition to frhd if it could be made.
     
    tigers_1234, Creak, FOIL and 10 others like this.
  2. goofyinc

    goofyinc Well-Known Member Official Author

    Awarded Medals
    I've been working on this as well!
    So far i've been trying to understand the track code. I drew a dirt jump pattern in the editior and then modify it's position in the code.
    Maybe we can get this to work if we understand the code.

    Here is a little preview code:
    Code:
    -18 1i 18 1i,
    
    6e 81 6n 8g 7a 9d 7u a9 8i b4 97 bu 9t cn aj df b9 e6 c0 et co fi dg g7 e9 gq f3 hd ft hv gn if hj iv ie je jb js k8 k9 l5 kl m4 l0 n2 lb o2 lk p1 ls q2 m4 r3 ma s5 mg t7 ml ua mo vd mr 10h mt 11m mu 128 mu 12o mu 13o mu 14o mt 15n ms 16l mq 17j mn 18h mk 19e mh 1aa md 1b6 m8 1c1 m2 1cs lt 1dm lm 1ef lf 1f8 l7 1g1 kv 1gp kn 1hg kd 1i7 k3 1iu jp 1jk je 1k9 j2 1ku im 1li i9 1m6 hs 1mp he 1nb h0 1nt gh 1of g1 1p0 fh 1pg f0 1q0 ef 1q8 e6,
    
    2pn dr 2q3 e9 2qq f4 2ri fu 2sb go 2t4 hg 2tu i8 2up iu 2vk jk 30g k9 31c kt 329 lg 337 m2 345 mk 353 n4 363 nk 372 o2 383 og 394 ot 3a5 p9 3b8 pk 3ca pv 3de q8 3ei qh 3fm qo 3gs qv 3i1 r5 3j8 ra 3kf re 3lm rh 3mu rj 3o7 rl 3pg rl 3q5 rl,
    
    ##
    So far I got something like this:
    • Connected lines are grouped together with a comma
    • one line = (XX XX XX XX,) can be negative and hexadecimal
    • first hex of a line is the begin point x-axis of the line, second the first y-axis, third end point x-axis, second y-axis.
    Maybe we can work on how to modify the position so we can automate and create perfect infinite tracks.

    G.
     
  3. Cryogenic

    Cryogenic Well-Known Member Official Author

    Using this you could also prefect the curve of your track too. I'd be up to help, just pm me.
     
    tigers_1234, Creak, Totoca12 and 3 others like this.
  4. FREEZ

    FREEZ Well-Known Member Official Author

    I wont. I do not code :D
     
    ei8ht, Creak, Dakoziol-2nd and 2 others like this.
  5. goofyinc

    goofyinc Well-Known Member Official Author

    Awarded Medals
  6. Cryogenic

    Cryogenic Well-Known Member Official Author

    Weilong likes this.
  7. goofyinc

    goofyinc Well-Known Member Official Author

    Awarded Medals
    i guess is going to be a replace job by hand because all coordinates have to be moved to the right for however long the copy paste piece is.

    I'm still looking for a good explanation of the coordinate system cause i'm a little confused by it xD
     
  8. Char

    Char Free Rider HD Developer Official Author

    Forget the coordinate system inside canvas. This means nothing in respect to the game.

    Onto the coordinate system.

    A track code is 3 parts divided by '#'
    Code:
               
               var track_parts = code.split('#');
                track.physicsLines = track_parts[0].split(',');
                track.sceneryLines = track_parts[1].split(',');
                track.powerups = track_parts[2].split(',');
    
    Each line is separated by a comma ','
    The coordinate system is base32 encoded
    http://en.wikipedia.org/wiki/Base32

    To explain further.
    If there are multiple lines, that connect at a point, the code for that will be simplified.
    Example:

    Line1.p1
    Line1.p2

    Line2.p1
    Line2.p2

    If Line1.p2 == Line.2.p1
    Then we only need 3 coordinates to explain that line, instead of 4.
    That is why in the line code, one line can have multiple coordinates.
     
    FoxGamingTM, ei8ht, Orbit and 8 others like this.
  9. Char

    Char Free Rider HD Developer Official Author

  10. goofyinc

    goofyinc Well-Known Member Official Author

    Awarded Medals
    Weilong and Cryogenic like this.
  11. Char

    Char Free Rider HD Developer Official Author

  12. Cryogenic

    Cryogenic Well-Known Member Official Author

    I've been playing around with that first link. It was a real easy fix to how make it smoother. All you needed to do was to make the step size bigger. I found out a way to make the tracks have a jump. The only problem is that I can't figure out of to make the jumps more random. This is going to be harder than I thought.

    This is the smoother code
    Code:
    -68 3t -5f 40 -4m 42 -3t 40 -34 3t -2b 3p -1i 3j -p 3b 0 34 p 2s 1i 2l 2b 2e 34 2a 3t 27 4m 26 5f 27 68 2a 71 2e 7q 2k 8j 2s 9c 34 a5 3b au 3i bn 3p cg 3t d9 40 e2 42 er 40 fk 3t gd 3p h6 3i hv 3b io 34 jh 2s ka 2l l3 2e ls 2a ml 27 ne 26 o7 27 p0 2a pp 2e qi 2k rb 2s s4 33 st 3b tm 3j uf 3p v8 3t 101 40 10q 42 11j 40 12c 3t 135 3p 13u 3j 14n 3b 15g 34 169 2s 172 2k 17r 2e 18k 2a 19d 27 1a6 26 1av 27 1bo 2a 1ch 2e 1da 2k 1e3 2s 1es 33 1fl 3b 1ge 3i 1h7 3p 1i0 3t 1ip 40 1ji 42 1kb 40 1l4 3t 1lt 3p 1mm 3j 1nf 3b 1o8 34 1p1 2s 1pq 2l 1qj 2e 1rc 2a 1s5 27 1su 26 1tn 27 1ug 2a 1v9 2e 202 2l 20r 2s 21k 33 22d 3b 236 3i 23v 3p 24o 3t 25h 40 26a 42 273 40 27s 3t 28l 3p 29e 3j 2a7 3b 2b0 34 2bp 2s 2ci 2l 2db 2e 2e4 2a 2et 27 2fm 26 2gf 27 2h8 2a 2i1 2e 2iq 2k 2jj 2s 2kc 34 2l5 3b 2lu 3i 2mn 3p 2ng 3t 2o9 40 2p2 42 2pr 40 2qk 3t 2rd 3p 2s6 3j 2sv 3b 2to 34 2uh 2s 2va 2l 303 2e 30s 2a 31l 27 32e 26 337 27 340 2a 34p 2e 35i 2k 36b 2s 374 34 37t 3b 38m 3j 39f 3p 3a8 3t 3b1 40 3bq 42 3cj 40 3dc 3t 3e5 3p 3eu 3j 3fn 3b 3gg 34 3h9 2s 3i2 2k 3ir 2e 3jk 2a 3kd 27 3l6 26 3lv 27 3mo 2a 3nh 2e 3oa 2k 3p3 2s 3ps 34 3ql 3b 3re 3i 3s7 3p 3t0 3t 3tp 40 3ui 42 3vb 40 404 3t 40t 3p 41m 3j 42f 3b 438 34 441 2s 44q 2k 45j 2e 46c 2a 475 27 47u 26 48n 27 49g 2a 4a9 2e 4b2 2k 4br 2s 4ck 34 4dd 3b 4e6 3i 4ev 3p 4fo 3t 4gh 40 4ha 42 4i3 40 4is 3t 4jl 3p 4ke 3j 4l7 3b 4m0 34 4mp 2s 4ni 2k 4ob 2e 4p4 2a 4pt 27 4qm 26 4rf 27##
     
    Last edited: Nov 13, 2014
    Weilong likes this.
  13. Cryogenic

    Cryogenic Well-Known Member Official Author

    Char could you explain in more detail how the track code works?
    EDIT: As in how it is encoded, and why it works.
     
    Last edited: Nov 13, 2014
    Dakoziol-2nd and Weilong like this.
  14. Cryogenic

    Cryogenic Well-Known Member Official Author

    I just spent about 4 hours learning all about how to plot a line and convert it into base32 code. I'm making my own program now that should create a random terrain!
     
  15. Cryogenic

    Cryogenic Well-Known Member Official Author

    Joelbmx likes this.
  16. Cryogenic

    Cryogenic Well-Known Member Official Author

    It paid off! I made a random line that will go on for as long as you want. It isn't smooth yet, and the altitude doesn't change too much. It does gradually get harder. I had to use the code that Char showed us, but I only used it because I couldn't figure out how to convert my "track" into base32 code. Anyway, it's not done yet, not nearly. But I'm getting there!
    http://jsfiddle.net/booka66/2zyLw13t/3/embedded/result/
     
  17. LukeSpecogna

    LukeSpecogna Well-Known Member Official Author

    Nice!
     
    goofyinc likes this.
  18. goofyinc

    goofyinc Well-Known Member Official Author

    Awarded Medals
    Joelbmx, Cryogenic and LukeSpecogna like this.
  19. LukeSpecogna

    LukeSpecogna Well-Known Member Official Author

  20. goofyinc

    goofyinc Well-Known Member Official Author

    Awarded Medals
    my first hard coded track, play and test here:


    I started with one dirt jump i drew with the bezier tool, and copied and pasted the code then modified the position of every line. But soon enough i noticed that the repeated dirt jump pattern did not work out. After two or three jumps i over jumped the dirt jump every time. So i went back to the drawing board, created three different sets of dirt jump and landings and copied and pasted randomly one of the three versions, which worked out pretty good imho.

    Cheers, more to come :p

    G.
     

Share This Page