My platformer engine has perfect collisions as of now, but no slope detection. You can view it here. If anyone could add a slope detection/movement section to the script, I would be grateful.
Offline
Because there is no slope detection XD
Offline
Use two sensor colours on the bottom edges of the sprite (they don't have to be very different from the sprites natural colour) and use
when gf clicked set [unsure] to (1) forever if <<color [#FF0000] is touching [#000000]?> and <not<color [#FFFFFF] is touching [#000000]?>>> if <(unsure) = (1)> switch to costume (relevant costume) set [unsure v] to (0)and you just dupe that code, it basically detects what corners are touching what and switches costume/direction accordingly, (unsure) is to detect if it's already set, thereby stopping it flickering. Unsire would need to be reset whenever you're not touching a platform. Oh BTW this only works for 45 135 etc degrees
Offline
Yes, I know how to do that. I mean the one costume 45 degrees or less kind of slope detection. And instead of using costumes and sensors, you can just have it switch to a tiny slope detection costume, say a few pixels, and duplicate something like
[if<touching color black>]
[change y by(insert number here)]
[change [direction^] by (insert number here)]
Then, do the same for the other side, then do that for
[if<not<touching color black>>]
[change y by (-insert number)]
[change [direction^] by (insert number)]
Thn add all those up and average them together. I think that's what you mean sort of but that's not
What I'm trying to do.
Offline
You can't do that easily, perhaps if you had a variable for each platform with it's direction and match it you could
EDIT:
a way of doing it:
when gf clicked point in direction (wanted direction) when gf clicked forever if <touching [sprite v]?> point in direction ([direction v] of [sprite v])
Last edited by zammer990 (2012-06-10 15:18:59)
Offline
But it's an engine . It's supposed to be a base you build upon. And that script might take 15-30 minutes to get right and perfect.
Offline
I saw your project. And I'll go write a quick script.
Edit: This could take a while, it'll probably involve a lot of trig
Last edited by zubblewu (2012-06-10 15:24:19)
Offline
zubblewu wrote:
I saw your project. And I'll go write a quick script.
Edit: This could take a while, it'll probably involve a lot of trig
unlikely, trigonometry is totally unnecessary, id't just be either sensors or variables
Offline
I mean with moving based on the slope. You'll see when i finish it.
Offline
And this is why I recommended array-based platforming. Slope detection is basically done for you; that is, the programmer can specify the exact shape of each type of tile. If I had finished the platforming base in that project I linked you to, I would have implemented 34 different tiles (including more sloped surfaces, and even rounded ones), but I ran out of time/energy/enthusiasm/Squeak's memory.
Offline
amcerbu wrote:
And this is why I recommended array-based platforming. Slope detection is basically done for you; that is, the programmer can specify the exact shape of each type of tile. If I had finished the platforming base in that project I linked you to, I would have implemented 34 different tiles (including more sloped surfaces, and even rounded ones), but I ran out of time/energy/enthusiasm/Squeak's memory.
Yep. What I mean, though, is using arctangent to predict the direction based on the slope, and changing the xvel by the cosine of the direction, creating realistic slope physics. I would have finished it in a few minutes but my frien and I are going to a concert and didn't have a chance to finish the last bit and test it. I'll probably post it at about 10 or 11 or sometime tomorrow.
Offline
But it's not quite just about changing x-velocity by cosine of direction. You actually don't need any trig at all. Check out Slopes, a project I made a few months ago that does what I think you're looking for. It takes in a slope value (from a list of slopes where it has approximated the slope of the tangent line of a function at many points), and gives bouncing/rolling physics, depending on the value of restitution; set it to 0 for sliding. Friction could also be easily added, I just never got around to it.
Last edited by amcerbu (2012-06-10 19:59:47)
Offline
Judging by the scripts it is capable to go up a 45 degree angle.
Offline
chanmanpartyman wrote:
Judging by the scripts it is capable to go up a 45 degree angle.
It seems like it should, but when I tested it it didn't work. If you want you can add a slope and see what happens XD.
Offline
Bump. And please ignore the rest of the posts.
Offline
My project perfect platformer base has perfect movement based on slopes. Test out the scripts and let me know!
Offline