aboutsummaryrefslogtreecommitdiff
path: root/bin/game/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'bin/game/main.lua')
-rw-r--r--bin/game/main.lua19
1 files changed, 11 insertions, 8 deletions
diff --git a/bin/game/main.lua b/bin/game/main.lua
index d268e23..98f7bc7 100644
--- a/bin/game/main.lua
+++ b/bin/game/main.lua
@@ -52,14 +52,14 @@ local spr = nil
local bitmap = nil
local sprs = {}
local animator = nil
-
+local spr = nil
local function createAnimation(path, count, r, c, w, h, loop, speed)
local tex = jin.graphics.newTexture(path)
local ssheet = jin.graphics.newSpriteSheet(tex)
local sprs = ssheet:newSprites(count, r, c, w, h, jin.graphics.SpriteOrigin.BOTTOMCENTER)
return jin.graphics.newAnimation(sprs, loop, speed)
end
-asd
+
function jin.core.onLoad()
bitmap = jin.graphics.newBitmap(200, 200, function(w, h, x, y)
return {255*math.sin(x/w),255 - 255,255*math.cos(y/w),255}
@@ -70,11 +70,10 @@ function jin.core.onLoad()
tex = jin.graphics.newTexture(bitmap)
local tex2 = jin.graphics.newTexture("anim.png")
local ssheet2 = jin.graphics.newSpriteSheet(tex2)
- local animation = createAnimation("anim2.png", 27, 3, 10, 200, 200, true, 100)
+ local animation = createAnimation("anim2.png", 27, 3, 10, 200, 200, true, 50)
animator = jin.graphics.newAnimator(animation)
- animation = nil
local ssheet = jin.graphics.newSpriteSheet(tex)
- spr = ssheet:newSprite({50, 50, 50, 50}, 20, 20)
+ spr = animation:getFrame(1)
tex = nil
-- music = jin.audio.newSource("forest.ogg")
-- music:setVolume(0.5)
@@ -86,9 +85,13 @@ function jin.core.onLoad()
local h = timer:every(0.5, function(sp)
end, spr)
- timer:after(6, function(p)
+ timer:every(3, function(p)
--timer:cancel(h)
- --animator:pause()
+ if animator:getSpeed() == 50 then
+ animator:setSpeed(100)
+ elseif animator:getSpeed() == 100 then
+ animator:setSpeed(50)
+ end
end, animator)
jin.graphics.pushMatrix()
jin.graphics.translate(0, 0)
@@ -119,7 +122,7 @@ function jin.core.onDraw()
local x, y = jin.mouse.getPosition()
animator:render(x, y, 1, 1, 0)
jin.graphics.print(#sprs, 10, 10)
- --jin.graphics.draw(spr)
+ jin.graphics.draw(spr, 100, 100, 1, 1, 0)
--jin.graphics.useShader(shader_program2)
--jin.graphics.draw(tex, 0, 0,0.2, 0.2)
--jin.graphics.unuseShader()