lokal x = 10 declare une variable. lokal x: nombre = 10 la type.
Types : nombre, texte, bool, nix, tout.
Constantes : yo (vrai), nei (faux), nix (rien).
Commentaire : -- ...
foncsion function | hopla end | lokal local |
si if | dann then | sunscht else |
sunschtwenn elseif | solang while | mach do |
fer for | widerhol repeat | bis until |
zeruck return | abbruch break | in in |
unn and | oder or | nit not |
Reserves aussi : scene entite schluss match fall wenn.
Calcul + - * / % ^ · comparaison == ~= < > <= >=
· texte .. (concatener) et # (longueur) · pipe x |> f = f(x)
si vie <= 0 dann perdu = yo sunscht perdu = nei hopla solang i < 10 mach i = i + 1 hopla fer i = 1, 10 mach ... hopla -- boucle numerique fer c, v in pairs(t) mach ... hopla -- parcours de table
foncsion aire(r: nombre): nombre zeruck 3.14 * r * r hopla
"salut $nom" -- variable
"total ${a + b}" -- expression
"prix \$5" -- $ litteral
lokal t = { 10, 20, 30 } print(t[1]) print(#t)
table.insert(t, 40) table.remove(t, 1)
match forme mach
fall "cercle" dann ...
fall { w = w, h = h } wenn w == h dann ...
fall _ dann ... -- joker
sunscht ... -- defaut
hopla
scene Menu
foncsion dessiner() ... hopla
foncsion touche_pressee(k)
si k == "space" dann bretz.remplace(Jeu) hopla
hopla
schluss
bretz.pousse(s) empile · bretz.remplace(s) ·
bretz.retire() · bretz.dessus()
entite Balle { x: nombre, y: nombre }
foncsion bouge(dt: nombre) self.x = self.x + 60 * dt hopla
schluss
lokal b = Balle.nouveau{ x = 0, y = 0 }
charger() au demarrage · actualiser(dt) chaque frame ·
dessiner() affichage · touche_pressee(k) ·
touche_relachee(k) · souris_pressee(x, y, b)
amour.touche(k) = touche MAINTENUE (bouger en continu, dans actualiser).
touche_pressee(k) = enfoncee UNE fois (menus, saut).
Multiplie toujours par dt.
si amour.touche("left") dann x = x - 250 * dt hopla
si amour.touche("right") dann x = x + 250 * dt hopla
Touches : left right up down space return escape tab lshift, lettres a..z, chiffres 0..9.
amour.couleur(r,g,b,a) | couleur 0..1 |
amour.cercle(mode,x,y,r) | "fill" ou "line" |
amour.rectangle(mode,x,y,l,h) | rectangle |
amour.ligne(x1,y1,x2,y2,...) | ligne |
amour.texte(txt,x,y) | texte |
amour.image(chemin) / amour.dessine(img,x,y) | images |
amour.largeur() / amour.hauteur() | taille fenetre |
amour.touche(k) / amour.souris() / amour.clic(b) | entrees |
amour.son(chemin) / amour.joue(s) | son |
amour.hasard(min,max) / amour.temps() / amour.quitter() | divers |