|
| 1 | +-- settings.lua: Rozbudowane ustawienia |
| 2 | + |
| 3 | +settings = { |
| 4 | + difficulty = 'normal', |
| 5 | + fullscreen = false, |
| 6 | + soundVolume = 1.0, |
| 7 | + musicOn = true, |
| 8 | + resolution = {width = 800, height = 600}, |
| 9 | + keyBindings = {jump = "space", hack = "h", left = "left", right = "right"}, |
| 10 | + graphicsQuality = 'medium' -- low, medium, high |
| 11 | +} |
| 12 | + |
| 13 | +settingsOptions = { |
| 14 | + {name = "Difficulty", values = {"Easy", "Normal", "Hard"}, selected = 2}, |
| 15 | + {name = "Fullscreen", values = {"Off", "On"}, selected = 1}, |
| 16 | + {name = "Sound Volume", values = {"0%", "25%", "50%", "75%", "100%"}, selected = 5}, |
| 17 | + {name = "Music", values = {"Off", "On"}, selected = 2}, |
| 18 | + {name = "Resolution", values = {"800x600", "1024x768", "1280x720", "1920x1080"}, selected = 1}, |
| 19 | + {name = "Graphics Quality", values = {"Low", "Medium", "High"}, selected = 2}, |
| 20 | + {name = "Rebind Jump", values = {"Current: space"}, selected = 1}, |
| 21 | + {name = "Rebind Hack", values = {"Current: h"}, selected = 1}, |
| 22 | + {name = "Rebind Left", values = {"Current: left"}, selected = 1}, |
| 23 | + {name = "Rebind Right", values = {"Current: right"}, selected = 1} |
| 24 | +} |
| 25 | + |
| 26 | +selectedSetting = 1 |
| 27 | + |
| 28 | +function applySettings() |
| 29 | +if not player then return end |
| 30 | + if settings.difficulty == 'easy' then |
| 31 | + player.autoSpeed = 150 |
| 32 | + gravity = 800 |
| 33 | + elseif settings.difficulty == 'normal' then |
| 34 | + player.autoSpeed = 200 |
| 35 | + gravity = 1000 |
| 36 | + elseif settings.difficulty == 'hard' then |
| 37 | + player.autoSpeed = 250 |
| 38 | + gravity = 1200 |
| 39 | + end |
| 40 | + love.window.setFullscreen(settings.fullscreen) |
| 41 | + love.window.setMode(settings.resolution.width, settings.resolution.height) |
| 42 | + updateAudioVolumes() |
| 43 | + end |
| 44 | + |
| 45 | + function drawSettings() |
| 46 | + love.graphics.setColor(1, 1, 1) |
| 47 | + love.graphics.print("Settings", 300, 100, 0, 2, 2) |
| 48 | + for i, setting in ipairs(settingsOptions) do |
| 49 | + if i == selectedSetting then |
| 50 | + love.graphics.setColor(1, 1, 0) |
| 51 | + else |
| 52 | + love.graphics.setColor(1, 1, 1) |
| 53 | + end |
| 54 | + local value = setting.values[setting.selected] |
| 55 | + love.graphics.print(setting.name .. ": " .. value, 250, 200 + (i-1)*40) |
| 56 | + end |
| 57 | + love.graphics.setColor(1, 1, 1) |
| 58 | + love.graphics.print("Left/Right to change, Enter to rebind, Esc to Back", 250, 500) |
| 59 | + end |
| 60 | + |
| 61 | + function updateSettings(isRight) |
| 62 | + local setting = settingsOptions[selectedSetting] |
| 63 | + if isRight then |
| 64 | + setting.selected = setting.selected + 1 |
| 65 | + if setting.selected > #setting.values then setting.selected = 1 end |
| 66 | + else |
| 67 | + setting.selected = setting.selected - 1 |
| 68 | + if setting.selected < 1 then setting.selected = #setting.values end |
| 69 | + end |
| 70 | + if setting.name == "Difficulty" then |
| 71 | + settings.difficulty = string.lower(setting.values[setting.selected]) |
| 72 | + elseif setting.name == "Fullscreen" then |
| 73 | + settings.fullscreen = (setting.selected == 2) |
| 74 | + elseif setting.name == "Sound Volume" then |
| 75 | + settings.soundVolume = (setting.selected - 1) * 0.25 |
| 76 | + elseif setting.name == "Music" then |
| 77 | + settings.musicOn = (setting.selected == 2) |
| 78 | + elseif setting.name == "Resolution" then |
| 79 | + local res = setting.values[setting.selected] |
| 80 | + local w, h = res:match("(%d+)x(%d+)") |
| 81 | + settings.resolution = {width = tonumber(w), height = tonumber(h)} |
| 82 | + elseif setting.name == "Graphics Quality" then |
| 83 | + settings.graphicsQuality = string.lower(setting.values[setting.selected]) |
| 84 | + elseif setting.name:match("^Rebind") then |
| 85 | + local key = setting.name:match("Rebind (%w+)") |
| 86 | + setting.values = {"Current: " .. settings.keyBindings[key:lower()]} |
| 87 | + end |
| 88 | + applySettings() |
| 89 | + end |
0 commit comments