diff --git a/JetBrainsMono-Regular.ttf b/JetBrainsMono-Regular.ttf new file mode 100644 index 0000000..7db854f Binary files /dev/null and b/JetBrainsMono-Regular.ttf differ diff --git a/conf.lua b/conf.lua index a8060fe..312cc71 100644 --- a/conf.lua +++ b/conf.lua @@ -1,7 +1,7 @@ function love.conf(t) package.path = package.path..";./?.lua" - GAME_WIDTH = 512 - GAME_HEIGHT = 288 + GAME_WIDTH = 416 + GAME_HEIGHT = 240 scale = 2 --scale multiplier t.version = "11.3" t.window.width = GAME_WIDTH * scale diff --git a/draw.lua b/draw.lua index 88f46b3..21b9ad3 100644 --- a/draw.lua +++ b/draw.lua @@ -1,7 +1,25 @@ function love.draw() - if tiles [selected_tile].texture then - love.graphics.draw(tiles[selected_tile].texture, 0, 0) - end + love.graphics.push() + love.graphics.scale(scale) + x = 0 + y = 0 for i = 1, SCREEN_LEN, 1 do + current_tile = selected_screen:sub(i, i) + tile_id = 0 + for i, v in ipairs(tiles_char) do + if v == current_tile then tile_id = i break end + end + if tiles[tile_id] then + love.graphics.draw(tiles[tile_id], x, y) + end + x = x + 16 + if x > 16 * 25 then + x = 0 + y = y + 16 + end end + --gui + love.graphics.pop() + love.graphics.setColor(0.8, 0.8, 0.8, 1) + love.graphics.print(tiles_char[selected_tile], 2, 0) end diff --git a/keyboard.lua b/keyboard.lua index baf9f4c..00495a8 100644 --- a/keyboard.lua +++ b/keyboard.lua @@ -2,10 +2,6 @@ function update_keyboard() --get keys inputs --debug key if love.keyboard.isDown("d") then debug.debug() end - --mute - local buffer = k_m - k_m = love.keyboard.isDown("m") - if k_m and not buffer then sfx = not sfx end --swap selected object local buffer = k_tab k_tab = love.keyboard.isScancodeDown("tab") diff --git a/load.lua b/load.lua index 7884f99..7f5986d 100644 --- a/load.lua +++ b/load.lua @@ -4,3 +4,8 @@ love.graphics.setDefaultFilter("nearest", "nearest") selected_screen = "000000000000000000000000000000000000000000000000000000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................000000000000000000000000000000000000000000000000000000" SCREEN_LEN = 390 path = "../platformer/" + +--font +love.graphics.setNewFont("JetBrainsMono-Regular.ttf", 24) + +mouse_mode = 0 diff --git a/mouse.lua b/mouse.lua index f925867..24a5805 100644 --- a/mouse.lua +++ b/mouse.lua @@ -2,30 +2,32 @@ function update_mouse() mouse_x, mouse_y = love.mouse.getX(), love.mouse.getY() --mouse position mouse_x = math.floor(mouse_x / scale) mouse_y = math.floor(mouse_y / scale) - clip_mouse_x = mouse_x - mouse_x % grid_spacing - clip_mouse_y = mouse_y - mouse_y % grid_spacing + clip_mouse_x = mouse_x - mouse_x % 16 + clip_mouse_y = mouse_y - mouse_y % 16 --edition mode mouse_mode = 0 - if (clip_mouse_x >= bounds.min_x) and (clip_mouse_x <= bounds.max_x) and - (clip_mouse_y >= bounds.min_y) and (clip_mouse_y <= bounds.max_y) then - if love.mouse.isDown(1) then - mouse_mode = 1 - elseif love.mouse.isDown(2) then - mouse_mode = -1 - end + if love.mouse.isDown(1) then + mouse_mode = 1 + elseif love.mouse.isDown(2) then + mouse_mode = -1 end if mouse_mode == 0 then buffer_x, buffer_y = 0, 0 end --add to layer if if mouse_mode == 1 and (clip_mouse_x ~= buffer_x or clip_mouse_y ~= buffer_y) then - add_to_layer(layer_selected) - if sfx then s_place:stop() s_place:play() end + set_tile(tiles_char[selected_tile]) buffer_x = clip_mouse_x buffer_y = clip_mouse_y end --delete of layer if if mouse_mode == -1 and (clip_mouse_x ~= buffer_x or clip_mouse_y ~= buffer_y) then - rem_of_layer(layer_selected) + set_tile('.') buffer_x = clip_mouse_x buffer_y = clip_mouse_y end end + +function set_tile(char) + pos = clip_mouse_x / 16 + 1 + clip_mouse_y / 16 * 26 + selected_screen = selected_screen:sub(1, pos - 1)..char.. + selected_screen:sub(pos + 1, -1) +end diff --git a/tiles.lua b/tiles.lua index a690e17..6a14606 100644 --- a/tiles.lua +++ b/tiles.lua @@ -1,9 +1,10 @@ local img_path = "img/" tiles = { - {id = '0', texture = love.graphics.newImage(img_path.."ground.png")}, - {id = '^', texture = love.graphics.newImage(img_path.."elevator1.png")}, - {id = '.', texture = nil}, + love.graphics.newImage(img_path.."ground.png"), + love.graphics.newImage(img_path.."elevator1.png"), + false, } +tiles_char = { '0', '^', '.' } selected_tile = 1 diff --git a/update.lua b/update.lua index ae4bead..b076b70 100644 --- a/update.lua +++ b/update.lua @@ -1,3 +1,4 @@ function love.update(dt) update_keyboard() + update_mouse() end