"Pixel Perfect" Collision Version 2 - Platformer Game

this is really neat! what’s the delta time for, and what are the red lines and balls used for?

Delta time is for getting the same speed even if you change the fps. So the player won’t be slowing down and speeding up depending on fps.
The red lines and red circles are only for visualizing where the collision hitbox of the player are. You can erase them. they’re only for development purpose.

2 Likes

do you still have the wick file @Revon? it would be really helpfull because I need a moving platform that you can stick to and I cant go on that site

1 Like

good work man!

well you can ask @Jovanny

can i get the wick file or the code for lockable doors

1 Like

The person who made this is not active on the wick forums but he’s still active on youtube

ok then i didn’t know

well then ok

nvm he’s active here the last time he logged in was 2 days ago

ok ;) what is his yt

His YT is also called Revon wait let me get the link

ill just search revon

oh i didn’t find him

here is his channel: https://youtu.be/76-t6nD5TiE

did u get the link

ok thanks :)

hey @Revon or @Jovanny can you send some code and .wick files I need the moving platform code for sticking to it and @Jordy needs lockable doors

Moving platform code

It adds the platform’s speed to the player’s position (x coordinate) and its own position (x coordinate).

This is old code! And it is combined with “pixel perfect” functions for its collisions.

this.player_touch = false;
this.direction = 0;
this.SPEED = 5;
project.TILES.push(eval(this._identifier));

this.update_hitbox = function () {
    this.hitbox = project.get_tile_hitbox(eval(this._identifier));
};

this.update_hitbox();

onEvent('update', function () {
    if (this.x > 245 && this.direction === 0) {
        if (this.player_touch) {
            player.x -= this.SPEED * player.delta_time;
        }
        this.x -= this.SPEED * player.delta_time;
        this.update_hitbox();
    }
    else if (this.x < 465 && this.direction === 1) {
        if (this.player_touch) {
            player.x += this.SPEED * player.delta_time;
        }
        this.x += this.SPEED * player.delta_time;
        this.update_hitbox();
    }
    else {
        this.direction = ((this.direction === 0) ? 1 : 0);
    }
});
4 Likes