Skip to content

Commit 43d1162

Browse files
committed
V1.0.1 releases (#14)
* Add compatibility for love.js * fix: do not clone sounds in web mode Memory freeing does not work well, and memory is limited Also means that every sound is monophonic * Add lint to web version * Add AndroidMainfest.xml * Update README
1 parent 2edeee5 commit 43d1162

File tree

5 files changed

+83
-5
lines changed

5 files changed

+83
-5
lines changed

AndroidManifest.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<manifest package="sasszem.love"
3+
android:versionCode="101"
4+
android:versionName="v1.0.1"
5+
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
6+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
7+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
8+
<uses-feature android:glEsVersion="0x00020000"/>
9+
<application
10+
android:allowBackup="true"
11+
android:icon="@drawable/love"
12+
android:label="13"
13+
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
14+
>
15+
<activity
16+
android:configChanges="orientation|screenSize"
17+
android:label="13"
18+
android:launchMode="singleTask"
19+
android:name="org.love2d.android.GameActivity"
20+
android:screenOrientation="sensorLandscape"
21+
>
22+
<intent-filter>
23+
<action android:name="android.intent.action.MAIN"/>
24+
<category android:name="android.intent.category.LAUNCHER"/>
25+
<category android:name="tv.ouya.intent.category.GAME"/>
26+
</intent-filter>
27+
</activity>
28+
</application>
29+
</manifest>

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Recreation of a simple game
44

55
## To play
66

7-
Grab a download from the releases page. Needs Löve2D version 11.3 or compatible. Works on every platform supported by Löve2D, but the main target is android.
7+
Grab a download from the releases page. The .love bundles need Löve2D version 11.3 or compatible. Works on every platform supported by Löve2D, but the main target is android - so just grab the apk version if you can.
8+
9+
You can also try out the web version (.html file), altought that's slower and hase a few sound issues.
810

911
## To build
1012

main.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
local Sounds = require("src.Sounds")
2+
local versionCompat = require("src.versionCompat")
23

34
local menu = require("src.menu.menu")
45

56
function love.load()
7+
versionCompat.register()
68
Sounds.playLooping("loop")
79
menu:getWidget("options"):load()
810
end

src/Sounds.lua

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
local Sounds = {
88
soundsEnabled = true,
9-
musicEnabled = true
9+
musicEnabled = true,
10+
11+
clone = true,
12+
-- do we need to clone the sound or use a single source
13+
-- later is required by love.js's limitations
1014
}
1115

1216
local cache = {}
@@ -31,7 +35,11 @@ function Sounds.getSource(name)
3135
cache[name] = love.audio.newSource(filename, sourceMode)
3236
end
3337

34-
return cache[name]:clone()
38+
local s = cache[name]
39+
if Sounds.clone then
40+
s = s:clone()
41+
end
42+
return s
3543
end
3644

3745
local playing = {}
@@ -42,14 +50,18 @@ function Sounds.play(name)
4250
if not Sounds.soundsEnabled then return end
4351

4452
local source = Sounds.getSource(name)
45-
playing[#playing+1] = source
53+
if Sounds.clone then
54+
playing[#playing+1] = source
55+
end
4656
source:play()
4757
end
4858

4959
-- play a sound looping (background music)
5060
function Sounds.playLooping(name)
5161
local source = Sounds.getSource(name)
52-
playing[#playing+1] = source
62+
if Sounds.clone then
63+
playing[#playing+1] = source
64+
end
5365

5466
source:setLooping(true)
5567

@@ -74,10 +86,12 @@ end
7486

7587
-- remove stopped sources from list
7688
function Sounds.cleanup()
89+
if not Sounds.clone then return end
7790
local newPlaying = {}
7891
for _, sound in ipairs(playing) do
7992
if not sound:isPlaying() then
8093
sound:release()
94+
print("Removed a sound")
8195
else
8296
newPlaying[#newPlaying+1] = sound
8397
end

src/versionCompat.lua

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- versionCompat.lua
2+
-- needed because love.js has some odd quirks
3+
4+
local Sounds = require("src.Sounds")
5+
6+
local function fGetInfo(path)
7+
-- I used the original for 2 reasons
8+
-- file exists check
9+
-- file size check
10+
-- (for determining to stream or staticly load sounds)
11+
-- but as love.js does not suppert streaming
12+
-- we return a fake size that forces static
13+
if not love.filesystem.exists(path) then
14+
return false
15+
end
16+
return {
17+
size = 10000
18+
}
19+
end
20+
21+
local function register()
22+
-- register new function missing for some reason
23+
if not love.filesystem.getInfo then
24+
love.filesystem.getInfo = fGetInfo
25+
Sounds.clone = false
26+
end
27+
end
28+
29+
return {
30+
register = register
31+
}

0 commit comments

Comments
 (0)