I'm currently making a mario fangame and I wanted to know how would an acceleration/sliding movement work in Love2D.
Anything about Skidding would also be grateful.
Sliding/Acceleration/Skidding in Love2D?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- JacKobOriginal
- Prole
- Posts: 11
- Joined: Thu Mar 22, 2018 12:05 am
- Location: Colombia
- Contact:
Sliding/Acceleration/Skidding in Love2D?
Follow my GameDev Twitter: https://twitter.com/qqnutgames
Play Lil Jingle: https://qqnut.itch.io/lil-jingle
Play Lil Jingle: https://qqnut.itch.io/lil-jingle
Re: Sliding/Acceleration/Skidding in Love2D?
Skidding as in Super Mario is where the player's velocity points one way, but there is a constant acceleration in the opposite direction.
In many games your velocity drops to 0 as soon as you release the movement keys.
There are other games where you could be skidding but it's not shown explicitly on the screen.
The clever thing about Mario is that they were smart enough to draw a sprite that makes Mario look like he is actually skidding.
This is similar to throwing a ball up in the air.
When you throw the ball up you make its velocity positive.
But gravity is constantly accelerating it down.
Over a few seconds, the ball's velocity goes from positive to negative.
Sliding is more complicated and is related to friction.
This is where you push an object and it eventually comes to a halt.
So when you release the movement keys, Mario slows down and stops.
Friction happens when two bodies are contacting
although some people use "damping" to emulate this effect.
In many games your velocity drops to 0 as soon as you release the movement keys.
There are other games where you could be skidding but it's not shown explicitly on the screen.
The clever thing about Mario is that they were smart enough to draw a sprite that makes Mario look like he is actually skidding.
Code: Select all
-- movement
acceleration = 0
if love.keyboard.isDown('left') then
acceleration = -1
elseif love.keyboard.isDown('right') then
acceleration = 1
end
-- simulation
velocity = velocity + acceleration
position = position + velocity
-- skidding check
if velocity < 0 and acceleration > 0 or velocity > 0 and acceleration < 0 then
-- yep
end
When you throw the ball up you make its velocity positive.
But gravity is constantly accelerating it down.
Over a few seconds, the ball's velocity goes from positive to negative.
Sliding is more complicated and is related to friction.
This is where you push an object and it eventually comes to a halt.
So when you release the movement keys, Mario slows down and stops.
Friction happens when two bodies are contacting
although some people use "damping" to emulate this effect.
Re: Sliding/Acceleration/Skidding in Love2D?
Thank you! Works like a charm .
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests