How does the Platform Behavior exactly function?

For questions about using Classic.

Post » Sun Jan 03, 2016 5:10 pm

When an object has the Platform Behavior, what exactly do the different variables(Floor Accelaration, Jump Strenght, Fall Gravity, etc.) represent? Is it the number of pixels the object is moved with every frame? What are the exact formulas, that this Behavior uses? How is everything calculated? I need to have more control over objects with this Behavior and experimentation didn't get me far. Now, you might say, that I should just make a custom Gravity Subroutine, but I don't have much time and I would like to make games more quickly. The Behaviors, that come with Construct Classic will help out a lot in this case, but I need to know what they exactly do.

Thanks!
B
4
S
1
Posts: 13
Reputation: 376

Post » Sun Jan 03, 2016 7:04 pm

Its pixels per second synced at 60 frames per second.
Meaning it will vary depending on the frame rate.
There are no formulas available, unless you can get somebody to dig through the source code.
Image ImageImage
B
171
S
50
G
180
Posts: 8,397
Reputation: 113,988

Post » Sun Jan 03, 2016 7:08 pm

newt wrote:There are no formulas available, unless you can get somebody to dig through the source code.


Source is here if it helps: https://svn.code.sf.net/p/construct/code/Behaviors/Platform/
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
87
Posts: 5,498
Reputation: 60,282

Post » Sun Jan 03, 2016 7:40 pm

When you click on those parameters in the editor there is a description at the bottom of the property bar that tells what it does. The speeds are in pixels/second and the accelerations are in pixels/second^2, and sustain is in milliseconds as I recall.

Anyway you'll have to look in the source to see exactly what it does. It also has some other things it handles such as being on a moving platform and such.

Roughly off the top of my head the motion is done like this. On top of that you'll need to detect collisions and resolve them someway.

not on ground
--- add gravity*dt to velocityY

global number upPressTime=0

on up pressed
--- set upPressTime to time

up is pressed
time < pressTime+sustain
--- set velocityY to -jumpStrength

left is down
--- subtract acceleration*dt from velocityX

left is not down
velocityX < 0
--- add deceleration*dt to velocityX

right is down
--- add acceleration*dt to velocityX

right is not down
velocityX > 0
--- subtract deceleration*dt from velocityX

every tick
--- set velocityY to min(velocityY, maxFallSpeed)
--- set velocityX to clamp(velocityX, -maxSpeed, maxSpeed)
--- set x to self.x+velocityX*dt
--- set y to self.y+velocityY*dt
B
94
S
33
G
114
Posts: 5,361
Reputation: 73,783


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest