Code:
self.Vel.Y = self.Vel.Y - (TimerMan.DeltaTimeSecs * SceneMan.GlobalAcc.Y)
if ownController:IsState(Controller.HOLD_LEFT) then
self.Vel.X = self.Vel.X - self.acceleration;
if self.Vel.X < -self.maxSpeed then
self.Vel.X = -self.maxSpeed;
end
elseif ownController:IsState(Controller.HOLD_RIGHT) then
self.Vel.X = self.Vel.X + self.acceleration;
if self.Vel.X > self.maxSpeed then
self.Vel.X = self.maxSpeed;
end
elseif self.Vel.X < 0 then
self.Vel.X = self.Vel.X + self.acceleration;
if self.Vel.X > 0 then
self.Vel.X = 0;
end
elseif self.Vel.X > 0 then
self.Vel.X = self.Vel.X - self.acceleration;
if self.Vel.X < 0 then
self.Vel.X = 0;
end
end
if ownController:IsState(Controller.HOLD_UP) then
self.Vel.Y = self.Vel.Y - self.acceleration;
if self.Vel.Y < -self.maxSpeed then
self.Vel.Y = -self.maxSpeed;
end
elseif ownController:IsState(Controller.HOLD_DOWN) then
self.Vel.Y = self.Vel.Y + self.acceleration;
if self.Vel.Y > self.maxSpeed then
self.Vel.Y = self.maxSpeed;
end
elseif self.Vel.Y < 0 then
self.Vel.Y = self.Vel.Y + self.acceleration;
if self.Vel.Y > 0 then
self.Vel.Y = 0;
end
elseif self.Vel.Y > 0 then
self.Vel.Y = self.Vel.Y - self.acceleration;
if self.Vel.Y < 0 then
self.Vel.Y = 0;
end
end
Darlos's grav tester is fairly pointless.
You need to define speed and acceration in create.
The rest should be simple for anyone with basic lua synthax knowlage.