Added physics types.#1
Conversation
Gravity, Velocity, Position, DrawColor, more for individual points. Working on a unified PhysicsObject class to treat many points as one object.
| return val; | ||
| } | ||
| public static float ClampMin(float min, float val) | ||
| { |
There was a problem hiding this comment.
There was a problem hiding this comment.
Per discussion with Peter, the idea is a one-side capping of the value, rather than automatic return of a max value, as Math.Max would do.
| } | ||
| return val; | ||
| } | ||
| public static float ClampMax(float max, float val) |
There was a problem hiding this comment.
There was a problem hiding this comment.
Per discussion with Peter, the idea is a one-side capping of the value, rather than automatic return of a min value, as Math.Min would do.
glen3b
left a comment
There was a problem hiding this comment.
I haven't looked too deeply at the actual physics implementation, but I've briefly reviewed the general API and I have a handful of preliminary pointers.
| { | ||
| public static class PhysicsExtensions | ||
| { | ||
| public static bool ContainsPoint(this List<PhysicsPoint> points, Point point, bool mustInteractWithEnvironment = true) |
There was a problem hiding this comment.
This looks like it could take an IEnumerable<PhysicsPoint> instead of a list, is there any particular reason you need it to be ordered?
There was a problem hiding this comment.
Agreed, IEnumerable is a better choice here.
| return false; | ||
| } | ||
|
|
||
| public static Point BottomLeft(this List<PhysicsPoint> points) |
There was a problem hiding this comment.
Consider whether this can take an IEnumerable.
There was a problem hiding this comment.
Agreed, IEnumerable is a better choice here.
|
|
||
| namespace ConsoleGameLib | ||
| { | ||
| public class PhysicsPoint |
There was a problem hiding this comment.
Consider overloading Equals, GetHashCode, and the corresponding operators.
|
|
||
|
|
||
|
|
||
| public List<PhysicsPoint> Contents |
| | ||
| Microsoft Visual Studio Solution File, Format Version 11.00 | ||
| # Visual C# Express 2010 | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 |
There was a problem hiding this comment.
This will break compatibility with developing in VS express 2010, this is probably OK but is worth evaluating.
There was a problem hiding this comment.
Ok with that. VS2010 is a discontinued product, it can't even be installed (or more precisely, activated once installed) anymore.
| { | ||
|
|
||
| static void Main(string[] args) | ||
| { |
There was a problem hiding this comment.
Please comment your example code extensively so it is easy to tell what it does without referring to other code.
There was a problem hiding this comment.
Comments are good. I agree with this suggestion
| { | ||
| foreach(PhysicsPoint entry in points) | ||
| { | ||
| if(entry.Position.X == point.X && entry.Position.Y == point.Y && (mustInteractWithEnvironment == true ? entry.InteractsWithEnvironment : true)) |
There was a problem hiding this comment.
entry.Position is of type ConsoleGameLib.CoreTypes.Point, which currently does not have equality operators overloaded. I plan to submit a separate pull request which fixes this. If that goes through, I suggest using overloaded equality operators.
In addition, it appears mustInteractWithEnvironment is a boolean. If this is the case, you can eliminate the == true (minor code style comment).
There was a problem hiding this comment.
Great suggestions, agreed. Will review your PR shortly.
Grabbing Glen's changes to upstream. Who uses VIM?
Gravity, Velocity, Position, DrawColor, more for individual points.
Working on a unified PhysicsObject class to treat many points as one object.