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
Physics.cpp
00001 #include "Physics.h" 00002 00003 Position::Position() : vPos(), pPrev(), pCur() 00004 { // constructor 00005 00006 } 00007 00008 Point Position::getPrev() 00009 { 00010 return(pPrev); 00011 } 00012 00013 Point Position::getCur() 00014 { 00015 return(pCur); 00016 } 00017 00018 int Position::getX() 00019 { 00020 return(pCur.getX()); 00021 } 00022 int Position::getY() 00023 { 00024 return(pCur.getY()); 00025 } 00026 00027 void Position::set(float x, float y) 00028 { 00029 pPrev=pCur; 00030 vPos.x=x; 00031 vPos.y=y; 00032 pCur.set(rint(vPos.x), rint(vPos.y)); 00033 } 00034 00035 void Position::set(int x, int y) 00036 { 00037 set((float)x, (float)y); 00038 } 00039 00040 void Position::set(Point ptNew) 00041 { 00042 set(ptNew.getX(), ptNew.getY()); 00043 } 00044 00045 void Position::setX(int x) 00046 { 00047 set((float)x, vPos.y); 00048 } 00049 00050 void Position::setY(int y) 00051 { 00052 set(vPos.x, (float)y); 00053 } 00054 00055 void Position::move(float fDiffX, float fDiffY) 00056 { 00057 pPrev=pCur; 00058 vPos.x+=fDiffX; 00059 vPos.y+=fDiffY; 00060 pCur.set(rint(vPos.x), rint(vPos.y)); 00061 } 00062 00063 void Position::move(int nDiffX, int nDiffY) 00064 { 00065 move((float)nDiffX, (float)nDiffY); 00066 } 00067 00068 void Position::move(Vector vDiff) 00069 { 00070 move(vDiff.x, vDiff.y); 00071 } 00072 00073 bool Position::hasChanged() 00074 { 00075 //return(nPrevX!=nCurX || nPrevy!=nCury); 00076 return(pPrev.getX()!=pCur.getX() || pPrev.getY()!=pCur.getY()); 00077 } 00078 00079 Dimension::Dimension() 00080 { 00081 nWidth=0; 00082 nHeight=0; 00083 }
Generated on Thu Jul 14 2022 10:55:45 by
1.7.2