diff --git a/AKULIVIK.desktop b/AKULIVIK.desktop deleted file mode 100644 index 64d0187..0000000 --- a/AKULIVIK.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Name=ᐊᑯᓕᕕᒃ -Comment=Circumpolar Puzzle Game -MimeType=application/x-love-game; -Exec=ᐊᑯᓕᕕᒃ %f -Type=Application -Categories=Development;Game; -Terminal=false -Icon=ᐊᑯᓕᕕᒃ.png -NoDisplay=true \ No newline at end of file diff --git a/build/Info.plist b/build/Info.plist new file mode 100644 index 0000000..54aba58 --- /dev/null +++ b/build/Info.plist @@ -0,0 +1,107 @@ + + + + + BuildMachineOSBuild + 23C71 + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + love + + CFBundleTypeIconFile + GameIcon + CFBundleTypeName + LÖVE Project + CFBundleTypeRole + Viewer + LSHandlerRank + Owner + LSItemContentTypes + + org.love2d.love-game + + LSTypeIsPackage + 1 + + + CFBundleTypeName + Folder + CFBundleTypeOSTypes + + fold + + CFBundleTypeRole + Viewer + LSHandlerRank + None + + + CFBundleTypeIconFile + Document + CFBundleTypeName + Document + CFBundleTypeOSTypes + + **** + + CFBundleTypeRole + Editor + + + CFBundleExecutable + love + CFBundleIconFile + OS X AppIcon + CFBundleIconName + OS X AppIcon + CFBundleIdentifier + AKULIVIK + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + AKULIVIK + CFBundlePackageType + APPL + CFBundleShortVersionString + 11.5a + CFBundleSignature + LoVe + CFBundleSupportedPlatforms + + MacOSX + + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + + DTPlatformName + macosx + DTPlatformVersion + 14.2 + DTSDKBuild + 23C53 + DTSDKName + macosx14.2 + DTXcode + 1520 + DTXcodeBuild + 15C500b + LSApplicationCategoryType + public.app-category.games + LSMinimumSystemVersion + 10.11 + NSHighResolutionCapable + + NSHumanReadableCopyright + © 2025 wan-may + NSPrincipalClass + NSApplication + NSSupportsAutomaticGraphicsSwitching + + + diff --git a/distribute.sh b/distribute.sh index 2ff428a..3b56c8d 100755 --- a/distribute.sh +++ b/distribute.sh @@ -2,6 +2,7 @@ rm -r build/win/ rm -r build/out/ rm -r build/linux/ rm -r build/macos/ +rm -r build/web/ mkdir -p build/ mkdir -p build/out/ @@ -9,17 +10,22 @@ cd src zip -9 -r "../build/out/AKULIVIK.love" . cd ../build/ -echo WINDOWS +#echo WEB +#npx love.js -m 100000000 -t "ᐊᑯᓕᕕᒃ" -c out/AKULIVIK.love web/ + +echo ===WINDOWS=== +echo mkdir -p win/ cp -r /home/frc/Bureau/frc/dev/love/love-11.5-win64/. win/ -cat licence.txt win/license.txt > win/license.txt +cat licence.txt >> win/license.txt cat "win/love.exe" "out/AKULIVIK.love" > win/ᐊᑯᓕᕕᒃ.exe rm win/love.exe cd win/ zip -9 -r "../out/ᐊᑯᓕᕕᒃ-win.zip" . cd .. -echo LINUX +echo ===LINUX=== +echo mkdir -p linux/ cp -r /home/frc/Bureau/frc/dev/love/linux/ . cat "linux/bin/love" "out/AKULIVIK.love" > "linux/bin/AKULIVIK" @@ -28,8 +34,16 @@ rm linux/bin/love rm linux/love.svg cp AKULIVIK.desktop linux/love.desktop cp favicon.png linux/AKULIVIK.png -cat licence.txt linux/license.txt > linux/license.txt +cat licence.txt >> linux/license.txt cp AppRun linux/AppRun -/home/frc/Bureau/frc/dev/love/appimagetool-x86_64.AppImage linux/ out/AKULIVIK.AppImage +/home/frc/Bureau/frc/dev/love/appimagetool-x86_64.AppImage linux/ out/ᐊᑯᓕᕕᒃ.AppImage -echo MACOS \ No newline at end of file +echo ===MACOS=== +echo +mkdir -p macos/ +cp -r /home/frc/Bureau/frc/dev/love/love.app/. macos/AKULIVIK.app +cp out/AKULIVIK.love macos/AKULIVIK.app/Contents/Resources +cp Info.plist macos/AKULIVIK.app/Contents/Info.plist +cd macos/ +zip -9 -r -y "../out/ᐊᑯᓕᕕᒃ-mac.zip" AKULIVIK.app +cd ../ diff --git a/src/models/bell.lua b/src/models/bell.lua index e69de29..f100478 100644 --- a/src/models/bell.lua +++ b/src/models/bell.lua @@ -0,0 +1,79 @@ +local lg = assert( love.graphics ) +local math = math +local mat = require( "mat4" ) + +local DETAIL = 15 +local CURVE = 45 + +local vertices = {} + +local function radius( y ) + return math.max( 0, + 0.6 * math.pow( (1-y), 1/3 ) + + 0.1 * math.exp( -5*y )) +end + +local loops = {} +for i = 1, CURVE do loops[i] = {} end + +do + local c, s = math.cos( 2*math.pi / DETAIL ), -math.sin( 2*math.pi / DETAIL ) + local n = 1 + local y = 0 + for i, loop in ipairs( loops ) do + local x, z = 1, 0 + y = y + 1 / #loops + local r = radius( y ) + for j = 1, DETAIL + 1 do + --need the extra vertex so the texture wraps correctly + local u = 5 * ( j - 1 ) / DETAIL + local v = 3 * (1.0 - y) - 0.85 + vertices[ n ] = { r * x, y, r * z, u, v } + loop[j] = n + n = n + 1 + x, z = c*x+s*z, c*z-s*x + end + end +end + +local function constructVertexMap() + local map = {} + local k = 1 + for i, loop in ipairs( loops ) do + local nextLoop = loops[i+1] + if not nextLoop then return map end + for j, n in ipairs( loop ) do + map[k] = n + map[k+1] = nextLoop[j] + k=k+2 + end + end +end + + +local bellMesh = lg.newMesh( + {--attributes + {"VertexPosition", "float", 3}, + {"VertexTexCoord", "float", 2}, + }, + vertices, + "strip", + "static" +) + +do + local c, s = math.cos( 2*math.pi / 7 ), -math.sin( 2*math.pi / 7 ) + local instanceMesh = {} + local x, z = 1, 0 + local r = 15 + for i = 1, 7 do + instanceMesh[i] = { i / 2, r * x, r * z, (i-1)/6 } + x, z = c*x+s*z, c*z-s*x + end + bellMesh:attachAttribute( "bellInstance", + lg.newMesh({{"bellInstance","float",4}}, instanceMesh, nil, "static" ), + "perinstance" ) +end + +bellMesh:setVertexMap( constructVertexMap() ) +return bellMesh \ No newline at end of file diff --git a/src/models/plane.lua b/src/models/plane.lua index 7fa746c..f4f5e15 100644 --- a/src/models/plane.lua +++ b/src/models/plane.lua @@ -10,15 +10,15 @@ return lg.newMesh( {-25, 0, -25, 1, 1, 1, 1, 0, 0, }, - {25, 0, -25, 1, + { -25, 0, 25, 1, 1, 1, 1, - 25, 0, }, + 0, 25, }, {25, 0, 25, 1, 1, 1, 1, 25, 25, }, - { -25, 1, 25, 1, + {25, 0, -25, 1, 1, 1, 1, - 0, 25, }, + 25, 0, }, }, "fan", "static" diff --git a/src/models/sky.lua b/src/models/sky.lua index d563ad2..db027a6 100644 --- a/src/models/sky.lua +++ b/src/models/sky.lua @@ -1,17 +1,40 @@ local lg = love.graphics local mesh = lg.newMesh( - {{ "VertexPosition", 3}}, + {{"VertexPosition", "float", 3}}, { - {-1,-1,9-1}, - {-1,-1,1}, - {-1,1,-1}, - {-1,1,1}, - {1,-1,-1}, - {1,-1,1}, - {1,1,-1}, - {1,1,1} + {-1,-1,-1}, --A + {-1,-1, 1}, --B + {-1, 1,-1}, --H + {-1, 1, 1}, --G + { 1,-1,-1}, --D + { 1,-1, 1}, --C + { 1, 1,-1}, --E + { 1, 1, 1}, --F }, - "strip", + "triangles", "static") -mesh:setVertexMap{ 4,3,7,8,5,3,1,4,2,7,6,5,2,1 } -return mesh \ No newline at end of file +mesh:setVertexMap{ + 1, 2, 3, + 2, 3, 4, + 3, 4, 7, + 4, 7, 8, + 7, 5, 8, + 5, 8, 6, + 8, 4, 6, + 4, 6, 2, + 6, 2, 5, + 2, 5, 1, + 5, 1, 7, + 1, 7, 3, +} +local cubemap = love.graphics.newCubeImage( + { + "tex/cubemap_0.png", + "tex/cubemap_1.png", + "tex/cubemap_2.png", + "tex/cubemap_3.png", + "tex/cubemap_4.png", + "tex/cubemap_5.png", + }, + {mipmaps = true} ) +return { mesh = mesh, tex = cubemap } \ No newline at end of file diff --git a/src/player.lua b/src/player.lua index 28e6fef..f778226 100644 --- a/src/player.lua +++ b/src/player.lua @@ -2,6 +2,9 @@ local math = assert( math ) local mat = require( "mat4" ) +local maxPitch = math.pi / 2 +local speed = 2 + local function logistic( x ) return 1.0 / ( 1.0 + math.exp( x ) ) end @@ -32,6 +35,11 @@ function player:updateDesiredDirection( forward, left, right, back ) self.desx, self.desz = x * c + z * s, -x * s + z * c end +--[[function player:getViewDirection() + local cy, sy, cp, sp = math.cos(self.yaw), math.sin(self.yaw), math.cos( self.pitch ), math.sin( self.yaw ) + return cy, sp, 1 +end]] + function player:setFOV( fov ) self.proj = mat.projection( 0.05, 100, math.rad( fov or 90 ) ) end @@ -42,12 +50,13 @@ end function player:turn( dx, dy ) self.yaw = self.yaw + dx * self.turnRate - self.pitch = self.pitch + dy * self.turnRate + self.pitch = math.min( maxPitch, math.max( -maxPitch, + self.pitch + dy * self.turnRate )) end function player:update() - self.vx = self.desx - self.vz = self.desz + self.vx = self.desx * speed + self.vz = self.desz * speed self.x = self.x + self.vx * self.rate self.z = self.z + self.vz * self.rate diff --git a/src/renderer.lua b/src/renderer.lua index cc55e3a..7eda2f5 100644 --- a/src/renderer.lua +++ b/src/renderer.lua @@ -5,6 +5,8 @@ local t = {} local canvas local shaders = { matte = require( "shaders.matte" ), + bell = require( "shaders.bell" ), + sky = require( "shaders.sky" ), } local meshes = {} @@ -21,42 +23,76 @@ function t.start() stencil = false, depth = true, } + + drawLists.sky = require( "models.sky" ) + shaders.sky:send( "cube", drawLists.sky.tex ) end function t.debug() isDebugging = true end +local function sky( view ) + love.graphics.push( "all" ) + love.graphics.setDepthMode( "always", false ) + love.graphics.setMeshCullMode( "none" ) + love.graphics.setShader( shaders.sky ) + local s = shaders.sky + local rot = { view[1], view[2], view[3], {0, 0, 0, 1} } + s:send( "view", "column", rot ) + love.graphics.draw( drawLists.sky.mesh ) + love.graphics.pop() +end + +local function matte( ) + local list = drawLists.matte + local shader = shaders.matte + love.graphics.setShader( shader ) + for mesh in pairs( list ) do + shader:send( "mdl", "column", meshes[mesh]) + love.graphics.draw( mesh ) + end +end + +local function bell( ) + local list = drawLists.bell + local shader = shaders.bell + love.graphics.setShader( shader ) + + for mesh in pairs( list ) do + love.graphics.drawInstanced( mesh, 7 ) + end +end + +--[[function t.setViewDirection( x, y, z ) + shaders.sky:send( "viewVec", {x, y, z} ) +end]] + function t.draw( view, proj ) - + if isDebugging then end - - love.graphics.setScissor( 0, 0, love.graphics.getDimensions() ) - love.graphics.setColor( 1, 1, 1, 1 ) + + love.graphics.push( "all" ) + love.graphics.setScissor( 0, 0, love.graphics.getDimensions() ) love.graphics.setCanvas( canvas ) love.graphics.clear() love.graphics.setDepthMode( "less", true ) love.graphics.replaceTransform( tf ) + love.graphics.setMeshCullMode( "back" ) - for name, shader in pairs( shaders ) do - love.graphics.setShader( shader ) - shader:send( "view", "column", view ) - shader:send( "proj", "column", proj ) - - for mesh in pairs( drawLists[ name ] ) do - local modelMatrix = meshes[ mesh ] - shader:send( "mdl", "column", modelMatrix ) - love.graphics.draw( mesh ) - end + for _, s in pairs( shaders ) do + s:send( "view", "column", view ) + s:send( "proj", "column", proj ) end + sky( view ) + matte() + bell() + love.graphics.pop() - love.graphics.setCanvas() - love.graphics.setDepthMode( "always", false ) - love.graphics.setShader() - love.graphics.origin() + love.graphics.setColor( 1, 1, 1, 1 ) love.graphics.draw( canvas[1] ) if isDebugging then diff --git a/src/scenes/main.lua b/src/scenes/main.lua index 6769c26..f4d8d11 100644 --- a/src/scenes/main.lua +++ b/src/scenes/main.lua @@ -25,20 +25,18 @@ function t.play() spike:setTexture( rockTexture ) renderer.add( spike ) renderer.update( spike, mat.TRS( 0.3, 12, 0.3, 0, 0, 0, 4, 0, 3) ) + + local bellTexture = love.graphics.newImage( "tex/bell-height.png", { mipmaps = true } ) + bellTexture:setWrap( "repeat", "clampzero" ) + local bell = require( "models/bell" ) + bell:setTexture( bellTexture ) + renderer.add( bell, "bell" ) + local scene = require( "scene" ) return scene.load( t ) end function t.draw() - --[[love.graphics.setScissor( ) - love.graphics.push( "transform" ) - love.graphics.scale( love.graphics.getWidth(), -love.graphics.getHeight() ) - love.graphics.translate( 0, -1 ) - love.graphics.translate( player.x, player.y ) - love.graphics.rotate( player.yaw ) - love.graphics.scale( w, h ) - love.graphics.draw( playerMesh ) - love.graphics.pop()]] renderer.draw( player.view, player.proj ) @@ -64,12 +62,15 @@ function t.update( dt ) love.keyboard.isScancodeDown( settings.keyBack.val ) ) + updateTimeRemaining = updateTimeRemaining + dt while updateTimeRemaining >= player.rate do updateTimeRemaining = updateTimeRemaining - player.rate player:update() end + --renderer.setViewDirection( player:getViewDirection() ) + end function t.mousepressed( x, y, button, isTouch, presses ) diff --git a/src/shaders/bell.lua b/src/shaders/bell.lua new file mode 100644 index 0000000..067ba63 --- /dev/null +++ b/src/shaders/bell.lua @@ -0,0 +1,32 @@ +return love.graphics.newShader[[ + #define fog vec4( 0.85, 0.85, 1.0, 1.0 ) + #define fogHigh vec4( 1.0, 1.0, 0.85, 1.0 ) + varying float depth; + varying float height; + varying float instanceColor; +#ifdef VERTEX + //per instance: (uniform) scale and xz position + attribute vec4 bellInstance; + uniform mat4 view; + uniform mat4 proj; + vec4 position( mat4 _, vec4 pos ){ + instanceColor = bellInstance.a; + pos.xyz *= bellInstance.r; + pos.xz += bellInstance.gb; + height = pos.y; + vec4 eye = view * pos; + depth = -eye.z; + return proj*eye; + } +#endif +#ifdef PIXEL + vec4 effect( vec4 color, Image tex, vec2 texuv, vec2 scruv) { + vec4 bellColor = mix( vec4(1.0,1.0,1.0,1.0), vec4(0.2,0.0,0.0,1.0), instanceColor ); + return vec4( + mix( mix( bellColor * color * Texel( tex, texuv ), fog, + clamp( depth / 20.0, 0.0, 1.0)), fogHigh, + clamp( height / 20.0, 0.0, 1.0)).rgb, + 1.0 ); + } +#endif +]] \ No newline at end of file diff --git a/src/shaders/ground.lua b/src/shaders/ground.lua new file mode 100644 index 0000000..e69de29 diff --git a/src/shaders/matte.lua b/src/shaders/matte.lua index d66c74c..58831d6 100644 --- a/src/shaders/matte.lua +++ b/src/shaders/matte.lua @@ -1,6 +1,6 @@ return love.graphics.newShader[[ #define fog vec4( 0.85, 0.85, 1.0, 1.0 ) - #define fogHigh vec4( 1.0, 1.0, 0.85, 1.0 ) + #define fogHigh vec4( 1.0, 1.0, 0.9, 1.0 ) varying float depth; varying float height; #ifdef VERTEX diff --git a/src/shaders/sky.lua b/src/shaders/sky.lua index 43c1593..1eb7de0 100644 --- a/src/shaders/sky.lua +++ b/src/shaders/sky.lua @@ -1,18 +1,21 @@ return love.graphics.newShader[[ + #define fog vec4( 0.85, 0.85, 1.0, 1.0 ) varying vec3 viewDir; #ifdef VERTEX uniform mat4 view; uniform mat4 proj; vec4 position( mat4 _, vec4 pos ){ - vec4 eye = view * pos; - viewDir = eye.xyz; - return proj*eye; + viewDir = pos.xyz; + viewDir.y -= 0.5; + return proj*view*pos; } #endif #ifdef PIXEL uniform samplerCube cube; vec4 effect( vec4 color, Image _, vec2 __, vec2 ___) { - return Texel( cube, viewDir ); + return mix( fog, + Texel( cube, viewDir ), + dot(viewDir, vec3(0.0, 1.0, 0.0 )));; } #endif ]] \ No newline at end of file diff --git a/src/tex/cubemap_0.png b/src/tex/cubemap_0.png index bacff48..b931a1d 100644 Binary files a/src/tex/cubemap_0.png and b/src/tex/cubemap_0.png differ diff --git a/src/tex/cubemap_1.png b/src/tex/cubemap_1.png index fc97ba9..30d4bb1 100644 Binary files a/src/tex/cubemap_1.png and b/src/tex/cubemap_1.png differ diff --git a/src/tex/cubemap_2.png b/src/tex/cubemap_2.png index a9bd6a9..78380c5 100644 Binary files a/src/tex/cubemap_2.png and b/src/tex/cubemap_2.png differ diff --git a/src/tex/cubemap_3.png b/src/tex/cubemap_3.png index ea09b47..911e0de 100644 Binary files a/src/tex/cubemap_3.png and b/src/tex/cubemap_3.png differ diff --git a/src/tex/cubemap_4.png b/src/tex/cubemap_4.png index d09954e..c579eb8 100644 Binary files a/src/tex/cubemap_4.png and b/src/tex/cubemap_4.png differ diff --git a/src/tex/cubemap_5.png b/src/tex/cubemap_5.png index c844da5..ad2c5f2 100644 Binary files a/src/tex/cubemap_5.png and b/src/tex/cubemap_5.png differ