Skip to content

Commit 010cd5d

Browse files
author
Patrick Rye
committed
Update to v1.1.6-beta.2
Started work on adding collison dection unfinsihed at the moment
1 parent 721524a commit 010cd5d

File tree

6 files changed

+62
-11
lines changed

6 files changed

+62
-11
lines changed

ChangesLog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
15 September 2015
2+
UNFINISHED Released version 1.1.7-Beta
3+
4+
Change log:
5+
-Added: Collisons
6+
17
15 September 2015
28
Released version 1.1.6-Beta
39

project/SDL-Cannon-Simulation.cbp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@
130130
<Unit filename="../src/cannonball.h" />
131131
<Unit filename="../src/config.cpp" />
132132
<Unit filename="../src/config.h" />
133+
<Unit filename="../src/global.h" />
133134
<Unit filename="../src/image_ball.xpm" />
134-
<Unit filename="../src/image_cannon.xpm" />
135+
<Unit filename="../src/image_pixel.xpm" />
135136
<Unit filename="../src/image_sky.xpm" />
136137
<Unit filename="../src/main.cpp" />
137138
<Unit filename="../src/screen.cpp" />

src/cannonball.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,8 @@ void clsCannonball::setValues(double r, LOC init_place, double init_vel, double
123123
if (Global::Config.values.blnDragMode) { enableDrag(); }
124124
}
125125
/**********************************************************************************************************************************************/
126+
LOC clsCannonball::getplace() {
127+
return place;
128+
}
129+
/**********************************************************************************************************************************************/
126130

src/cannonball.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class clsCannonball {
3030
clsCannonball();
3131
bool blnstarted;
3232
void setValues(double, LOC, double, double);
33+
LOC getplace(void);
3334

3435
void enableDrag(void);
3536
void update(double);

src/main.cpp

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@
1010
#include "tick.h"
1111
#include "config.h"
1212
/**********************************************************************************************************************************************************************/
13+
struct stcBox {
14+
uint left;
15+
uint right;
16+
uint top;
17+
uint bottom;
18+
};
19+
typedef struct stcBox BOX;
20+
/**********************************************************************************************************************************************************************/
1321
void addNewCannonball(LOC, LOC);
22+
void checkForCollisons(void);
23+
bool checkCollide(BOX, BOX);
24+
void doCollision(uint, uint);
25+
BOX boxMaker(LOC);
1426
/**********************************************************************************************************************************************************************/
1527
namespace Global {
1628
#ifdef DEFINED_BUILD_MODE_PRIVATE
@@ -83,7 +95,7 @@ int main(int argc, char *argv[]) {
8395
Cannonballs[i].update(tempdeltat);
8496
} //end if started
8597
} //end for loop
86-
98+
checkForCollisons();
8799
CannonWindow.update();
88100
} while (!quit);
89101
return 0;
@@ -124,11 +136,38 @@ void addNewCannonball(LOC mouseC, LOC mouseO ) {
124136
printf("You cannot add more cannonballs, please wait for some to decay.\n");
125137
}
126138
/**********************************************************************************************************************************************************************/
127-
void checkCollide(LOC place1, LOC place2) {
128-
139+
void checkForCollisons() { //Checks every cannonball against every other cannonball to see if they collide
140+
BOX A, B;
141+
for(uint j = 0; j < DEFINED_CANNONBALL_LIMIT; j++) {
142+
A = boxMaker( Cannonballs[j].getplace() );
143+
for (uint i = 0; i < DEFINED_CANNONBALL_LIMIT; i++) {
144+
if (Cannonballs[i].blnstarted && i != j) {
145+
B = boxMaker( Cannonballs[i].getplace() );
146+
if ( checkCollide(A, B) ) { doCollision(j, i); }
147+
} //end if started and not same ball
148+
} //end for loop inner
149+
} //end for loop outer
150+
}
151+
/**********************************************************************************************************************************************************************/
152+
bool checkCollide(BOX A, BOX B) { //checks if two objects (made with the BOXES collide)
153+
if( A.bottom <= B.top ){return false;}
154+
if( A.top >= B.bottom ){return false;}
155+
if( A.right <= B.left ){return false;}
156+
if( A.left >= B.right ){return false;}
157+
//If none of the sides from A are outside B
158+
return true;
129159
}
130160
/**********************************************************************************************************************************************************************/
131161
void doCollision(uint num1, uint num2) {
132162

133163
}
134164
/**********************************************************************************************************************************************************************/
165+
BOX boxMaker(LOC place) {
166+
BOX tempBOX;
167+
tempBOX.left = place.x;
168+
tempBOX.top = place.y;
169+
tempBOX.bottom = tempBOX.top + 10;
170+
tempBOX.right = tempBOX.left + 10;
171+
return tempBOX;
172+
}
173+
/**********************************************************************************************************************************************************************/

src/version.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
//Standard Version Type
1515
#define DEFINED_VER_MAJOR 1
1616
#define DEFINED_VER_MINOR 1
17-
#define DEFINED_VER_BUILD 6
18-
#define DEFINED_VER_REVISION 5
17+
#define DEFINED_VER_BUILD 7
18+
#define DEFINED_VER_REVISION 6
1919

2020
//Miscellaneous Version Types
21-
#define DEFINED_VER_BUILDS_COUNT 142
22-
#define DEFINED_VER_RC_FILEVERSION 1,1,6,5
23-
#define DEFINED_VER_RC_FILEVERSION_STRING "1, 1, 6, 5\0"
24-
#define DEFINED_VER_FULLVERSION_STRING "1.1.6.5"
21+
#define DEFINED_VER_BUILDS_COUNT 160
22+
#define DEFINED_VER_RC_FILEVERSION 1,1,7,6
23+
#define DEFINED_VER_RC_FILEVERSION_STRING "1, 1, 7, 6\0"
24+
#define DEFINED_VER_FULLVERSION_STRING "1.1.7.6"
2525

2626
//These values are to keep track of your versioning state, don't modify them.
27-
#define DEFINED_VER_BUILD_HISTORY 3
27+
#define DEFINED_VER_BUILD_HISTORY 4
2828

2929

3030
#endif //__VERSION_HEADER__

0 commit comments

Comments
 (0)