I'll let the image explain itself
So yeah, scrolling the text isn't a problem, it's the part that says "TEXT JUST GOT TO THIS POINT DO SOMETHING" heh..
Thanks.
Text position detection thing or something
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Text position detection thing or something
There is getWrap, which even accounts for embedded newlines, but it is kind of broken in 0.7.2, and, more importantly, it doesn't help you determine where to wrap.
If you have it line-by-line, you can just do the math with Font:getHeight.
If you have it line-by-line, you can just do the math with Font:getHeight.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Text position detection thing or something
You are not giving much information (nor showing us any code, tsk tsk) so it's a bit difficult to help you.
Assuming that:
If you need more flexibility than that (for example, if the spacing between lines is flexible, or the console area is not always the same) then you will have to calculate something more complex on getMaxLinesShownInConsole().
As bartbes says, there's Font:getHeight, but you are probably using a fixed line height, or you would have discovered it already. So probably you only need something along the lines of "consoleAreaHeight / lineHeight" for a more flexible getMaxLinesShownInConsole().
Regards!
Assuming that:
- You have a table representing the console "buffer" (the lines on the screen) and
- That you now how many lines you can print at maximum
Code: Select all
function getMaxLinesShownInConsole()
return 14 -- as per your example
end
function addLineToConsole(line)
if #currentLines < getMaxLinesShownInConsole() then
table.remove(currentLines, 1) -- remove the "top" line from the console list.
end
table.insert(currentLines, line) -- insert the new line at the bottom.
end
As bartbes says, there's Font:getHeight, but you are probably using a fixed line height, or you would have discovered it already. So probably you only need something along the lines of "consoleAreaHeight / lineHeight" for a more flexible getMaxLinesShownInConsole().
Regards!
When I write def I mean function.
Re: Text position detection thing or something
Heh, I feel like a fool, after getting some needed sleep I came up with a solution rather quickly and easily(it'll get more advanced as i go along though)
Basically it adds a line at the bottom of the console, and moves the rest of the text up, completely shattering all my problems, which is how it should of worked in the first place.
This is why programmers should not code while extremely tired heh.
Code: Select all
function ConsoleLog(text)
table.insert(table_consolebuffer, text);
int_consoletextpos = int_consoletextpos - 15;
end
...
for i, lines in ipairs(table_consolebuffer) do
love.graphics.printf(lines, 20, int_consoletextpos + (i * 15), love.graphics.getWidth() - 20, "left");
end
This is why programmers should not code while extremely tired heh.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 13 guests