Gamecamp
From Ghoulwiki
Revision as of 12:23, 23 May 2010 by Ghoulsblade (talk | contribs)
- http://www.gamecampmunich.de/sessions/ ! vorschlag eintragen ?
Contents
lua intro
- kein int, alles float
- local a,b,c = MyFun() -- multiple return values
- todo : unpack
- for i=1,10 do ... end
- for i=1,10,2 do ... end -- -> 1 3 5 7 9
- if (cond) then ... elseif (cond) then ... else ... end
- while (cond) do ... end
- kein continue aber break geht
- for k,v in pairs(mytable) do ... end
- for k,v in ipairs(mytable) do ... end
- function bla:blub () ... end : TODO : implizites self
- print(var1,var2,var3) alle ausgeben
- comments : -- single line --.... multiline/block
- oop über metatables modellierbar
- funktionen sind 1.class variablen (implizite closure) MyFunction(1, function (a,b) return a+b end )
- local a,b,c -- sonst global
- stringcat : "hello" .. " " .. "world"
lua tables
- arrays : starten bei index 1
- arrays : table.insert(mytable,o)
- assoc/map : mytable[name] = value
- set : mytable[o] = true
- key und value any
- löschen = assign nil
utils
- for line in io.lines(filepath) do ... print(line) ... end
- print(debug.traceback("nachricht"))
- assert(wert_der_true_sein_soll,nachricht)
- dofile(filepath) -- TODO : unter löve anders zwecks zip ?
- for a,b,c in string.gmatch(txt,"(%w+)=(%w+):(%w+)") do print(a,b,c) end -- z.b. map-daten laden..
- local startpos,endpos,match1,match2,match3 = string.find(txt,"(%w+)=(%w+):(%w+)")
- table.sort(arr,function (a,b) return a.feld < b.feld end)
- math.max/min/floor/ceil/pi/atan2/
- math.randomseed(os.time()) -- am anfang einmal aufrufen
- math.random() -- [0;1[ float zwischen 0 und 1
- math.random(n) -- n=int -> returns int in range [1;n]
- math.random(n,m) -- n,m=int -> returns int in range [n;m]
löve 0.6.2
- features
- audio (mitlerweile ganz gut)
- 2d gfx
- particle system
- input
- box2 physic (etwas wackelig)
- hello world
function love.draw()
love.graphics.print('Hello World!', 400, 300)
end
- anekdoten
- ö
- forum: öbey
- seltsame libnamen: AnAL (Animation), LUBE (Network), Pölygamy (State, Helpers), Swingers (gesture)
- binary für win,mac,linux
- game als zip (.love) in einem file
- man kann standalone exe bauen (binary + zip dran-ge-cat'ed)
- todo : keypressed/keyisdown
- todo : time/milliseconds
- todo : particle system beispiel? nicht nötig falls zeit knapp
game
- sidescroller
- tyrian gfx pack von lostgarden
- states (menu,game,highscore)
- map (texteditor, vertical)
- enemies,deco,shots spawn from right (map) and despawn
- parallax background / stars
- interaktive : program new enemies
- object system with stepper (createclass? :syntax?)
- löve particle fx
code
sprite malen
object = love.graphics.newImage("ball.png") love.graphics.draw(object, 10, 10)
ton abspielen
sound = love.audio.newSource("pling.wav", "static") music = love.audio.newSource("techno.ogg") -- streamed love.audio.play(sound) love.audio.play(music)
text ausgeben
love.graphics.setFont("AwesomeFont.ttf", 15) love.graphics.print("This is some awesome text", 100, 100)
input handling
if love.keyboard.isDown( " " ) then print("space pressed") end
function love.keypressed( key, unicode )
if key == "return" then text = "RETURN is being pressed!" end
end
mouse_x = love.mouse.getX() mouse_y = love.mouse.getY() if love.mouse.isDown("r") then text = "Mouse button right is pressed" end
collab edit test, didn't work out though
- note : http://etherpad.com/
- note : http://ietherpad.com/WkXqSs9AOr
- note : http://piratepad.net/TCRLQs5Bd5