Topple/Example Code

From Esolang
Jump to navigation Jump to search

← Back to Topple

Example Code

Hello, world!

H.e.l.l.o. ,.~ .w.o.r.l.d.@!,

Hello, world! (but unnecessarily longer)

v=1
a=0
v.{
    a^.0.?.(H.e.l.)[
        a^.1.?.(w.o.r.)
    ]
    l.
    a^.0.?.(o. ,.~ . a=1)[
        a^.1.?.(d.)
        v=0
    ]
}
@!,

Guessing Game

_ Number Game _

_ Number _
n=0
#.<n^+>

_ While "Running" _
r=1

G,u,e,s,s, ,0,-,9,\,
r.{
    g=0
    !.<g^+>
    g^.n^.?.(~R,i,g,h,t,*)[~W,r,o,n,g,\,]
}

2D Grid Player Movement

_Two-Dimensional Grid-Based Player Movement_

_ Player Position _
x=0
y=0

_ Grid-Check Position _
a=0
b=0

_ Grid Size _
s=6
t=0
s^.<t^+>t^-

_ While "Running" _
r=1
r.{
    b=0
    s^.<
        a=0
        s^.<
            x^.a^.?.(y^.b^.?.(o, ,)[ .,| ,])[ .,| ,]
            a^.t^.?.()[a^+]
        >
        \,
        b^.t^.?.()[b^+]
    >

    \,\,|!.0;0;0;
    y^.0.?.()[w.?.(y^-)]    _ W key = Move Up       _
    y^.t^.?.()[s.?.(y^+)]    _ S key = Move Down     _
    x^.0.?.()[a.?.(x^-)]    _ A key = Move Left     _
    x^.t^.?.()[d.?.(x^+)]    _ D key = Move Right    _
    |~
}