help with this file

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.
Post Reply
User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

help with this file

Post by luislasonbra » Fri Dec 21, 2012 3:01 am

Hi I have the following file
mi juego 02.love
mi game 2
(9.2 KiB) Downloaded 165 times
that when you jump and hit the tilemap throws the following error:

Code: Select all

Error: main.lua:160: attempt to index field '?' (a nil value)

stack traceback:

	main.lua:160: in function 'IsCollider'

	main.lua:136: in function 'update'

	[string "boot.lua"]:407: in function <[string "boot.lua"]:373>

	[C]: in function 'xpcall'

Warning, quality setting failed!
 (Result: buffers: 6223912, samples: 1786992)

coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: help with this file

Post by coffee » Fri Dec 21, 2012 7:58 am

First an advice. Your cube starts game in plain air and due to machine performance oddities you dt could be affected when you land. That way there lot of chances that your player "tunneling" the ground. Half of times I start your game it fails. You can fix this putting in your love.update something like math.min(dt, 0.06). This will avoid huge dt drops. This wouldn't happen for example if your game started in a menu screen. Anyway use that dt quality check is also useful for any in-game situation that your machine is stressing.

About your problem I think you doing "wall collision" too late. You should limit movement instead in key movement because if you do it later the collider check will try meanwhile to use an offscreen position (and so nil).

User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

Re: help with this file

Post by luislasonbra » Fri Dec 21, 2012 1:08 pm

coffee wrote:First an advice. Your cube starts game in plain air and due to machine performance oddities you dt could be affected when you land. That way there lot of chances that your player "tunneling" the ground. Half of times I start your game it fails. You can fix this putting in your love.update something like math.min(dt, 0.06). This will avoid huge dt drops. This wouldn't happen for example if your game started in a menu screen. Anyway use that dt quality check is also useful for any in-game situation that your machine is stressing.

About your problem I think you doing "wall collision" too late. You should limit movement instead in key movement because if you do it later the collider check will try meanwhile to use an offscreen position (and so nil).

hello failed to solve the problem.

when changing frame = dt * 30 to Math.min (dt, 0.06) does not fall. What could this be?

coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: help with this file

Post by coffee » Fri Dec 21, 2012 1:22 pm

luislasonbra wrote:
coffee wrote:First an advice. Your cube starts game in plain air and due to machine performance oddities you dt could be affected when you land. That way there lot of chances that your player "tunneling" the ground. Half of times I start your game it fails. You can fix this putting in your love.update something like math.min(dt, 0.06). This will avoid huge dt drops. This wouldn't happen for example if your game started in a menu screen. Anyway use that dt quality check is also useful for any in-game situation that your machine is stressing.

About your problem I think you doing "wall collision" too late. You should limit movement instead in key movement because if you do it later the collider check will try meanwhile to use an offscreen position (and so nil).

hello failed to solve the problem.

when changing frame = dt * 30 to Math.min (dt, 0.06) does not fall. What could this be?
That was not really intended to replace your internal/custom frame value but just adjust your dt to a safe value before. You can do something like this:

Code: Select all

   clamped_dt = math.min (dt, 0.06)
   frame = clamped_dt * 30
100% safe landings now! :D

User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

Re: help with this file

Post by luislasonbra » Fri Dec 21, 2012 2:50 pm

coffee wrote:
luislasonbra wrote:
coffee wrote:First an advice. Your cube starts game in plain air and due to machine performance oddities you dt could be affected when you land. That way there lot of chances that your player "tunneling" the ground. Half of times I start your game it fails. You can fix this putting in your love.update something like math.min(dt, 0.06). This will avoid huge dt drops. This wouldn't happen for example if your game started in a menu screen. Anyway use that dt quality check is also useful for any in-game situation that your machine is stressing.

About your problem I think you doing "wall collision" too late. You should limit movement instead in key movement because if you do it later the collider check will try meanwhile to use an offscreen position (and so nil).

hello failed to solve the problem.

when changing frame = dt * 30 to Math.min (dt, 0.06) does not fall. What could this be?
That was not really intended to replace your internal/custom frame value but just adjust your dt to a safe value before. You can do something like this:

Code: Select all

   clamped_dt = math.min (dt, 0.06)
   frame = clamped_dt * 30
100% safe landings now! :D

Thanks but I still have the problem of the clash.

What do you advise me?

coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: help with this file

Post by coffee » Fri Dec 21, 2012 4:28 pm

luislasonbra wrote: Thanks but I still have the problem of the clash.

What do you advise me?
There isn't much to say from my first post than give you some code. Something simple as this work. Code and measures taken from "Collicion con las paredes x, y" section. I didn't check if your "width + width" is really the ground width.

Code: Select all

   if love.keyboard.isDown("right") and player.x < (2 * width) - 32 then
      player.x = player.x + player.speed * dt
   elseif love.keyboard.isDown("left") and player.x > 1 then
      player.x = player.x - player.speed * dt
   end
However you should optimize it later. Call instead a function and so on...

User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

Re: help with this file

Post by luislasonbra » Fri Dec 21, 2012 7:33 pm

coffee wrote:
luislasonbra wrote: Thanks but I still have the problem of the clash.

What do you advise me?
There isn't much to say from my first post than give you some code. Something simple as this work. Code and measures taken from "Collicion con las paredes x, y" section. I didn't check if your "width + width" is really the ground width.

Code: Select all

   if love.keyboard.isDown("right") and player.x < (2 * width) - 32 then
      player.x = player.x + player.speed * dt
   elseif love.keyboard.isDown("left") and player.x > 1 then
      player.x = player.x - player.speed * dt
   end
However you should optimize it later. Call instead a function and so on...


Hello I still have the problem of the collision with the ground here I leave the file with the problem but a picture of what I mean.

mi juego 02.love
mi juego 2
(9.29 KiB) Downloaded 152 times
Image1.png
image
Image1.png (75.96 KiB) Viewed 3209 times

coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: help with this file

Post by coffee » Fri Dec 21, 2012 11:16 pm

Hello I still have the problem of the collision with the ground here I leave the file with the problem but a picture of what I mean.
So, now you added floating platforms and notice that your previous code made for floor don't work now. Well but is no use do another "let's make a platform game" thread. You need first learn the basics of platform collisions. Puzzlem00n very recently helped doing one from scratch. If you read the help in those threads and check wolfninja2 "platformguy" code you get a reliable engine for learn and use. I advise you learn what you can from there and comeback later with specific thing not learned there.

viewtopic.php?f=5&t=11635
and
viewtopic.php?f=4&t=11616

User avatar
luislasonbra
Citizen
Posts: 60
Joined: Sun Jun 24, 2012 1:57 pm

Re: help with this file

Post by luislasonbra » Sat Dec 22, 2012 9:40 am

coffee wrote:
Hello I still have the problem of the collision with the ground here I leave the file with the problem but a picture of what I mean.
So, now you added floating platforms and notice that your previous code made for floor don't work now. Well but is no use do another "let's make a platform game" thread. You need first learn the basics of platform collisions. Puzzlem00n very recently helped doing one from scratch. If you read the help in those threads and check wolfninja2 "platformguy" code you get a reliable engine for learn and use. I advise you learn what you can from there and comeback later with specific thing not learned there.

viewtopic.php?f=5&t=11635
and
viewtopic.php?f=4&t=11616

Thank review what you've told me and proves what it says on the link

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests