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

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.
Locked
Atton
Prole
Posts: 15
Joined: Mon Aug 26, 2013 1:38 pm

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

Post by Atton »

How would one create an element in love with STI and apply gravity and collisions with the world to said object.
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

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

Post 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
Attachments
Room collision.zip
(17.35 KiB) Downloaded 104 times
Room collision.love
(16.28 KiB) Downloaded 97 times
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

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

Post 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?
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

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

Post 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
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

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

Post by Bindie »

Cool.
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

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

Post 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
Attachments
Room collision - Kopia.zip
(25.39 KiB) Downloaded 91 times
Room collision.love
(25.39 KiB) Downloaded 1340 times
luaiscool
Prole
Posts: 34
Joined: Mon Apr 21, 2014 11:03 pm

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

Post 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:
http://xkcd.com/979/

Code: Select all

if signature = true then
    print(signaturetext)
else
    print("Error: Signature Not Found")
end
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

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

Post by HugoBDesigner »

That depends. You mean having an image where the pixels are tiles or detecting an image as a whole and applying collision?
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

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

Post 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:
Locked

Who is online

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