How to put text on a certain path/route?
Posted: Wed Jul 24, 2013 7:19 am
First of all, greetings to all who read.
Secondly, I hope I'm posting in the right forum. It wasn't totally clear in which of the forum sections to post my question.
I'm only just starting to learn Love2D. It's absolutely amazing how quick you can get started with a game project using Löve.
I managed to create a program that just makes some text move. However, I would like it to move on a certain path.
I guess I could do it by incorporating some more "if-then" statements inside love.update, but what I would really like to be able to do, is have a table holding all the coordinates and then the game uses that table to move the text around.
I don't know how to go about this though, so if anyone could give me some pointers/tips, I'd greatly appreciate it.
Here is my code so far (if my code can be better somehow, I'd like to know too):
My first idea was to do something like this:
The idea being:
1. if specialEffectText.path.x > 200 then stop horizontal movement and start vertical movement
2. if specialEffectText.path.y > 100 then stop vertical movement and start horizontal movement
3. if specialEffectText.path.x > 400 then stop horizontal movement and start vertical movement
4. if specialEffectText.path.y > 200 then stop vertical movement and start horizontal movement
5. if specialEffectText.path.x > 600 then stop ALL movement
Then I would somehow need to check when the x and y values have been reached.
Secondly, I hope I'm posting in the right forum. It wasn't totally clear in which of the forum sections to post my question.
I'm only just starting to learn Love2D. It's absolutely amazing how quick you can get started with a game project using Löve.
I managed to create a program that just makes some text move. However, I would like it to move on a certain path.
I guess I could do it by incorporating some more "if-then" statements inside love.update, but what I would really like to be able to do, is have a table holding all the coordinates and then the game uses that table to move the text around.
I don't know how to go about this though, so if anyone could give me some pointers/tips, I'd greatly appreciate it.
Here is my code so far (if my code can be better somehow, I'd like to know too):
Code: Select all
function love.load()
love.graphics.setBackgroundColor(0,0,0, 255)
love.graphics.setColor(255,255,255, 255)
specialEffectText = {}
specialEffectText.textValue="Hello there!"
specialEffectText.x = 0
specialEffectText.y = 0
specialEffectText.speed = 80
end
function love.update(dt)
if specialEffectText.x < 600 then
specialEffectText.x = specialEffectText.x + specialEffectText.speed*dt
elseif specialEffectText.x > 600 then
specialEffectText.x = 600
end
end
function love.draw()
love.graphics.print(specialEffectText.textValue, specialEffectText.x, specialEffectText.y)
-- love.graphics.print(specialEffectText.x, 200, 400)
end
Code: Select all
specialEffectText.path = {}
specialEffectText.path.x = {200, 400, 600}
specialEffectText.path.y = {100, 200, 300}
1. if specialEffectText.path.x > 200 then stop horizontal movement and start vertical movement
2. if specialEffectText.path.y > 100 then stop vertical movement and start horizontal movement
3. if specialEffectText.path.x > 400 then stop horizontal movement and start vertical movement
4. if specialEffectText.path.y > 200 then stop vertical movement and start horizontal movement
5. if specialEffectText.path.x > 600 then stop ALL movement
Then I would somehow need to check when the x and y values have been reached.