Difference between revisions of "Gamecamp"

From Ghoulwiki
Jump to: navigation, search
Line 1: Line 1:
 
== links ==
 
== links ==
  
 +
* http://ghoulsblade.schattenkind.net/wiki/index.php/Gamecamp
 
* http://www.gamecampmunich.de/  
 
* http://www.gamecampmunich.de/  
 
* http://www.gamecampmunich.de/sessions/ !  vorschlag eintragen ?
 
* http://www.gamecampmunich.de/sessions/ !  vorschlag eintragen ?
Line 8: Line 9:
 
* http://www.lua.org/manual/5.1/ -- LUA Reference
 
* http://www.lua.org/manual/5.1/ -- LUA Reference
 
* http://www.lua.org/pil/ -- LUA guide
 
* http://www.lua.org/pil/ -- LUA guide
 +
* http://gobby.0x539.de/trac/wiki/Download
 +
* gitosis@zwischenwelt.org:gamecamp2010.git
 +
* http://www.lostgarden.com/search/label/free%20game%20graphics
 +
* http://www.lostgarden.com/2007/04/free-game-graphics-tyrian-ships-and.html
  
 
== lua intro ==
 
== lua intro ==

Revision as of 14:18, 23 May 2010

links

lua intro

  • print("hello world")
  • local a = 2
  • if (a == 1) then ... elseif (a == 2) then ... else ... end
  • for i=1,10 do print(i) end
  • local myarr = {1,2,3,4,"text",6,7,"blub"}
  • local mymap = { a=5, b=3, c=myarr, d={1,2,3,4}, e={x=0,y=0}, }
  • for k,v in ipairs(myarr) do print(k,v) end
  • for k,v in pairs(mymap) do print(k,v) end
  • table.insert(myarr,10)
  • table.insert(myarr,"bla")
  • mymap["key"] = "wert"
  • mymap.key = "wert"
  • if (mymap.key == "wert") then ... end
  • function MyFun (a) return a,a+1,a+2 end
  • local a,b,c = MyFun(2) -- multiple return values
  • kein int, alles float -> vorsicht bei a/b wird NICHT gerundet. math.floor() benutzen wenn man das will
  • todo : unpack
  • for i=1,10,2 do ... end -- -> 1 3 5 7 9
  • while (cond) do ... if (cond) then break end ... end
  • es gibt kein "continue"
  • 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 objektorientierung

 local myobj = {}
 function bla:blub () ... end  :  TODO : implizites self


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