diff options
author | chai <chaifix@163.com> | 2018-12-30 12:40:20 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-12-30 12:40:20 +0800 |
commit | 2a867a0434f9c0f5c23da5249e5149623cac909c (patch) | |
tree | 3999807a4ea481201211e151ca2fb24008020e9d /bin | |
parent | 48173231d90de6bfc193260eab6369f7c88ca742 (diff) |
*添加sample
Diffstat (limited to 'bin')
-rw-r--r-- | bin/game/0.png | bin | 563072 -> 0 bytes | |||
-rw-r--r-- | bin/game/1.png | bin | 73228 -> 0 bytes | |||
-rw-r--r-- | bin/game/SDL.jpg | bin | 6481 -> 0 bytes | |||
-rw-r--r-- | bin/game/anim.png | bin | 44218 -> 0 bytes | |||
-rw-r--r-- | bin/game/anim2.png | bin | 648800 -> 0 bytes | |||
-rw-r--r-- | bin/game/config.lua | 6 | ||||
-rw-r--r-- | bin/game/dust/s_dust_A_0.png | bin | 82 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_1.png | bin | 93 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_10.png | bin | 84 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_2.png | bin | 94 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_3.png | bin | 95 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_4.png | bin | 76 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_5.png | bin | 88 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_6.png | bin | 87 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_7.png | bin | 84 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_8.png | bin | 86 -> 0 bytes | |||
-rw-r--r-- | bin/game/dust/s_dust_A_9.png | bin | 83 -> 0 bytes | |||
-rw-r--r-- | bin/game/forest.ogg | bin | 789109 -> 0 bytes | |||
-rw-r--r-- | bin/game/icon.ico | bin | 85182 -> 0 bytes | |||
-rw-r--r-- | bin/game/main.lua | 367 | ||||
-rw-r--r-- | bin/game/particle.png | bin | 1821 -> 0 bytes | |||
-rw-r--r-- | bin/game/splash.png | bin | 392 -> 0 bytes |
22 files changed, 0 insertions, 373 deletions
diff --git a/bin/game/0.png b/bin/game/0.png Binary files differdeleted file mode 100644 index fa62576..0000000 --- a/bin/game/0.png +++ /dev/null diff --git a/bin/game/1.png b/bin/game/1.png Binary files differdeleted file mode 100644 index 7e3fe49..0000000 --- a/bin/game/1.png +++ /dev/null diff --git a/bin/game/SDL.jpg b/bin/game/SDL.jpg Binary files differdeleted file mode 100644 index dcd530a..0000000 --- a/bin/game/SDL.jpg +++ /dev/null diff --git a/bin/game/anim.png b/bin/game/anim.png Binary files differdeleted file mode 100644 index ef0bc81..0000000 --- a/bin/game/anim.png +++ /dev/null diff --git a/bin/game/anim2.png b/bin/game/anim2.png Binary files differdeleted file mode 100644 index 63c1f63..0000000 --- a/bin/game/anim2.png +++ /dev/null diff --git a/bin/game/config.lua b/bin/game/config.lua deleted file mode 100644 index 095ee28..0000000 --- a/bin/game/config.lua +++ /dev/null @@ -1,6 +0,0 @@ -return -{ - title = "window form", - icon = "splash.png", - vsync = true -}
\ No newline at end of file diff --git a/bin/game/dust/s_dust_A_0.png b/bin/game/dust/s_dust_A_0.png Binary files differdeleted file mode 100644 index 79efc70..0000000 --- a/bin/game/dust/s_dust_A_0.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_1.png b/bin/game/dust/s_dust_A_1.png Binary files differdeleted file mode 100644 index acc2100..0000000 --- a/bin/game/dust/s_dust_A_1.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_10.png b/bin/game/dust/s_dust_A_10.png Binary files differdeleted file mode 100644 index e422644..0000000 --- a/bin/game/dust/s_dust_A_10.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_2.png b/bin/game/dust/s_dust_A_2.png Binary files differdeleted file mode 100644 index 1ef2056..0000000 --- a/bin/game/dust/s_dust_A_2.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_3.png b/bin/game/dust/s_dust_A_3.png Binary files differdeleted file mode 100644 index ca2260a..0000000 --- a/bin/game/dust/s_dust_A_3.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_4.png b/bin/game/dust/s_dust_A_4.png Binary files differdeleted file mode 100644 index 1f67b79..0000000 --- a/bin/game/dust/s_dust_A_4.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_5.png b/bin/game/dust/s_dust_A_5.png Binary files differdeleted file mode 100644 index 3969a04..0000000 --- a/bin/game/dust/s_dust_A_5.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_6.png b/bin/game/dust/s_dust_A_6.png Binary files differdeleted file mode 100644 index d2d6df0..0000000 --- a/bin/game/dust/s_dust_A_6.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_7.png b/bin/game/dust/s_dust_A_7.png Binary files differdeleted file mode 100644 index 02ba310..0000000 --- a/bin/game/dust/s_dust_A_7.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_8.png b/bin/game/dust/s_dust_A_8.png Binary files differdeleted file mode 100644 index 700052c..0000000 --- a/bin/game/dust/s_dust_A_8.png +++ /dev/null diff --git a/bin/game/dust/s_dust_A_9.png b/bin/game/dust/s_dust_A_9.png Binary files differdeleted file mode 100644 index 8de4fcf..0000000 --- a/bin/game/dust/s_dust_A_9.png +++ /dev/null diff --git a/bin/game/forest.ogg b/bin/game/forest.ogg Binary files differdeleted file mode 100644 index d3059e1..0000000 --- a/bin/game/forest.ogg +++ /dev/null diff --git a/bin/game/icon.ico b/bin/game/icon.ico Binary files differdeleted file mode 100644 index 3043332..0000000 --- a/bin/game/icon.ico +++ /dev/null diff --git a/bin/game/main.lua b/bin/game/main.lua deleted file mode 100644 index ff8670d..0000000 --- a/bin/game/main.lua +++ /dev/null @@ -1,367 +0,0 @@ -io.stdout:setvbuf("no") - -music = nil -local tex = nil -local timer = nil -local tb = {x = 1, y = 2} -local spr = nil -local bitmap = nil -local sprs = {} -local animator = nil -local spr = nil -local ps = nil -local mesh = 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, 96, 168) - return jin.graphics.newAnimation(sprs, loop, speed) -end -local particle_sprites = {} -local Pi = 3.1415 -local sinShader = nil -local screen = nil -local pp = nil -local pixel = nil -local rgbsplit = nil -local sobel = nil -local bloom = nil -local noise = nil -local radial = nil -local glow = nil -function jin.core.onLoad() - jin.log.info("=============== Start Game ===============") - - screen = jin.graphics.newCanvas(jin.graphics.getSize()) - -- 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} - -- end) - local tex = jin.graphics.newTexture("splash.png") - mesh = jin.graphics.newMesh() - mesh:setGraphic(tex) - mesh:pushVertex(-20, -20, 0, 0, {255, 0, 0, 255}) - mesh:pushVertex(20, -20, 0.8, 0, {255, 0, 255, 255}) - mesh:pushVertex(20, 20, 0.8, 0.8, {255, 255, 0, 255}) - mesh:pushVertex(-20, 120, 0, 0.8, {255, 255, 255, 255}) - ps = jin.graphics.newParticleSystem() - for i = 0, 10 do - local t = jin.graphics.newTexture("dust/s_dust_A_" .. i .. ".png") - local spr = jin.graphics.newSprite(t, jin.graphics.SpriteOrigin.MIDDLECENTER) - ps:addParticleSprite(spr) - end - ps:setEmitRate(0.02) - ps:setEmitForce(80, 120) - ps:setEmitPosition({0, 0}) - ps:setEmitDirection(-Pi / 10 - Pi / 2, Pi / 10 - Pi / 2) - ps:setParticleLinearAccelaration({0, 10}) - ps:setParticleSpritesMode(jin.graphics.SpriteMode.ANIMATED) - ps:setParticleColor({255, 30, 0, 255}) - ps:addParticleTransparencyPoint(1, 0) - ps:addParticleTransparencyPoint(0, 0.5) - ps:enableParticleBlendAdditive(true) - ps:setParticleLife(0.5, 2) - ps:addParticleScalePoint(3, 0) - ps:addParticleScalePoint(0, 1) - ps:setPosition(250, 200) - local animation = createAnimation("anim2.png", 27, 3, 10, 200, 200, true, 50) - animator = jin.graphics.newAnimator(animation) - spr = animation:getFrame(1) - local tex3 = jin.graphics.newTexture("anim2.png") - tex3 = nil - -- music = jin.audio.newSource("forest.ogg") - -- music:setVolume(0.5) - -- music:setLoop(true) - -- music:play() - jin.graphics.showWindow() - timer = jin.time.newTimer() - 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, animator) - jin.graphics.pushMatrix() - jin.graphics.translate(0, 0) - --jin.graphics.rotate(0.2) - - local fsm = jin.ai.newStateMachine({ - events = { - { name = 'startup', from = 'none', to = 'green' }, - { name = 'panic', from = 'green', to = 'red' }, - { name = 'calm', from = 'red', to = 'green' }, - }}) - jin.log.info(fsm.current) -- "none" - fsm:startup() - jin.log.info(fsm.current) -- "green" - jin.log.info(jin.utils.json.encode({ 1, 2, 3, { x = 10 } })) - jin.log.info(jin.utils.json.decode('[1,2,3,{"x":10}]')) - sinShader = jin.graphics.newShader[[ - #VERTEX_SHADER - Vertex vert(Vertex v) - { - return v; - } - #END_VERTEX_SHADER - #FRAGMENT_SHADER - Color frag(Color col, Texture tex, Vertex v) - { - col.r = sin(jin_Time.x); - col.g = cos(jin_Time.x); - col.b = sin(jin_Time.x); - return col; - } - #END_FRAGMENT_SHADER - ]] - - pp = jin.graphics.newShader[[ - #VERTEX_SHADER - Vertex vert(Vertex v) - { - return v; - } - #END_VERTEX_SHADER - #FRAGMENT_SHADER - Color frag(Color col, Texture tex, Vertex v) - { - v.uv.x += sin(v.uv.y * 4 * 2 * 3.14 + jin_Time.x) / (10 + sin(jin_Time.x) * 10); - return texel(tex, v.uv); - } - #END_FRAGMENT_SHADER - ]] - - pixel = jin.graphics.newShader[[ - #VERTEX_SHADER - Vertex vert(Vertex v) - { - return v; - } - #END_VERTEX_SHADER - #FRAGMENT_SHADER - Color frag(Color col, Texture tex, Vertex v) - { - // config - float pixel_w = 1 + sin(jin_Time.x / 3)*20.0; - float pixel_h = 1 + sin(jin_Time.x / 3)*20.0; - - vec2 uv = v.uv; - vec3 tc = vec3(1.0, 0.0, 0.0); - //if(uv.x < abs(sin(jin_Time.x))) - if(uv.x < 1) - { - float dx = pixel_w*(1.0/jin_RenderTargetSize.x); - float dy = pixel_h*(1.0/jin_RenderTargetSize.y); - vec2 coord = vec2(dx*floor(uv.x/dx),dy*floor(uv.y/dy)); - tc = texel(tex, coord).rgb; - } - else - { - tc = texel(tex, uv).rgb; - } - return vec4(tc, 1.0); - } - #END_FRAGMENT_SHADER - ]] - - rgbsplit = jin.graphics.newShader[[ - #VERTEX_SHADER - Vertex vert(Vertex v) - { - //v.xy += vec2(50 * sin(jin_Time.x * 2), 50 * cos(jin_Time.x * 2)); - return v; - } - #END_VERTEX_SHADER - #FRAGMENT_SHADER - Color frag(Color col, Texture tex, Vertex v) - { - float t = jin_Time.x; - float a = abs(sin(t)) * 3.14; - vec2 p = vec2(0.5*cos(a) + 0.5, 0.5*sin(a) + 0.5); - vec2 dir = v.uv - p; - float d = .7 * length(dir); - normalize(dir); - vec2 value = d * dir * 200 * abs(sin(t * 3)); - - vec4 c1 = texel(tex, v.uv - value / jin_RenderTargetSize.x); - vec4 c2 = texel(tex, v.uv); - vec4 c3 = texel(tex, v.uv + value / jin_RenderTargetSize.y); - return vec4(c1.r, c2.g, c3.b, c1.a + c2.a + c3.b); - } - #END_FRAGMENT_SHADER - ]] - - sobel = jin.graphics.newShader[[ - #VERTEX_SHADER - Vertex vert(Vertex v) - { - return v; - } - #END_VERTEX_SHADER - #FRAGMENT_SHADER - Color frag(Color col, Texture texture, Vertex v) - { - float x = 1.0 / jin_RenderTargetSize.x; - float y = 1.0 / jin_RenderTargetSize.y; - vec4 horizEdge = vec4( 0.0 ); - horizEdge -= texture2D( texture, vec2( v.uv.x - x, v.uv.y - y ) ) * 1.0; - horizEdge -= texture2D( texture, vec2( v.uv.x - x, v.uv.y ) ) * 2.0; - horizEdge -= texture2D( texture, vec2( v.uv.x - x, v.uv.y + y ) ) * 1.0; - horizEdge += texture2D( texture, vec2( v.uv.x + x, v.uv.y - y ) ) * 1.0; - horizEdge += texture2D( texture, vec2( v.uv.x + x, v.uv.y ) ) * 2.0; - horizEdge += texture2D( texture, vec2( v.uv.x + x, v.uv.y + y ) ) * 1.0; - vec4 vertEdge = vec4( 0.0 ); - vertEdge -= texture2D( texture, vec2( v.uv.x - x, v.uv.y - y ) ) * 1.0; - vertEdge -= texture2D( texture, vec2( v.uv.x , v.uv.y - y ) ) * 2.0; - vertEdge -= texture2D( texture, vec2( v.uv.x + x, v.uv.y - y ) ) * 1.0; - vertEdge += texture2D( texture, vec2( v.uv.x - x, v.uv.y + y ) ) * 1.0; - vertEdge += texture2D( texture, vec2( v.uv.x , v.uv.y + y ) ) * 2.0; - vertEdge += texture2D( texture, vec2( v.uv.x + x, v.uv.y + y ) ) * 1.0; - vec3 edge = sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb)); - - return vec4(edge, texture2D(texture, v.uv.xy).a); - } - #END_FRAGMENT_SHADER - ]] - - noise = jin.graphics.newShader[[ - #VERTEX_SHADER - Vertex vert(Vertex v) - { - return v; - } - #END_VERTEX_SHADER - #FRAGMENT_SHADER - - float random(vec2 n, float offset ){ - return .5 - fract(sin(dot(n.xy + vec2(offset, 0.), vec2(12.9898, 78.233)))* 43758.5453); - } - - Color frag(Color col, Texture texture, Vertex v) - { - float amount = 0.1; - float speed = 0.5; - vec4 color = texture2D(texture, v.uv.xy); - color += vec4(vec3(amount * random(v.uv.xy, .00001 * speed * jin_Time.x)), 1.); - return color; - } - #END_FRAGMENT_SHADER - ]] - - radial = jin.graphics.newShader[[ - #VERTEX_SHADER - Vertex vert(Vertex v) - { - return v; - } - #END_VERTEX_SHADER - #FRAGMENT_SHADER - Color frag(Color col, Texture texture, Vertex v) - { - float of = abs(sin(jin_Time.x / 5)); - vec3 p = vec3(v.xy/jin_RenderTargetSize, 0) - of; - vec3 o = texture2D(texture,of+(p.xy*=.992)).rbb; - for (float i=0.;i<100.;i++) - p.z += pow(max(0.,of-length(texture2D(texture,of+(p.xy*=.992)).rg)),2.)*exp(-i*.08); - return vec4(o*o+p.z,1); - } - #END_FRAGMENT_SHADER - ]] - - jin.log.info("test") - - timer:every(1, function() - jin.log.info(jin.time.getFPS() .. " fps") - local stats = jin.graphics.getStats() - jin.log.info("textures " .. stats.textures) - end) - - --local xmlParser = jin.utils.xml.newParser() - local xml = jin.utils.xml.parseXmlText[[ - <test one="two"> - <three four="five" four="six"/> - <three>eight</three> - <nine ten="eleven">twelve</nine> - </test> - ]] - jin.log.info(xml.test["@one"]) -end - -function jin.core.onEvent(e) - if e.type == "Quit" then - jin.core.stop() - end - if e.type == "MouseButtonDown" then - if e.button == "Left" then - ps:setPosition(e.x, e.y) - end - end -end - -local t = 0 -function jin.core.onUpdate(dt) - tb.x = t - t = t + jin.time.getDelta() - animator:update(jin.time.getDelta()) - timer:update(jin.time.getDelta()) - ps:update(dt) - local mx, my = jin.mouse.getPosition() - --ps:setPosition(mx, my) - --ps:setEmitDirection(t - 0.3, t + 0.3) -end - -function jin.core.onDraw() - jin.graphics.setClearColor(0, 0, 0, 0xff) - jin.graphics.clear() - jin.graphics.setColor(255, 255, 255, 255) - - jin.graphics.print("before canvas", 10, 300) - jin.graphics.draw(spr, 100, 300, 1, 1, 0) - - jin.graphics.bindCanvas(screen) - jin.graphics.setClearColor(0, 0, 0, 0) - jin.graphics.clear() - jin.graphics.useShader(jin.graphics.Shaders.Shape) - jin.graphics.setColor(255, 0, 255, 100) - jin.graphics.rect(jin.graphics.RenderMode.FILL, 30, 50, 100, 200) - jin.graphics.setColor(255, 255, 255, 255) - jin.graphics.unuseShader() - --jin.graphics.draw(sprs[2], 150, 150, 1, 1, 0) - local x, y = jin.mouse.getPosition() - animator:render(350, 150, 1, 1, 0) - jin.graphics.useShader(jin.graphics.Shaders.Font) - jin.graphics.print("* Particle system test\n* Animation test.", 10, 10) - jin.graphics.unuseShader() - jin.graphics.draw(spr, 100, 200, 1, 1, 0) - jin.graphics.useShader(jin.graphics.Shaders.Mesh) - jin.graphics.draw(mesh, 200, 100) - jin.graphics.unuseShader(); - ps:render() - jin.graphics.useShader(sinShader) - jin.graphics.rect(jin.graphics.RenderMode.FILL, 300, 300, 100, 50) - jin.graphics.unuseShader() - - jin.graphics.setColor(100, 100, 100, 100) - jin.graphics.useShader(jin.graphics.Shaders.Shape) - jin.graphics.rect(jin.graphics.RenderMode.FILL, 440, 0, 140, 150) - jin.graphics.unuseShader() - jin.graphics.setColor(255, 255, 255, 255) - jin.graphics.useShader(jin.graphics.Shaders.Font) - jin.graphics.print("Stats\n----------------\n" .. jin.graphics.getStatsStr(), 450, 10) - jin.graphics.unuseShader() - jin.graphics.unbindCanvas(screen) - - jin.graphics.useShader(rgbsplit) - local mode = jin.graphics.getBlendMode() - jin.graphics.setBlendMode(jin.graphics.BlendMode.PREMULTIPLIEDALPHA) - jin.graphics.draw(screen, 0, 0) - jin.graphics.setBlendMode(mode) - jin.graphics.unuseShader() - jin.graphics.print("after canvas", 10, 340) -end - -function jin.core.onQuit() - jin.log.info("=============== Quit Game ===============") -end - - diff --git a/bin/game/particle.png b/bin/game/particle.png Binary files differdeleted file mode 100644 index 632fcc1..0000000 --- a/bin/game/particle.png +++ /dev/null diff --git a/bin/game/splash.png b/bin/game/splash.png Binary files differdeleted file mode 100644 index b0c4256..0000000 --- a/bin/game/splash.png +++ /dev/null |