text based game

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.
supertails
Prole
Posts: 5
Joined: Sun Jul 18, 2010 5:08 am

text based game

Post by supertails »

I know love is more designed to make 2d games but can love be used to make text based games?
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: text based game

Post 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.
supertails
Prole
Posts: 5
Joined: Sun Jul 18, 2010 5:08 am

Re: text based game

Post 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
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: text based game

Post 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.
supertails
Prole
Posts: 5
Joined: Sun Jul 18, 2010 5:08 am

Re: text based game

Post by supertails »

I inserted the text and made the .love file but when ever I open it, it just shows the love tank.
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: text based game

Post 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.
supertails
Prole
Posts: 5
Joined: Sun Jul 18, 2010 5:08 am

Re: text based game

Post by supertails »

I'm doing that on linux.
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: text based game

Post 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"?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: text based game

Post 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.
Help us help you: attach a .love.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: text based game

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

Who is online

Users browsing this forum: Google [Bot] and 18 guests