Difference between revisions of "Gamecamp"

From Ghoulwiki
Jump to: navigation, search
Line 1: Line 1:
http://www.gamecampmunich.de/  
+
== links ==
 +
 
 +
* http://www.gamecampmunich.de/  
 
* http://www.gamecampmunich.de/sessions/ !  vorschlag eintragen ?
 
* http://www.gamecampmunich.de/sessions/ !  vorschlag eintragen ?
 
* http://love2d.org/ -- LÖVE
 
* http://love2d.org/ -- LÖVE
Line 9: Line 11:
 
== lua intro ==
 
== lua intro ==
  
 +
* if (cond) then ... elseif (cond) then ... else ... end
 +
* for i=1,10 do ... end
 +
* local myarr = {1,2,3,4,"text",6,7,"blub"}      for k,v in ipairs(arr) do print(k,v) end -- ipairs: int-keys, numer
 +
* local mymap = { a=5, b=3, c=myarr, d={1,2,3,4}, e={x=0,y=0}, }    for k,v in pairs(mymap) do print(k,v) end
 +
* local a,b,c = MyFun()  -- multiple return values
 
* kein int, alles float
 
* kein int, alles float
* local a,b,c = MyFun()  -- multiple return values
 
 
* todo : unpack
 
* todo : unpack
*
 
* for i=1,10 do ... end
 
 
* for i=1,10,2 do ... end      -- -> 1 3 5 7 9
 
* for i=1,10,2 do ... end      -- -> 1 3 5 7 9
* if (cond) then ... elseif (cond) then ... else ... end
 
 
* while (cond) do ... end
 
* while (cond) do ... end
 
* kein continue aber break geht
 
* kein continue aber break geht
Line 42: Line 45:
 
* print(debug.traceback("nachricht"))
 
* print(debug.traceback("nachricht"))
 
* assert(wert_der_true_sein_soll,nachricht)
 
* assert(wert_der_true_sein_soll,nachricht)
* dofile(filepath)  -- TODO : unter löve anders zwecks zip ?
+
* dofile(filepath)  -- (codefile includen) geht unter löve nicht wegen zip, use love.filesystem.load(filepath)() instead
 
* for a,b,c in string.gmatch(txt,"(%w+)=(%w+):(%w+)") do print(a,b,c) end -- z.b. map-daten laden..
 
* 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+)")
 
* local startpos,endpos,match1,match2,match3 = string.find(txt,"(%w+)=(%w+):(%w+)")
Line 58: Line 61:
 
* features
 
* features
 
** audio (mitlerweile ganz gut)
 
** audio (mitlerweile ganz gut)
 +
** particle system
 
** 2d gfx
 
** 2d gfx
** particle system
 
 
** input
 
** input
 
** box2 physic (etwas wackelig)
 
** box2 physic (etwas wackelig)
 +
* love.filesystem.load(filepath)()  -- (codefile includen) wegen zip so statt dofile
  
 
=== rest ===
 
=== rest ===
* hello world
+
 
function love.draw()
 
    love.graphics.print('Hello World!', 400, 300)
 
end
 
  
 
* anekdoten
 
* anekdoten
Line 95: Line 96:
 
== code ==
 
== code ==
 
=== skelett und mainloop ===
 
=== skelett und mainloop ===
cmd> love VERZEICHNIS_MIT_MAIN_LUA/ZIP
+
* win/linux : cmd> love VERZEICHNIS_MIT_MAIN_LUA/ZIP
 +
* mac : zip/ordner auf das löve programm drag-droppen ?
 +
 
 
==== main.lua ====
 
==== main.lua ====
function love.load()
 
-- was vorbereiten
 
end
 
  
function love.draw()
+
* function love.load() ... end -- daten laden
-- was malen
+
* function love.draw() love.graphics.print('Hellö Wörld!', 100, 100) ... end -- sprites zeichnen etc in der frameloop
end
+
* function love.update(dt) ... end -- objekte bewegen, gamelogik etc..
  
function love.update(dt)
 
-- was tun
 
end
 
 
==== conf.lua ====
 
==== conf.lua ====
function love.conf(t)
+
  function love.conf(t)
 
t.screen.width = gScreenW
 
t.screen.width = gScreenW
 
t.screen.height = gScreenH
 
t.screen.height = gScreenH
Line 129: Line 126:
 
t.title = "GameCampBlub"
 
t.title = "GameCampBlub"
 
t.author = "GameCampBlub Crew"
 
t.author = "GameCampBlub Crew"
end
+
  end
  
  
 
=== sprite malen ===
 
=== sprite malen ===
object = love.graphics.newImage("ball.png")
+
* object = love.graphics.newImage("ball.png")
love.graphics.draw(object, 10, 10)
+
* love.graphics.draw(object, 10, 10)
  
 
=== ton abspielen ===
 
=== ton abspielen ===
sound = love.audio.newSource("pling.wav", "static")
+
* sound = love.audio.newSource("pling.wav", "static")
music = love.audio.newSource("techno.ogg") -- streamed
+
* music = love.audio.newSource("techno.ogg") -- streamed
love.audio.play(sound)
+
* love.audio.play(sound)
love.audio.play(music)
+
* love.audio.play(music)
  
 
=== input handling ===
 
=== input handling ===
Line 153: Line 150:
  
 
=== text ausgeben ===
 
=== text ausgeben ===
love.graphics.setFont("AwesomeFont.ttf", 15) -- TODO : gibts den font standardmässig ? falls nein nen anderen =)
+
* love.graphics.setFont("AwesomeFont.ttf", 15) -- TODO : gibts den font standardmässig ? falls nein nen anderen =)
love.graphics.print("This is some awesome text", 100, 100)
+
* love.graphics.print("This is some awesome text", 100, 100)
 
 
 
 
  
== collab edit test, didn't work out though ==
+
== collab edit ==
  
* note : http://etherpad.com/
+
* didn't work : http://etherpad.com/
* note : http://ietherpad.com/WkXqSs9AOr
+
* didn't work : http://ietherpad.com/WkXqSs9AOr
* note : http://piratepad.net/TCRLQs5Bd5
+
* didn't work : http://piratepad.net/TCRLQs5Bd5
 +
* WORKED : sobby/gobby/infinote

Revision as of 13:07, 23 May 2010

links

lua intro

  • if (cond) then ... elseif (cond) then ... else ... end
  • for i=1,10 do ... end
  • local myarr = {1,2,3,4,"text",6,7,"blub"} for k,v in ipairs(arr) do print(k,v) end -- ipairs: int-keys, numer
  • local mymap = { a=5, b=3, c=myarr, d={1,2,3,4}, e={x=0,y=0}, } for k,v in pairs(mymap) do print(k,v) end
  • local a,b,c = MyFun() -- multiple return values
  • kein int, alles float
  • todo : unpack
  • for i=1,10,2 do ... end -- -> 1 3 5 7 9
  • 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) -- (codefile includen) geht unter löve nicht wegen zip, use love.filesystem.load(filepath)() instead
  • 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

  • license: zlib ( This is a very liberal license which permits almost anything. )
  • http://love2d.org/docs/
  • features
    • audio (mitlerweile ganz gut)
    • particle system
    • 2d gfx
    • input
    • box2 physic (etwas wackelig)
  • love.filesystem.load(filepath)() -- (codefile includen) wegen zip so statt dofile

rest

  • 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

skelett und mainloop

  • win/linux : cmd> love VERZEICHNIS_MIT_MAIN_LUA/ZIP
  • mac : zip/ordner auf das löve programm drag-droppen ?

main.lua

  • function love.load() ... end -- daten laden
  • function love.draw() love.graphics.print('Hellö Wörld!', 100, 100) ... end -- sprites zeichnen etc in der frameloop
  • function love.update(dt) ... end -- objekte bewegen, gamelogik etc..

conf.lua

 function love.conf(t)

t.screen.width = gScreenW t.screen.height = gScreenH t.screen.fullscreen = false t.screen.vsync = true t.screen.fsaa = 0 t.version = 0.6 t.modules.joystick = false t.modules.physics = false t.modules.audio = true t.modules.keyboard = true t.modules.event = true t.modules.image = true t.modules.graphics = true t.modules.timer = true t.modules.mouse = true t.modules.sound = true t.console = false t.title = "GameCampBlub" t.author = "GameCampBlub Crew"

 end


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)

input handling

  • local t = love.timer.getTime() -- globaler timestamp in sekunden als float
  • local x,y = love.mouse.getPosition()
  • if love.mouse.isDown("r") then print("Mouse button right is pressed") end
  • if (love.keyboard.isDown(" ")) then print("space gedrückt") end TODO : doppelt, unten nochmal
  • function love.keypressed(k,unicode) if (k == 'escape') then print("escape gedrückt") os.exit(0) end end
  • os.exit(0)  : programm sofort beenden


text ausgeben

  • love.graphics.setFont("AwesomeFont.ttf", 15) -- TODO : gibts den font standardmässig ? falls nein nen anderen =)
  • love.graphics.print("This is some awesome text", 100, 100)

collab edit