diff options
author | chai <chaifix@163.com> | 2018-09-11 22:38:29 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-09-11 22:38:29 +0800 |
commit | 99d246aa9f42e7c04cc6bab57a5ae195bfc904df (patch) | |
tree | a2e611264bb1b00c85f93d64b47991a879c3a2fa | |
parent | 97aace7c54fdb968f66d3998f796e87a42e9719e (diff) |
*update
-rw-r--r-- | class/class.lua | 3 | ||||
-rw-r--r-- | ini/ini.lua | 4 | ||||
-rw-r--r-- | parallax/main.lua | 16 | ||||
-rw-r--r-- | particles/init.lua | 2 | ||||
-rw-r--r-- | sprite/sprite.lua | 15 |
5 files changed, 33 insertions, 7 deletions
diff --git a/class/class.lua b/class/class.lua index 6cff4d7..bf3e616 100644 --- a/class/class.lua +++ b/class/class.lua @@ -1,9 +1,8 @@ local class = {} - class.new = function(self, ...) local c = {} + self.__index = self setmetatable(c, self) - self.__index = self if self.init then self.init(...) end diff --git a/ini/ini.lua b/ini/ini.lua index e69de29..1bd909e 100644 --- a/ini/ini.lua +++ b/ini/ini.lua @@ -0,0 +1,4 @@ +local ini = {} + + +return ini
\ No newline at end of file diff --git a/parallax/main.lua b/parallax/main.lua index 3028d36..6a799f4 100644 --- a/parallax/main.lua +++ b/parallax/main.lua @@ -2,21 +2,22 @@ local boundary = { x = 200, y = 100, w = 100, - h = 80, + h = 20, } local bg = { x = 200, y = 100, w = 150, - h = 80 + h = 20 } local p = { x = boundary.x + 10, y = boundary.y + 10, speed = 1, } - +local sw, sh = jin.graphics.getSize() +local canvas = jin.graphics.newCanvas(sw, sh) function jin.core.onLoad() end @@ -51,8 +52,8 @@ local function updateBg() if jin.keyboard.isPressed("Down") then p.y = p.y + p.speed end - p.x = clamp(p.x, boundary.x, boundary.x + boundary.w) - p.y = clamp(p.y, boundary.y, boundary.y + boundary.h) + p.x = clamp(p.x, boundary.x + 20, boundary.x + boundary.w - 20) + p.y = clamp(p.y, boundary.y + 10, boundary.y + boundary.h - 10) local x0 = boundary.x local x1 = boundary.x + boundary.w @@ -69,6 +70,8 @@ function jin.core.onUpdate(dt) end function jin.core.onDraw() + jin.graphics.bindCanvas(canvas) + jin.graphics.clear() jin.graphics.setColor(100, 100, 100, 255) jin.graphics.rect("fill", bg.x, bg.y, bg.w, bg.h) jin.graphics.setColor(255,255,255,255) @@ -77,4 +80,7 @@ function jin.core.onDraw() jin.graphics.rect("fill", p.x - 2, p.y- 2, 4, 4) jin.graphics.setColor(0, 255, 0) jin.graphics.rect("line", p.x - 20, p.y - 10, 40, 20) + jin.graphics.unbindCanvas() + jin.graphics.setColor(255, 255, 255) + jin.graphics.draw(canvas, 0, 0) end diff --git a/particles/init.lua b/particles/init.lua new file mode 100644 index 0000000..495653c --- /dev/null +++ b/particles/init.lua @@ -0,0 +1,2 @@ + +-- 丰富的粒子系统 diff --git a/sprite/sprite.lua b/sprite/sprite.lua new file mode 100644 index 0000000..79a7c06 --- /dev/null +++ b/sprite/sprite.lua @@ -0,0 +1,15 @@ +local Sprite = { + x = 0, + y = 0, +} +Sprite.__index = Sprite + +function Sprite:update(dt) + +end + +function Sprite.draw(sp) + +end + +return Sprite
\ No newline at end of file |