Fangames > Game Design
Flexible moving platform
Kyir:
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:
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
Cantavanda:
--- Quote from: klazen108 on November 23, 2015, 01:34:05 AM ----Snip-
--- End quote ---
Oh dude, thank you so much!
I haven't logged in since November, so I haven't seen it, sorry!
Navigation
[0] Message Index
[*] Previous page
Go to full version