Page 1 of 1

[Unsolved]Hardon Collider Problem

Posted: Thu Mar 14, 2013 9:42 pm
by SerTrollface
I'm using Hardon Collider to make a platform game, and i have a problem. The "ground" (a green rectangle until i solve this problem) isn't solid, i made a -theorically- working on_collide function, but the player (that for some other reason doesn't use the image it should use) passes right trough it. Also, the camera doesn't follow the player.
Before asking why the rectangle is 6000px wide,it is because i wanted to test also the camera.
In the .rar (not .love, for editing it's better the zipped one I think) you'll find some main-.lua, mainOld.lua etc. They're tutorial/old files i use only to copy-paste or to look the old scripts.
EDIT : Partially solved the animation problem, I changed to anim8. But still, even if the player X pos and Y pos update correctly on the debug informations, the image and the player state(variable to decide which image has to be used) don't. The image falls but it doesn't move horizontally, and the player state is still at "falling" .
Please help.

Re: [Hardon collider]Hardon Collider Problem

Posted: Sat Mar 16, 2013 5:08 pm
by SerTrollface
Sorry for the double post, but I really need help.

Re: [Unsolved]Hardon Collider Problem

Posted: Mon Mar 18, 2013 4:22 am
by Hexenhammer
But still, even if the player X pos and Y pos update correctly on the debug informations, the image and the player state(variable to decide which image has to be used) don't.

Code: Select all

    -- update the player's state
    player.state = Player.getState()

Code: Select all

-- returns shape's state as a string
function Player.getState()
   -- if player.index == not 'player' then return end
    local myState = ""
    if player.ySpeed == 0 then
        if player.xSpeed > 0 then
            myState = "moveRight"
        elseif player.xSpeed < 0 then
            myState = "moveLeft"
        else
            myState = "stand"
        end
    end
    if player.ySpeed < 0 then
        myState = "jump"
    elseif player.ySpeed > 0 then
        myState = "fall"
    end
    return myState
end
Looks like the player's state won't switch from "fall" to "stand" unless player.ySpeed is exactly 0. I don't have time trying to understand your code but I put "error(player.ySpeed)" at the top of the getState() function and the output was a floating point value...

Comparing floating point values for equality is tricky to say at least. My guess is that when your player stops on the ground his ySpeed is not actually exactly 0 but some floating point value close to zero.