lcurses with love

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
alexdantas
Prole
Posts: 3
Joined: Tue Jan 15, 2013 4:30 pm

lcurses with love

Post by alexdantas »

Hello, y'all.

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.

Here's the full source:

Code: Select all

-- 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
User avatar
ejmr
Party member
Posts: 302
Joined: Fri Jun 01, 2012 7:45 am
Location: South Carolina, U.S.A.
Contact:

Re: lcurses with love

Post by ejmr »

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 :: Programming and Game-Dev Blog, GitHub
南無妙法蓮華經
User avatar
alexdantas
Prole
Posts: 3
Joined: Tue Jan 15, 2013 4:30 pm

Re: lcurses with love

Post by alexdantas »

ejmr wrote:Why are you using lcurses instead of LÖVE's standard graphic functions?
I just love textual interface for games. :awesome:
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.
User avatar
slime
Solid Snayke
Posts: 3172
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: lcurses with love

Post by slime »

What's the benefit in this case of using LÖVE instead of a plain old Lua executable?
User avatar
alexdantas
Prole
Posts: 3
Joined: Tue Jan 15, 2013 4:30 pm

Re: lcurses with love

Post by alexdantas »

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?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: lcurses with love

Post by kikito »

alexdantas wrote:
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.
When I write def I mean function.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: lcurses with love

Post by bartbes »

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.)
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests