I've been trying to use lcurse's graphical interface with love's input and audio modules on a simple game.
To do this, I:
Disabled love's image and graphic's mode through conf.lua
Stopped calling any visual-related functions (love.draw()/love.focus()/etc)
Initialized curses
And after zipping everything up correctly and calling love it simply quits right away.
I've installed lcurses through luarocks and properly require'd it on the code.
-- oh yeah
require 'curses'
function love.load()
curses_init()
player_x, player_y = 0, 0
end
function curses_init()
screen = nil
curses.initscr() -- start curses
curses.cbreak() -- will wait for input
curses.echo(0) -- won't show input characters
curses.noln(0) -- use line-feed capability ('man 3 nl')
screen = curses.stdscr()
screen:clear()
screen:mvaddstr(3, 3, "Curses Initialized!")
screen:refresh()
end
-- treats input
function love.keypressed(key, unicode)
if key == 'd' or key == 'right' then
player_x = player_x + 1
elseif key == 's' or key == 'down' then
player_y = player_y + 1
elseif key == 'w' or key == 'up' then
player_y = player_y - 1
elseif key == 'a' or key == 'left' then
player_x = player_x - 1
elseif key == 'q' then
quit_game()
end
end
function love.update()
screen:mvaddch(player_y, player_x, '#')
end
-- This works around an issue on quitting between love versions.
function quit_game()
local f = love.event.quit or love.event.push
f('q')
end
Well I was going to test out your code to see if I duplicate the error, but lcurses fails to compile and install properly for some reason. Anyways...
Why are you using lcurses instead of LÖVE's standard graphic functions? I am not asking that in a snarky, condescending way. I am just genuinely curious what you are trying to do (because this sounds like something that may be useful for a roguelike, for instance).
ejmr wrote:Why are you using lcurses instead of LÖVE's standard graphic functions?
I just love textual interface for games.
Playing games on a terminal feels cute and geeky. When learning C, I chose ncurses because of the awesome games made around there. There's a lot of examples from several genres.
I'm excited with LÖVE and it's possibilities, so I'll try to implement simple textual games with it - pong, breakout, pacman... For now, it'd be great to enjoy all the interesting stuff LÖVE has to offer while keeping curses' interface control.
For instance, making a simple snake game in C took me a lot, while it'll be a lot easier with Lua.
slime wrote:What's the benefit in this case of using LÖVE instead of a plain old Lua executable?
All the modules provided by LÖVE. I'd have to implement input/audio/events/thread/etc myself.
Also, this is only a test, before I start using graphics/image.
So apparently there's zero compatibility between LÖVE and lcurses?
slime wrote:What's the benefit in this case of using LÖVE instead of a plain old Lua executable?
All the modules provided by LÖVE. I'd have to implement input/audio/events/thread/etc myself.
Also, this is only a test, before I start using graphics/image.
So apparently there's zero compatibility between LÖVE and lcurses?
It's not zero compatibility, but it's much more painful than just using the provided functions.
(I think that) You can't use luarocks, at least not directly. LÖVE expects the .dll / .so / whatever mac uses/, as well as any additional lua files that the library includes, to be on the same folder than the main.lua file, and on the same directory as the .love file. And yes, this means that if you want to make a multi-platform game, you must provide all the necessary files.
And kikito was wrong . There's very few cases where you have to use love's own binary loader (which either loads from the generic save dir, or from your game's if you're in release mode with a merged executable), and you can do with lua's standard one. Make sure you built lcurses for lua 5.1, though, not 5.2.
However, I have to disappoint you, basically all input modules require there to be a window, so no keyboard, mouse or joysticks will be usable. (Maybe joysticks will, I vaguely remember them being different.)