I Wanna Community

Fangames => Game Design => Topic started by: Cantavanda on November 22, 2015, 09:03:18 AM

Title: Flexible moving platform
Post by: Cantavanda on November 22, 2015, 09:03:18 AM
Hello there, since the birth of IWBTG engines, starting with Tijit's engine, I have been very dissapointed by the moving platform code. That complicated weird small unflexible heap of characters.
That one weird code made it's way in EVERY other engine in existence, including the Yuuutu and YoYoYo editions.
I am looking, and even ready to pay for a code, an edit of the player/platform collision code, that is very flexible, so the platform can follow paths, and go in all directions, without any studdering, or clipping, flawlessly.

If you have the skills to program it, and want to discuss it, and want some MONEY, then feel free to reply to this, or PM me.
And if it already exist, could you please post it as a reply?

Thank you!
Title: Re: Flexible moving platform
Post by: klazen108 on November 23, 2015, 01:34:05 AM
So I gave it a shot, and got something going reasonably well in Yoyo's studio engine. I threw this together really quick, it's not finished yet but it's 1:30 am and I'm going to bed so I thought I'd just post it here to share :Kappa:

This demo has moving platforms vertical, horizontal, and diagonal, as well as platforms moving on a path (and theoretically any other method you can think of). They seem to handle just like ordinary platforms too, but we all know I'm no good at replicating fangame physics so take that with a grain of salt.

It looks like path movement and hspeed/vspeed movement is handled at different points internally in the game maker engine, so there's some incompatibilities there causing the code to not be simple. I might fix this by just removing the hspeed/vspeed part and moving manually, or manually do the path stuff, not sure, just thoughts as the sleepiness takes over. Anywayyyy here's the link if you want to look (https://klazen.com/IWBTG/archive/Path%20Platform%20Demo%20in%20GMSYoYoYo1_12.gmz)

(httpss://i.gyazo.com/28d317f3f2fa41dcfe4b4c14ae1178f3.gif)

Warning I broke non-moving platforms so you're going to drop to your death as soon as you spawn ingame if you don't put some blocks under you. Already uploaded the project and don't feel like fixing it atm. Sorry! That's what you get for playing Early Access™ demos
Title: Re: Flexible moving platform
Post by: L4Vo5 on February 10, 2016, 09:52:42 PM
I actually made platforms in the game i'm working on by storing the relative position of the kid to the platform and then teleporting him there every frame (before he moves) and calculating the relative position again (after he moves, so he won't just be stuck there). I also made the kid store the platform he is standing in to avoid problems when having many platforms in one position. You think exactly how to apply those things
I won't give exact code but that should work flawlessly with paths and everything

(actually, there is a little bug in the specific way i made it and i'm too lazy to fix it right now because i won't use platforms just yet)
Title: Re: Flexible moving platform
Post by: Kyir on February 10, 2016, 10:31:23 PM
So what you're saying is 'I have a solution but I'm only going to describe it vaguely.'
Title: Re: Flexible moving platform
Post by: L4Vo5 on February 10, 2016, 11:33:57 PM
Sorry if that's what it looked like
I can't reveal the code because it's like 3 different pieces scatered around the other code i have, so i described the exact strategy i used because it's pretty flexible since you can move the platform wherever you want while using it
In fact, now i'll try to fix the glitch i was talking about, then see how i can manage to post a more complete reply
Title: Re: Flexible moving platform
Post by: Kyir on February 11, 2016, 12:12:34 AM
Sorry if that was rude, it seemed like you were being needlessly secretive or something. I would recommend just posting all relevant pieces of code and just say which objects they're in. Piecing things together after that isn't very hard.
Title: Re: Flexible moving platform
Post by: L4Vo5 on March 12, 2016, 07:09:06 PM
Sorry for the late reply. Haven't checked this forum in weeks
Ok. Didn't fix the bug/glitch but it probably won't give you much trouble anyways(sometimes you don't ride the platform if you fall right on the edge, and if you get to the platform and move to the edge you will stop riding it as soon as it bounces off a block. Hopefully that only happens because of the way i made the rest of the code tough)
Everything in the code is in the kid, except for this in the platform creation code:
hspd=0
vspd=0 //these values are here so that they are declared and don't cause trouble later

kid create event :
plat = 0
platdist[1] = 0 //platdist[0] = x and platdist[1] = y. The distance to the platform being used
platC = 0 //confirmation that you have been at least 1 step on a platform
hsped2 = 0
vsped2 = 0

kid step event:

Before the code for moving left/rigth:

//platforms
//moving platforms
with (obj_Platform) {
x+=hspd
y+=vspd
bounce(SolidObj) //this is the code i need for now. But in here you should do whatever you want to do to make the platforms move. I do it here because i need them to move now and not later
}
//moving to a position relative to the platform being used (plat)

if plat >1{
if platC = 1{
hsped2 = (plat.x+platdist[0]-x)
vsped2 = (plat.y+platdist[1]-y)
}
platC = 1
} else {platdist[0] = 0;platdist[1] = 0;platC = 0;hsped2=0;vsped2=0}
//platforms

anywhere in between this and the next code:
if vsped2 !=0{
if vsped2 >0 move_contact_solid(direction+270,vsped2)
else move_contact_solid(direction+90,-vsped2)
}
if hsped2 !=0{
if hsped2 >0 move_contact_solid(direction,hsped2)
else move_contact_solid(direction+180,-hsped2)
}


after the last code and after the left/right movement code:
//platforms
if plat >1{
platdist[0] = x - plat.x
platdist[1] = y - plat.y
vsped = 0}
//platforms


I think that's all. Hope it's useful
Title: Re: Flexible moving platform
Post by: Cantavanda on March 22, 2016, 12:05:51 PM
-Snip-
Oh dude, thank you so much!
I haven't logged in since November, so I haven't seen it, sorry!