Difference between revisions of "Gamecamp"

From Ghoulwiki
Jump to: navigation, search
Line 1: Line 1:
 
http://www.gamecampmunich.de/  
 
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/wiki/Main_Page -- Documentation
 +
* http://www.lua.org/ -- LUA
 +
* http://www.lua.org/manual/5.1/ -- LUA Reference
 +
* http://www.lua.org/pil/ -- LUA guide
  
 
== lua intro ==
 
== lua intro ==
Line 49: Line 53:
  
 
== löve 0.6.2 ==
 
== löve 0.6.2 ==
 +
 +
* license: zlib ( This is a very liberal license which permits almost anything. )
 +
* http://love2d.org/docs/
 
* features
 
* features
 
** audio (mitlerweile ganz gut)
 
** audio (mitlerweile ganz gut)
Line 56: Line 63:
 
** box2 physic (etwas wackelig)
 
** box2 physic (etwas wackelig)
  
 +
=== rest ===
 
* hello world
 
* hello world
 
function love.draw()
 
function love.draw()
Line 86: Line 94:
  
 
== code ==
 
== code ==
 +
=== skelett und mainloop ===
 +
cmd> love VERZEICHNIS_MIT_MAIN_LUA/ZIP
 +
==== main.lua ====
 +
function love.load()
 +
-- was vorbereiten
 +
end
 +
 +
function love.draw()
 +
-- was malen
 +
end
 +
 +
function love.update(dt)
 +
-- was tun
 +
end
 +
==== 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 ===
 
=== sprite malen ===
 
object = love.graphics.newImage("ball.png")
 
object = love.graphics.newImage("ball.png")
Line 95: Line 141:
 
love.audio.play(sound)
 
love.audio.play(sound)
 
love.audio.play(music)
 
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 ===
 
=== text ausgeben ===
love.graphics.setFont("AwesomeFont.ttf", 15)
+
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)
  
=== 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 ==
 
== collab edit test, didn't work out though ==

Revision as of 12:51, 23 May 2010

http://www.gamecampmunich.de/

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

  • license: zlib ( This is a very liberal license which permits almost anything. )
  • http://love2d.org/docs/
  • features
    • audio (mitlerweile ganz gut)
    • 2d gfx
    • particle system
    • input
    • box2 physic (etwas wackelig)

rest

  • 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

skelett und mainloop

cmd> love VERZEICHNIS_MIT_MAIN_LUA/ZIP

main.lua

function love.load() -- was vorbereiten end

function love.draw() -- was malen end

function love.update(dt) -- was tun end

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 test, didn't work out though