Commit 9e4c7ef7 authored by Sapln's avatar Sapln
Browse files

1ere tentative de changement de gravité seulement au sol

detection si au sol mais pb (a voir si c'est du aux blocs "collants" ou un pb de changement de gravité)
parent 1812865c
......@@ -15,7 +15,8 @@ namespace ZZZZZZ.Objects.Character
public float Speed { get; set; }
private List<Sprite2D> Sprites;
private float internalTimer;
private bool isGrounded = false;
public bool isGrounded { get; private set; }
private Vector2 prevPos = new Vector2(0, 0);
public Character()
{
......@@ -27,6 +28,7 @@ namespace ZZZZZZ.Objects.Character
Body.UseFixtureMass = false;
Body.Inertia = 5;
Body.FixedRotation = true;
isGrounded = false;
internalTimer = 0f;
......@@ -54,6 +56,10 @@ ApplicationOptions: args -w -x 720 -y 540 -s -p "CoreData;Data" -pp "D:\bureau\b
Console.WriteLine(movement);
var vect = new Vector2(0, 0);
var gravity = GameManager.Current.Scene.Gravity;
isGrounded = (((gravity == GravityDirection.Droite || gravity == GravityDirection.Gauche) && prevPos.X == Body.Node.Position.X)
|| ((gravity == GravityDirection.Haut || gravity == GravityDirection.Bas) && prevPos.Y == Body.Node.Position.Y));
switch (movement)
{
case Movement.Left:
......@@ -95,6 +101,8 @@ ApplicationOptions: args -w -x 720 -y 540 -s -p "CoreData;Data" -pp "D:\bureau\b
vect *= Speed;
//vect += GameManager.Current.Scene.PhysicsWorld2D.Gravity * 10;
Body.SetLinearVelocity(vect);
prevPos.X = Body.Node.Position.X;
prevPos.Y = Body.Node.Position.Y;
}
......
......@@ -16,6 +16,7 @@ namespace ZZZZZZ.Physics
get { return gravity; }
set
{
gravity = value;
switch (gravity)
{
......
......@@ -35,8 +35,9 @@ namespace ZZZZZZ.Player
private void Input_GravityChanged(InputActionArgs obj)
{
//Character.Move(Input.Movement);
GameManager.Current.Scene.Gravity = Input.GDir;
if (Character.isGrounded)
GameManager.Current.Scene.Gravity = Input.GDir;
}
private void Current_Update(UpdateEventArgs obj)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment