Again entirely followed on from the Gridlocked Player tutorial, it's easy enough to check where the player is moving, but how do you check if they can do something where they are already standing. How would you make it so that if the player is standing in a certain type of tile and a certain key is pressed that it would display a message?
And also on a similar topic, how could I make it print the message letter by letter?
As always, any help is appreciated.
Testmap issues, and printing letter by letter???
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 17
- Joined: Mon Jul 30, 2012 9:15 pm
Testmap issues, and printing letter by letter???
- Attachments
-
- Example.love
- (1.61 KiB) Downloaded 129 times
Re: Testmap issues, and printing letter by letter???
First question is easy:
The second one is way too general to even start to explaining. You need to be more specific. For this kind of vague question, I can only give vague answer: send to print function only a part of the string via string.sub:
Code: Select all
if love.keyboard.isDown ( "escape" ) and tiles[x][y].type == "ThisTileQuitsTheGameOnEscape" then love.event.push ( "quit" ) end
Code: Select all
love.graphics.print ( textstring:sub ( 1, numberOfCharsToDisplay ), x, y )
-
- Prole
- Posts: 17
- Joined: Mon Jul 30, 2012 9:15 pm
Re: Testmap issues, and printing letter by letter???
Where would I put these in MY code? I understand that I need to tell it which tile to stand on, but in which function?raidho36 wrote:First question is easy:The second one is way too general to even start to explaining. You need to be more specific. For this kind of vague question, I can only give vague answer: send to print function only a part of the string via string.sub:Code: Select all
if love.keyboard.isDown ( "escape" ) and tiles[x][y].type == "ThisTileQuitsTheGameOnEscape" then love.event.push ( "quit" ) end
Code: Select all
love.graphics.print ( textstring:sub ( 1, numberOfCharsToDisplay ), x, y )
Also, sorry for the vagueness of the second question, when I say print a message letter by letter I mean like in one of those old spy movies, where the date and location appear as if they were being typed.
Thanks for the help anyway.
Re: Testmap issues, and printing letter by letter???
Look, I don't want to be rude (although I will), but how do you expect me to know where do you put it in your code? Just put it wherever it's appropriate. Draw function? Keypress function? Update function? I can't tell. Depends on your code and however you see it.Where would I put these in MY code?
If you merely want that, then what I suggested was pretty much spot-on, minus you'd better store mid-animation text somewhere rather than use string:sub every time you render your text, because in Lua strings are immutable and blah blah yadda yadda you better store every single result of stirng operation to a variable if you're gonna reuse it.in one of those old spy movies, where the date and location appear as if they were being typed
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Testmap issues, and printing letter by letter???
The first goes somewhere in love.update or a function called by love.update. The second goes somewhere in love.draw or in a function called by love.draw.FatalMarshmallow wrote:Where would I put these in MY code?
UseFatalMarshmallow wrote:I understand that I need to tell it which tile to stand on, but in which function?
Code: Select all
map[player.grid_y / 16][player.grid_x / 16]
After a time, increase numberOfCharsToDisplay. I'll show you a minimal example:FatalMarshmallow wrote:Also, sorry for the vagueness of the second question, when I say print a message letter by letter I mean like in one of those old spy movies, where the date and location appear as if they were being typed.
Thanks for the help anyway.
Code: Select all
function love.load()
textToDisplay = "VICTORY" -- or, you know, whatever
numberOfCharsToDisplay = 0
timePassed = 0
timeForEachChar = 0.2 --seconds
end
function love.update(dt)
timePassed = timePassed + dt
if timePassed >= timeForEachChar then
timePassed = timePassed - timeForEachChar
numberOfCharsToDisplay = numberOfCharsToDisplay + 1
end
end
function love.draw()
love.graphics.print(textToDisplay:sub ( 1, numberOfCharsToDisplay ), 10, 10)
end
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests