Fries
604d79e654
i added a GameArea class which makes it easier to operate on in coordinates bounds with the GameCoordinate struct wrapper which does calculations for me. the GameArea class also has a normalization system which is how the ScalingManager can teleport items in bounds to relatively the same place when resized. it took quite a while to get the paddle to teleport. looks like im supposed to modify the position inside IntegrateForces instead of PhysicsProcess which is my mistake.
25 lines
939 B
C#
25 lines
939 B
C#
namespace Pong.Scripts.Data;
|
|
|
|
/// <summary>
|
|
/// simple wrapper structure to a double that makes it easy to get commonly used calculations of the number.
|
|
/// </summary>
|
|
/// <param name="Coordinate">the coordinate you want to wrap.</param>
|
|
public readonly record struct GameCoordinate(double Coordinate)
|
|
{
|
|
/// <summary>
|
|
/// the original coordinate. you don't really need to use this as the struct has an implicit operator, but
|
|
/// its here if you need it.
|
|
/// </summary>
|
|
public readonly double Coordinate = Coordinate;
|
|
|
|
/// <summary>
|
|
/// get the coordinate but calculated by the extents of the wall size.
|
|
/// </summary>
|
|
public double ByWallSizeExtents => Coordinate - Constants.WallSizeExtents;
|
|
/// <summary>
|
|
/// get the coordinate but calculated by the wall size.
|
|
/// </summary>
|
|
public double ByWallSize => Coordinate - Constants.WallSize;
|
|
|
|
public static implicit operator double(GameCoordinate coord) => coord.Coordinate;
|
|
}
|