Author Topic: Flexible moving platform  (Read 3516 times)

Cantavanda

  • Wannabe
  • Posts: 12
  • ❋ Prince of the magical flower forest ❋
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 46.0.2490.86 Chrome 46.0.2490.86
    • View Profile
  • Playstyle: Keyboard
Flexible moving platform
« 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!

klazen108

  • Administrator
  • The Kid
  • Posts: 286
  • your a kid now your a squid now
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 46.0.2490.86 Chrome 46.0.2490.86
    • View Profile
    • Delicious-Fruit
  • Playstyle: Keyboard
Re: Flexible moving platform
« Reply #1 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



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

L4Vo5

  • Cherry Eater
  • Posts: 59
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.2.2564.88 Chrome 48.2.2564.88
    • View Profile
  • Playstyle: Keyboard
Re: Flexible moving platform
« Reply #2 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)
I have to admit, i still haven't beaten IWBTG

Kyir

  • The Kid
  • Posts: 293
  • Normal Guy
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.0.2564.103 Chrome 48.0.2564.103
    • View Profile
  • Playstyle: Keyboard
Re: Flexible moving platform
« Reply #3 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.'
« Last Edit: February 10, 2016, 10:33:59 PM by Kyir »

L4Vo5

  • Cherry Eater
  • Posts: 59
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.2.2564.88 Chrome 48.2.2564.88
    • View Profile
  • Playstyle: Keyboard
Re: Flexible moving platform
« Reply #4 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
I have to admit, i still haven't beaten IWBTG

Kyir

  • The Kid
  • Posts: 293
  • Normal Guy
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.0.2564.103 Chrome 48.0.2564.103
    • View Profile
  • Playstyle: Keyboard
Re: Flexible moving platform
« Reply #5 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.

L4Vo5

  • Cherry Eater
  • Posts: 59
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.0.2564.116 Chrome 48.0.2564.116
    • View Profile
  • Playstyle: Keyboard
Re: Flexible moving platform
« Reply #6 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
« Last Edit: March 12, 2016, 07:11:59 PM by L4Vo5 »
I have to admit, i still haven't beaten IWBTG

Cantavanda

  • Wannabe
  • Posts: 12
  • ❋ Prince of the magical flower forest ❋
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 49.0.2623.87 Chrome 49.0.2623.87
    • View Profile
  • Playstyle: Keyboard
Re: Flexible moving platform
« Reply #7 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!