Page 28 of 91

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Dec 24, 2014 10:22 am
by Atton
How would one create an element in love with STI and apply gravity and collisions with the world to said object.

Re: "Questions that don't deserve their own thread" thread

Posted: Sun Jan 25, 2015 9:06 pm
by Bindie
This is a great thread for my question.

I tried making a love file, however it seems main.lua has a hard time reaching my assets folder even though I have archieved the insides of the main folder. I'll attach the tried .love and for the sake of an unconditional guide there's a zip.

In this tutorial, is there some way of determining from player.x and player.y what tile one is on? I was thinking of using it for activating doors and such. I guess that will do.

Thanks for any help.

Bindie

Re: "Questions that don't deserve their own thread" thread

Posted: Sun Jan 25, 2015 9:37 pm
by s-ol
Bindie wrote:This is a great thread for my question.

I tried making a love file, however it seems main.lua has a hard time reaching my assets folder even though I have archieved the insides of the main folder. I'll attach the tried .love and for the sake of an unconditional guide there's a zip.

In this tutorial, is there some way of determining from player.x and player.y what tile one is on? I was thinking of using it for activating doors and such. I guess that will do.

Thanks for any help.

Bindie

Code: Select all

x, y = floor( player.x / TILEWIDTH ), floor( player.y / TILEHEIGHT )
ofc account for map offset / camera stuff if present and messing with player/map position

Re: "Questions that don't deserve their own thread" thread

Posted: Sun Jan 25, 2015 9:50 pm
by Bindie

Code: Select all

x =  floor( player.y / TILEHEIGHT ), y = floor( player.x / TILEWIDTH )
If I understood you correctly, is this what you showed?

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Jan 26, 2015 3:23 am
by Jasoco
Bindie wrote:

Code: Select all

x =  floor( player.y / TILEHEIGHT ), y = floor( player.x / TILEWIDTH )
If I understood you correctly, is this what you showed?
No, the other way around. The y and x are flipped in your code. What was posted above is the correct way:

Code: Select all

x, y = floor( player.x / TILEWIDTH ), floor( player.y / TILEHEIGHT )
Alternatively you'd do:

Code: Select all

x = floor( player.x / TILEWIDTH ),
y = floor( player.y / TILEHEIGHT )
When you have two or more variables being defined on one line you separate them by commas, put an equal sign then all the values after that. The code you posted won't work in this case. Basically:

Code: Select all

a, b, c, d, e = valA, valB, valC, valD, valE
Is equivalent to:

Code: Select all

a = valA
b = valB
c = valC
d = valD
e = valE

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Jan 26, 2015 5:46 pm
by Bindie
Cool.

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Jan 26, 2015 7:11 pm
by Bindie
Hey, I have been trying to implement bump.lua, how does world:move work? I think I have implemented the tiles in the world:update and my player image and through using world:move I thought there would be collision, however there could be more of that.

Someone out there with the solution?

Bindie

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Jan 26, 2015 8:58 pm
by luaiscool
How does one make collisions on an image? I know its a noob question. I've been out of the forums for a while and forget if it's even possible. :emo:

Re: "Questions that don't deserve their own thread" thread

Posted: Mon Jan 26, 2015 11:11 pm
by HugoBDesigner
That depends. You mean having an image where the pixels are tiles or detecting an image as a whole and applying collision?

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Jan 27, 2015 2:08 am
by Jasoco
Oh, hey, luaiscool, you can make your signature much shorter if you replace this:

Code: Select all

if signature = true then
    print(signaturetext)
else
    print("Error: Signature Not Found")
end
With this:

Code: Select all

print(signaturetext or "Error: Signature Not Found")
Then you have no need for a signature exists boolean. :monocle: