Difference between revisions of "Gamecamp"

From Ghoulwiki
Jump to: navigation, search
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
git pull git://192.168.2.105/home/hagish/dev/gamecamp2010
 
git-daemon --verbose --export-all /home/hagish/dev
 
/usr/lib/git-core/git-daemon
 
 
 
== links ==
 
== links ==
  
 +
* example projects : http://schattenkind.net/gamecamp/
 
* löve binaries : http://ghoulsblade.schattenkind.net/love2d_0.6.2/
 
* löve binaries : http://ghoulsblade.schattenkind.net/love2d_0.6.2/
 +
* löve 0.6 docs : http://web.ics.purdue.edu/~dcfritz/lovewiki/love4.html  offline: http://commondatastorage.googleapis.com/loveclub/docs.zip
 +
 +
* http://gamecamp.pastebin.com : workshop 30.05.2010
  
 
* http://ghoulsblade.schattenkind.net/wiki/index.php/Gamecamp
 
* http://ghoulsblade.schattenkind.net/wiki/index.php/Gamecamp
Line 19: Line 19:
 
* http://www.lostgarden.com/search/label/free%20game%20graphics
 
* http://www.lostgarden.com/search/label/free%20game%20graphics
 
* http://www.lostgarden.com/2007/04/free-game-graphics-tyrian-ships-and.html
 
* http://www.lostgarden.com/2007/04/free-game-graphics-tyrian-ships-and.html
 +
* [[Lua Objektorientierung]]
 +
 +
== lua intro ==
 +
 +
Lua is a powerful, fast and lightweight scripting language.
 +
small : 17000 lines of C. (linux) Lua interpreter 153K and the Lua library takes 203K.
 +
license : MIT license, no cost, commercial use, no source required
 +
 +
* Crysis & Far Cry,
 +
* World of Warcraft,
 +
* Ragnarok Online,
 +
* Dawn of War,
 +
* Counter Strike 2D,
 +
* Civilization 5.
 +
* Fable II
 +
* Heroes of Might and Magic V
 +
* Aquaria (video game)
 +
* Baldur's Gate
 +
* Civilization V
 +
* Company of Heroes
 +
* Escape from Monkey Island
 +
* Natural Selection 2
 +
* Painkiller (video game)
 +
* Ragnarok Online
 +
* Runes of Magic
 +
* S.T.A.L.K.E.R.: Shadow of Chernobyl
 +
* Warhammer 40,000: Dawn of War
 +
* World of Warcraft
 +
* [SimCity 4]
 +
* Ryzom
  
 
== lua intro ==
 
== lua intro ==
Line 39: Line 69:
 
* local a,b,c = MyFun(2)  -- multiple return values  (a=2,b=3,c=4)
 
* local a,b,c = MyFun(2)  -- multiple return values  (a=2,b=3,c=4)
 
* kein int, alles float -> vorsicht bei a/b wird NICHT gerundet. math.floor() benutzen wenn man das will
 
* 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
 
* for i=1,10,2 do ... end      -- -> 1 3 5 7 9
 
* while (cond) do ... if (cond) then break end ... end
 
* while (cond) do ... if (cond) then break end ... end
 
* es gibt kein "continue"
 
* es gibt kein "continue"
* oop über metatables modellierbar
 
 
* funktionen sind 1.class variablen (implizite closure) MyFunction(1, function (a,b) return a+b end )     
 
* 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"  
 
* stringcat : "hello" .. " " .. "world"  
* (coroutine, threading)
 
  
 
=== lua objektorientierung ===
 
=== lua objektorientierung ===
 
  
 
* klasse und methoden definieren :  
 
* klasse und methoden definieren :  
Line 106: Line 131:
 
** input
 
** input
 
** box2 physic (etwas wackelig)
 
** box2 physic (etwas wackelig)
* love.filesystem.load(filepath)()  -- (codefile includen) wegen zip so statt dofile
 
  
 
=== rest ===
 
=== rest ===
 
  
 
* anekdoten
 
* anekdoten
Line 119: Line 142:
 
* game als zip (.love) in einem file
 
* game als zip (.love) in einem file
 
* man kann standalone exe bauen (binary + zip dran-ge-cat'ed)
 
* man kann standalone exe bauen (binary + zip dran-ge-cat'ed)
* todo : keypressed/keyisdown
+
* timestamp : love.timer.getTime()  float in sekunden
* todo : time/milliseconds
+
* love.filesystem.load(filepath)()  -- (codefile includen) wegen zip so statt dofile
* todo : particle system beispiel? nicht nötig falls zeit knapp
 
  
 
== game ==
 
== game ==
  
 
* sidescroller  
 
* sidescroller  
* tyrian gfx pack von lostgarden
+
* tyrian gfx pack von lostgarden.com
 
* states (menu,game,highscore)
 
* 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
 
* TODO : framerate unabhängiger zeitverlauf : speed/gMyTicks/gTimeSinceLastFrame etc
 
  
 
== code ==
 
== code ==
Line 172: Line 187:
  
 
=== sprite malen ===
 
=== sprite malen ===
* object = love.graphics.newImage("ball.png")
+
* gfx = love.graphics.newImage("ball.png")
* love.graphics.draw(object, 10, 10)
+
* love.graphics.draw(gfx, 10, 10)
  
 
=== ton abspielen ===
 
=== ton abspielen ===
Line 189: Line 204:
 
* function love.keypressed(k,unicode) if (k == 'escape') then print("escape gedrückt") os.exit(0) end end
 
* function love.keypressed(k,unicode) if (k == 'escape') then print("escape gedrückt") os.exit(0) end end
 
* os.exit(0)  : programm sofort beenden
 
* os.exit(0)  : programm sofort beenden
 
  
 
=== text ausgeben ===
 
=== text ausgeben ===
Line 195: Line 209:
 
* love.graphics.print("This is some awesome text", 100, 100)
 
* love.graphics.print("This is some awesome text", 100, 100)
  
== collab edit ==
+
== bei problemen mit grafikanzeige (eee pc, weisse bilder) ==
 +
 
 +
zum bilderladeen statt
 +
* gfx = love.graphics.newImage("ball.png")
 +
* gfx = newPaddedImage("ball.png")
 +
 
 +
<pre>
 +
function newPaddedImage(filename)
 +
    local source = love.image.newImageData(filename)
 +
    local w, h = source:getWidth(), source:getHeight()
 +
    -- Find closest power-of-two.
 +
    local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
 +
    local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))
 +
   
 +
    local gfx = nil
 +
   
 +
    -- Only pad if needed:
 +
    if wp ~= w or hp ~= h then
 +
        local padded = love.image.newImageData(wp, hp)
 +
        padded:paste(source, 0, 0)
 +
        gfx = love.graphics.newImage(padded)
 +
    else
 +
gfx = love.graphics.newImage(source)
 +
end
 +
   
 +
    -- originalgroesse in die groessenfunctionen patchen
 +
    local sourceW = source:getWidth()
 +
    local sourceH = source:getHeight()
 +
   
 +
    return gfx
 +
end
 +
</pre>
  
* didn't work : http://etherpad.com/
+
== git lan usage ==
* didn't work : http://ietherpad.com/WkXqSs9AOr
+
git pull git://192.168.2.105/home/hagish/dev/gamecamp2010
* didn't work : http://piratepad.net/TCRLQs5Bd5
+
git-daemon --verbose --export-all /home/hagish/dev
* WORKED : sobby/gobby/infinote
+
/usr/lib/git-core/git-daemon

Latest revision as of 11:17, 28 January 2012

links

lua intro

Lua is a powerful, fast and lightweight scripting language. small : 17000 lines of C. (linux) Lua interpreter 153K and the Lua library takes 203K. license : MIT license, no cost, commercial use, no source required

  • Crysis & Far Cry,
  • World of Warcraft,
  • Ragnarok Online,
  • Dawn of War,
  • Counter Strike 2D,
  • Civilization 5.
  • Fable II
  • Heroes of Might and Magic V
  • Aquaria (video game)
  • Baldur's Gate
  • Civilization V
  • Company of Heroes
  • Escape from Monkey Island
  • Natural Selection 2
  • Painkiller (video game)
  • Ragnarok Online
  • Runes of Magic
  • S.T.A.L.K.E.R.: Shadow of Chernobyl
  • Warhammer 40,000: Dawn of War
  • World of Warcraft
  • [SimCity 4]
  • Ryzom

lua intro

  • print("hello world",2,3+4,"test",a) -- comment
  • block comment : --[[....]]
  • 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 -- arrays mit numerischen indices sortiert auflisten (ipairs -> int)
  • for k,v in pairs(mymap) do print(k,v) end -- pairs ohne i : alle key/values in asso-array/map auflisten, unsortiert
  • table.insert(myarr,10)
  • mymap["key"] = "wert"
  • mymap.key = "wert"
  • if (mymap.key == "wert") then ... end
  • function MyFun (x) return x+5 end
  • function MyFun (x) return x,x+1,x+2 end
  • local a,b,c = MyFun(2) -- multiple return values (a=2,b=3,c=4)
  • kein int, alles float -> vorsicht bei a/b wird NICHT gerundet. math.floor() benutzen wenn man das will
  • 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"
  • funktionen sind 1.class variablen (implizite closure) MyFunction(1, function (a,b) return a+b end )
  • stringcat : "hello" .. " " .. "world"

lua objektorientierung

  • klasse und methoden definieren :
    • cMyClass = CreateClass()
    • function cMyClass:blub (a,b,c) print("blub") end -- ist dasselbe wie :
    • function cMyClass.blub (self,a,b,c) print("blub") end -- ist dasselbe wie :
    • cMyClass.blub = function (self,a,b,c) print("blub") end
  • aufruf :
    • local myobj = CreateClassInstance(cMyClass)
    • myobj:blub(3,4,5) -- aufruf, ist dasselbe wie
    • myobj.blub(myobj,3,4,5)
  • vererbung :
    • cMyDerived = CreateClass(cMyClass)
    • function cMyDerived:boing () print("boing!") end
    • local myd = CreateClassInstance(cMyDerived)
    • myd:blub()
    • myd:boing()
  • boilerplate :
    • function CreateClass(base) local p = base and setmetatable({},base._cmeta) or {} p._cmeta = { __index=p } return p end
    • function CreateClassInstance(someclass) return setmetatable({},someclass._cmeta) end

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)

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)
  • timestamp : love.timer.getTime() float in sekunden
  • love.filesystem.load(filepath)() -- (codefile includen) wegen zip so statt dofile

game

  • sidescroller
  • tyrian gfx pack von lostgarden.com
  • states (menu,game,highscore)

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

  • gfx = love.graphics.newImage("ball.png")
  • love.graphics.draw(gfx, 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)

bei problemen mit grafikanzeige (eee pc, weisse bilder)

zum bilderladeen statt

  • gfx = love.graphics.newImage("ball.png")
  • gfx = newPaddedImage("ball.png")
function newPaddedImage(filename)
    local source = love.image.newImageData(filename)
    local w, h = source:getWidth(), source:getHeight()
    -- Find closest power-of-two.
    local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
    local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))
    
    local gfx = nil
    
    -- Only pad if needed:
    if wp ~= w or hp ~= h then
        local padded = love.image.newImageData(wp, hp)
        padded:paste(source, 0, 0)
        gfx = love.graphics.newImage(padded)
    else
		gfx = love.graphics.newImage(source)
	end
    
    -- originalgroesse in die groessenfunctionen patchen
    local sourceW = source:getWidth()
    local sourceH = source:getHeight()
    
    return gfx
end

git lan usage

git pull git://192.168.2.105/home/hagish/dev/gamecamp2010
git-daemon --verbose --export-all /home/hagish/dev
/usr/lib/git-core/git-daemon