diff options
Diffstat (limited to 'bin/game/main.lua')
-rw-r--r-- | bin/game/main.lua | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/bin/game/main.lua b/bin/game/main.lua index 98f7bc7..b233272 100644 --- a/bin/game/main.lua +++ b/bin/game/main.lua @@ -56,7 +56,7 @@ 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) + local sprs = ssheet:newSprites(count, r, c, w, h, 96, 168) return jin.graphics.newAnimation(sprs, loop, speed) end @@ -66,15 +66,11 @@ function jin.core.onLoad() end) shader_program = jin.graphics.newShader(shader) shader_program2 = jin.graphics.newShader(shader2) - --tex = jin.graphics.newTexture("1.png") - 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, 50) animator = jin.graphics.newAnimator(animation) - local ssheet = jin.graphics.newSpriteSheet(tex) spr = animation:getFrame(1) - tex = nil + local tex3 = jin.graphics.newTexture("anim2.png") + tex3 = nil -- music = jin.audio.newSource("forest.ogg") -- music:setVolume(0.5) -- music:setLoop(true) @@ -82,22 +78,18 @@ function jin.core.onLoad() jin.graphics.clear() jin.graphics.showWindow() timer = jin.time.newTimer() - local h = timer:every(0.5, function(sp) - - end, spr) timer:every(3, function(p) --timer:cancel(h) if animator:getSpeed() == 50 then animator:setSpeed(100) elseif animator:getSpeed() == 100 then animator:setSpeed(50) - end + end end, animator) jin.graphics.pushMatrix() jin.graphics.translate(0, 0) --jin.graphics.rotate(0.2) end -local stop = false function jin.core.onEvent(e) if e.type == "Quit" then @@ -105,14 +97,14 @@ function jin.core.onEvent(e) end end -function jin.core.onUpdate() +function jin.core.onUpdate() tb.x = t t = t + jin.time.getDelta() animator:update(jin.time.getDelta()) + timer:update(jin.time.getDelta()) end function jin.core.onDraw() - timer:update(jin.time.getDelta()) jin.graphics.useShader(shader_program) jin.graphics.setColor(255, 0, 255, 255) jin.graphics.rect(jin.graphics.RenderMode.FILL, 30, 50, 100, 200) @@ -122,7 +114,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, 100, 100, 1, 1, 0) + jin.graphics.draw(spr, 100, 200, 1, 1, 0) --jin.graphics.useShader(shader_program2) --jin.graphics.draw(tex, 0, 0,0.2, 0.2) --jin.graphics.unuseShader() |