Page 1 of 3

text based game

Posted: Sun Jul 18, 2010 5:11 am
by supertails
I know love is more designed to make 2d games but can love be used to make text based games?

Re: text based game

Posted: Sun Jul 18, 2010 5:27 am
by Kingdaro
Here's how I would do it:

Code: Select all

text = ""

function keypressed(key)
text = text ..key
end

function love.draw()
love.graphics.drawText(text,400,300) --I KNOW ITS WRONG, JUST AN EXAMPLE.
end
And you know, it checks to see if text is a specific value...and then sets it back to "". So as a short answer: Yes, you can.

Re: text based game

Posted: Sun Jul 18, 2010 5:42 am
by supertails
text = ""

function keypressed(key)
text = text ..key
end

function love.draw()
love.graphics.drawText(text,400,300) --I KNOW ITS WRONG, JUST AN EXAMPLE.
end

Do I write it word for word or like this?

text = "You're in a castle"

function keypressed(1)
text = "You're in the throne room"
end

function love.draw()
love.graphics.drawText(text,400,300)
end

Re: text based game

Posted: Sun Jul 18, 2010 5:44 am
by Kingdaro
Unless you want a retarded sentence generator, yes.

And I mean like for the text box, that was my example, and when they pressed the "enter" key, it would send and check. If not a valid answer, say so, and if so, would direct to the right place.

Re: text based game

Posted: Sun Jul 18, 2010 6:00 am
by supertails
I inserted the text and made the .love file but when ever I open it, it just shows the love tank.

Re: text based game

Posted: Sun Jul 18, 2010 6:04 am
by Kingdaro
supertails wrote:I inserted the text and made the .love file but when ever I open it, it just shows the love tank.
That's how you shouldn't test an incomplete game. Put your script[s] in one folder, than drag that folder onto the LOVE.exe icon or the desktop shortcut.

Re: text based game

Posted: Sun Jul 18, 2010 6:23 am
by supertails
I'm doing that on linux.

Re: text based game

Posted: Sun Jul 18, 2010 6:27 am
by Kingdaro
supertails wrote:I'm doing that on linux.
Oh. Dang. Remember, my drawText thing was incorrect, and just an example. Look up on the wiki for the Hello World example to get an idea on how to ACTUALLY draw text.

As for the tank, did you name your .lua file "main.lua"?

Re: text based game

Posted: Sun Jul 18, 2010 7:51 am
by Robin
Text based games in LÖVE are very graphical, because you still have to worry about vertical and horizontal placement.

My advice is to get to know LÖVE and Lua better before attempting such a text based game.

Re: text based game

Posted: Sun Jul 18, 2010 8:07 am
by nevon
It seems kind of counter-intuitive to write a text-based game in Löve, when you could just write it in pure Lua and run it in a terminal. Though I guess you could show some pretty pictures to go along with it if you were using Löve.