I Wanna Community
Fangames => Game Design => Programming Questions => Topic started by: 128-Up on January 24, 2015, 07:12:29 PM
-
I'm using the Lemon Engine on 8.0 and noticed that if the Kid stands on the moving platform going upwards, when the platform hits a ceiling the Kid is pushed into the ceiling. Some games make it so that the Kid just drops through the platform if that happens. What do I do to make that happen?
-
Within the step code for the platform, I recommend putting something like this where the code sets the player's x and y relative to the platform.
RATHER THAN SAYING SOMETHING LIKE:
player.x += hspeed;
player.y += vspeed;
DO THIS INSTEAD:
globalvar space_available, hsp, vsp;
space_available = true;
hsp = hspeed;
vsp = vspeed;
with(player) {
if not place_free(x + hsp, y + vsp) {
space_available = false;
}
}
//Finally, set the player relative to this platform's movement if it is deemed that space is available
if space_available {
player.x += hspeed;
player.y += vspeed;
}
NOTE: This will not work if the platform is moving diagonally. In such a case, you will need to check the horizontal and vertical available spaces separately.
-
Hope you don't mind me asking a separate question RE: Vertical Platforms. This is the Yuutuu engine. Collision with niseblocks works from the bottom, left, and right of the platforms just fine. But for some reason collision with the top of the platforms doesn't work as intended and the moving platforms pass right through without changing direction. This is all standard Yuutuu code for moving platforms I haven't added anything new so it's weird that this specific instance doesn't work for moving platforms.
-
Looking at YoSniper's code... it looks like the Lemon code already has that? Maybe I'm missing something. ._.
if (!place_free(x+hspeed,y)) {
hspeed=-hspeed;
}
if (!place_free(x,y+vspeed+yspeed)) {
if (vspeed!=0) {
yspeed=-vspeed;
vspeed=0;
}
else {
vspeed=-yspeed;
yspeed=0;
}
}
y+=yspeed;
if (place_meeting(x,y-2,player)) {
player.y+=vspeed+yspeed;
with (player) {
if (place_free(x+other.hspeed,y)) player.x+=other.hspeed;
}
}
if (place_meeting(x,y+2,player2)) {
player2.y+=vspeed+yspeed;
with (player2) {
if (place_free(x+other.hspeed,y)) player2.x+=other.hspeed;
}
}
if (vspeed<0) {
yspeed=vspeed;
vspeed=0;
}
if (yspeed>0) {
vspeed=yspeed;
yspeed=0;
}
-
I normally put invisible killers inside of blocks that players can be pushed into, like a squishing death. however,
I know I got something like what you want to work before but I cant remember the coding for now.
I suppose for an easy way you could make an object that preforms a while loop when contacting the player to push them down.
-
Create a new object, solid, give it a blocky 32*32 sprite and the parent of it should be "block". Replace the roof block with this new object and you're done!
-
I guess that just works on weird reading order lol.