Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RETRO_BallsAndPaddle RETRO_BallAndHoles
Diff: Physics.cpp
- Revision:
- 0:3d0db4e183ee
- Child:
- 7:4fa3edaa1201
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Physics.cpp Fri Feb 06 09:51:06 2015 +0000
@@ -0,0 +1,91 @@
+#include "Physics.h"
+
+Position::Position() : vPos(), pPrev(), pCur()
+{ // constructor
+
+}
+
+Point Position::getPrev()
+{
+ return(pPrev);
+}
+
+Point Position::getCur()
+{
+ return(pCur);
+}
+
+int Position::getX()
+{
+ return(pCur.getX());
+}
+int Position::getY()
+{
+ return(pCur.getY());
+}
+
+void Position::set(float x, float y)
+{
+ //nPrevX=nCurX;
+ //nPrevY=nCurY;
+ pPrev=pCur;
+ vPos.x=x;
+ vPos.y=y;
+ pCur.set(rint(vPos.x), rint(vPos.y));
+ //nCurX=rint(vPos.x);
+ //nCurY=rint(vPos.y);
+}
+
+void Position::set(int x, int y)
+{
+ set((float)x, (float)y);
+}
+
+void Position::set(Point ptNew)
+{
+ set(ptNew.getX(), ptNew.getY());
+}
+
+void Position::setX(int x)
+{
+ set((float)x, vPos.y);
+}
+
+void Position::setY(int y)
+{
+ set(vPos.x, (float)y);
+}
+
+void Position::move(float fDiffX, float fDiffY)
+{
+ //nPrevX=nCurX;
+ //nPrevY=nCurY;
+ pPrev=pCur;
+ vPos.x+=fDiffX;
+ vPos.y+=fDiffY;
+ pCur.set(rint(vPos.x), rint(vPos.y));
+ //nCurX=rint(vPos.x);
+ //nCurY=rint(vPos.y);
+}
+
+void Position::move(int nDiffX, int nDiffY)
+{
+ move((float)nDiffX, (float)nDiffY);
+}
+
+void Position::move(Vector vDiff)
+{
+ move(vDiff.x, vDiff.y);
+}
+
+bool Position::hasChanged()
+{
+ //return(nPrevX!=nCurX || nPrevy!=nCury);
+ return(pPrev.getX()!=pCur.getX() || pPrev.getY()!=pCur.getY());
+}
+
+Dimension::Dimension()
+{
+ nWidth=0;
+ nHeight=0;
+}
\ No newline at end of file