Skip to content

Commit 57cb92b

Browse files
committed
Update to v1.4.1-rc.1
## [1.4.1-rc.1] - 2020.05.29 ### Added * Pause symbol for when simulation is paused (Issue #10) ### Fixed * Defined macros not working correctly since I moved certain functions to core.cpp ### Changed * Modified the check overlap function
1 parent 3d11f04 commit 57cb92b

File tree

9 files changed

+113
-51
lines changed

9 files changed

+113
-51
lines changed

docs/ChangesLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
All notable changes to this project will be documented here.
44
This project adheres to [Semantic Versioning](http://semver.org/)
55

6-
## [1.4.1-beta.3] - Unreleased
6+
## [1.4.1-rc.1] - Unreleased
77
### Added
88
* Math function specifically to deal with vector math.
9+
* Pause symbol for when simulation is paused (Issue #10)
910

1011
### Fixed
1112
* Spelling mistakes
1213
* Various Code mistakes
1314
* Drag tool not un-pausing correctly
15+
* Defined macros not working correctly since I moved certain functions to core.cpp
1416

1517
### Changed
1618
* Updated Doxygen file
1719
* Info tool now displays if ball is paused
20+
* Modified the check overlap function
1821

1922
## [1.4.0-R] - 2018-03-27
2023
### Added

src/core.cpp

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ void cannonballs::addNew(LOC mouseC, LOC mouseO, double HoldTime ) {
5858
intCannonBallNum++;
5959
clsCannonball tempBall;
6060
tempBall.setValues(radius, mouseO, fire_v, angle, intCannonBallNum);
61-
if (intCannonBallNum > 1) {
62-
if(balls[0].isPaused()) { tempBall.togglePause(); }
63-
}
61+
if (global::blnPaused) { tempBall.togglePause(); }
6462
balls.push_back(tempBall);
6563

6664
return;
@@ -77,6 +75,7 @@ void cannonballs::checkCollisons(uint j) {
7775
/////////////////////////////////////////////////
7876

7977
BOX A, B;
78+
dblXY ball_a_loc;
8079
dblXY ball_b_loc;
8180
A = balls[j].getBOX();
8281
if (balls[j].blncheckphysics_) {
@@ -85,14 +84,31 @@ void cannonballs::checkCollisons(uint j) {
8584
B = balls[i].getBOX();
8685
if ( checkOverlap(A, B) ) {
8786
doCollide(j, i);
88-
ball_b_loc = balls[i].getdbLOC();
89-
/** @todo (GamerMan7799#9#): This might work for stopping the balls from overlapping, just need to add a check on which way they are colliding */
90-
/*do {
91-
ball_b_loc.x++;
92-
ball_b_loc.y++;
87+
/** @todo (GamerMan7799#3#): This might work for stopping the balls from overlapping, just need to add a check on which way they are colliding */
88+
#if DEFINED_PUSH_BALLS_OUT_OF_OVERLAP == 1
89+
ball_a_loc = balls[j].getdbLOC();
90+
ball_b_loc = balls[i].getdbLOC();
91+
do {
92+
if (A.right <= B.right && A.right >= B.left) {
93+
ball_a_loc.x--;
94+
ball_b_loc.x++;
95+
} else if (A.left >= B.left && A.left <= B.right) {
96+
ball_a_loc.x++;
97+
ball_b_loc.x--;
98+
}
99+
if (A.top >= B.top && A.top <= B.bottom) {
100+
ball_a_loc.y++;
101+
ball_b_loc.y--;
102+
} else if (A.bottom >= B.top && A.bottom <= B.bottom) {
103+
ball_a_loc.y--;
104+
ball_b_loc.y++;
105+
}
93106
balls[i].setdbLOC(ball_b_loc);
107+
balls[j].setdbLOC(ball_a_loc);
108+
A = balls[j].getBOX();
94109
B = balls[i].getBOX();
95-
} while (checkOverlap(A,B)); */
110+
} while (checkOverlap(A,B));
111+
#endif
96112
balls[i].blncheckphysics_ = false;
97113
balls[j].blncheckphysics_ = false;
98114
} // end if overlap
@@ -111,12 +127,24 @@ bool cannonballs::checkOverlap(BOX A, BOX B) {
111127
///
112128
/////////////////////////////////////////////////
113129

114-
if( A.right < B.left ){ return false; }
130+
/** @todo (GamerMan7799#9#): Improve the overlap check to allow pixel-by-pixel detection */
131+
132+
if (A.right <= B.right && A.right >= B.left) {
133+
if (A.top >= B.top && A.top <= B.bottom) { return true; }
134+
else if (A.bottom >= B.top && A.bottom <= B.bottom) { return true; }
135+
else { return false; }
136+
} else if (A.left >= B.left && A.left <= B.right) {
137+
if (A.top >= B.top && A.top <= B.bottom) { return true; }
138+
else if (A.bottom >= B.top && A.bottom <= B.bottom) { return true; }
139+
else { return false; }
140+
} else { return false; }
141+
142+
/*if( A.right < B.left ){ return false; }
115143
if( A.left > B.right ){ return false; }
116144
if( A.bottom < B.top ){ return false; }
117145
if( A.top > B.bottom ){ return false; }
118146
119-
return true;
147+
return true;*/
120148
}
121149
/*****************************************************************************/
122150
void cannonballs::doCollide(uint numA, uint numB) {
@@ -408,6 +436,7 @@ char core::handleEvent(SDL_Event* e ) {
408436
return 0;
409437
case SDLK_p:
410438
//"pauses" the simulation by preventing ball from updating
439+
global::blnPaused = !(global::blnPaused);
411440
for (int i = 0; i < cannonballs::balls.size(); ++i)
412441
{ cannonballs::balls[i].togglePause(); }
413442
return 0;
@@ -544,23 +573,11 @@ void core::doDragTool(SDL_Event* e) {
544573
}
545574

546575
//if(global::blnDebugMode) { printf("Tool Drag event\n"); }
547-
if ( holding && !(cannonballs::balls[ball_num].isPaused()) ) {
576+
if ( holding && !(cannonballs::balls[ball_num].isPaused()) && !(global::blnPaused) ) {
548577
cannonballs::balls[ball_num].togglePause();
549-
} else if ( !(holding) ) {
550-
// check if the ball is the first or last
551-
if (&cannonballs::balls[ball_num] == &cannonballs::balls.front()) {
552-
if (!(cannonballs::balls.back().isPaused()) &&
553-
cannonballs::balls[ball_num].isPaused()) {
554-
cannonballs::balls[ball_num].togglePause();
555-
ball_num = -1;
556-
}
557-
} else {
558-
if (!(cannonballs::balls.front().isPaused()) &&
559-
cannonballs::balls[ball_num].isPaused()) {
560-
cannonballs::balls[ball_num].togglePause();
561-
ball_num = -1;
562-
}
563-
}
578+
} else if ( !(holding) && !(global::blnPaused) ) {
579+
cannonballs::balls[ball_num].togglePause();
580+
ball_num = -1;
564581
}
565582
}
566583
/*****************************************************************************/

src/global.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@
99
/// Global namespace. See Main.cpp for more details
1010
/////////////////////////////////////////////////
1111
/*****************************************************************************/
12+
#define DEFINED_USE_R2_VEL_MODDER 0
13+
/**< If this is defined, then program will use unrealistic method that will
14+
increase the velocity of two colliding balls the closer they are together
15+
it will reduce the number of times that the balls stick together,
16+
but also causes them to get unrealistically high velocities. */
17+
/*****************************************************************************/
18+
#define DEFINED_COLLISION_NORMAL_FORCE 0
19+
/**< If this is defined, then program will use apply a normal force to any
20+
colliding balls. The forces are along the same direction as the velocities
21+
are. It doesn't make sense in the real world. */
22+
/*****************************************************************************/
23+
#define DEFINED_PUSH_BALLS_OUT_OF_OVERLAP 1
24+
/**< This will turn on a method that will attempt to move the balls until they
25+
are no longer overlapping when detecting collision. */
26+
/*****************************************************************************/
1227
class clsConfig;
1328
/*****************************************************************************/
1429
//global typedefs
@@ -31,6 +46,7 @@ namespace cannonballs {
3146
namespace global {
3247
extern const bool blnDebugMode;
3348
extern clsConfig config;
49+
extern bool blnPaused;
3450
namespace physics {
3551
/////////////////////////////////////////////////
3652
/// @defgroup ChangeablePhysics Defined Physics values
@@ -88,7 +104,8 @@ enum Tools {
88104
ToolDrop, /**< Drops a ball without velocity. */
89105
ToolDele, /**< Tool to delete selected ball. */
90106
ToolDrag, /**< Tool that allows ball to be dragged around. */
91-
ToolInfo /**< Tool that writes information about the selected ball to screen */
107+
ToolInfo, /**< Tool that writes information about the selected ball to screen */
108+
ToolPause /**< Not really a tool, but the pause symbol */
92109
};
93110
/*****************************************************************************/
94111
#endif // __GLOBAL_H_INCLUDED__

src/image_tools.xpm

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* XPM */
22
static char * image_tools_xpm[] = {
3-
"24 144 2 1",
3+
"24 168 2 1",
44
" c None",
55
". c #FFFFFF",
66
" ",
@@ -146,4 +146,28 @@ static char * image_tools_xpm[] = {
146146
" ................ ",
147147
" ............. ",
148148
" .......... ",
149-
" .... "};
149+
" .... ",
150+
" ",
151+
" ........ ........ ",
152+
" ........ ........ ",
153+
" ........ ........ ",
154+
" ........ ........ ",
155+
" ........ ........ ",
156+
" ........ ........ ",
157+
" ........ ........ ",
158+
" ........ ........ ",
159+
" ........ ........ ",
160+
" ........ ........ ",
161+
" ........ ........ ",
162+
" ........ ........ ",
163+
" ........ ........ ",
164+
" ........ ........ ",
165+
" ........ ........ ",
166+
" ........ ........ ",
167+
" ........ ........ ",
168+
" ........ ........ ",
169+
" ........ ........ ",
170+
" ........ ........ ",
171+
" ........ ........ ",
172+
" ........ ........ ",
173+
" "};

src/main.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
/// @brief Holds all the main functions.
55
/// @author GamerMan7799
66
/// @author xPUREx
7-
/// @version 1.4.0-R
8-
/// @date 2018
7+
/// @version 1.4.1-rc.1
8+
/// @date 2015-2020
99
/// @copyright Public Domain Unlicense.
1010
/////////////////////////////////////////////////
1111
/*****************************************************************************/
@@ -16,17 +16,6 @@
1616
/** @todo (GamerMan7799#8#): Allow setting of some Physics Values in Config */
1717
/** @todo (GamerMan7799#8#): Set Max/Min values for mass? */
1818
/*****************************************************************************/
19-
#define DEFINED_USE_R2_VEL_MODDER 0
20-
/**< If this is defined, then program will use unrealistic method that will
21-
increase the velocity of two colliding balls the closer they are together
22-
it will reduce the number of times that the balls stick together,
23-
but also causes them to get unrealistically high velocities. */
24-
/*****************************************************************************/
25-
#define DEFINED_COLLISION_NORMAL_FORCE 0
26-
/**< If this is defined, then program will use apply a normal force to any
27-
colliding balls. The forces are along the same direction as the velocities
28-
are. It doesn't make sense in the real world. */
29-
/*****************************************************************************/
3019
#include "version.h"
3120
#include "core.h"
3221
/*****************************************************************************/
@@ -40,6 +29,7 @@ namespace global {
4029
#endif
4130

4231
clsConfig config;
32+
bool blnPaused = false;
4333

4434
/** Holds Values that are related the the physics of the world,
4535
these are all based on real numbers */

src/screen.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ void clsScreen::setClips() {
330330
* +-----+
331331
* |(0,5)|
332332
* +-----+
333+
* |(0,6)|
334+
* +-----+
333335
*/
334336

335337
int pic_size = 24;
@@ -340,6 +342,7 @@ void clsScreen::setClips() {
340342
screen::screenatt.toolclips[ToolDele] = {0 * pic_size, 3 * pic_size, pic_size, pic_size};
341343
screen::screenatt.toolclips[ToolDrag] = {0 * pic_size, 4 * pic_size, pic_size, pic_size};
342344
screen::screenatt.toolclips[ToolInfo] = {0 * pic_size, 5 * pic_size, pic_size, pic_size};
345+
screen::screenatt.toolclips[ToolPause] = {0 * pic_size, 6 * pic_size, pic_size, pic_size};
343346

344347
}
345348
/*****************************************************************************/

src/screen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct stcWinAtt {
2828
SDL_Texture *pixel; /**< The pixel texture, used to draw lines */
2929
SDL_Texture *toolbox; /**< Toolbox frame texture. */
3030
SDL_Texture *tools; /**< Textures for the tools in the toolbox. */
31-
SDL_Rect toolclips[6]; /**< Clips for the different tools. */
31+
SDL_Rect toolclips[7]; /**< Clips for the different tools. */
3232
};
3333
/*****************************************************************************/
3434
typedef struct stcWinAtt WINATT;

src/toolbar.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ void clsToolbar::show() {
2222

2323
// Make SDL rect just for the tool picture inside the frame
2424
SDL_Rect tool_pic_box = {position_.x+2,position_.y+2,24,24};
25+
SDL_Rect pause_location = {screen::screenatt.width-24,2,24,24};
26+
27+
pause_location.x + 28;
28+
2529

2630
if(show_toolbox_) { // only show if enabled
2731
SDL_RenderCopy(screen::screenatt.ren,screen::screenatt.toolbox,
@@ -31,6 +35,10 @@ void clsToolbar::show() {
3135
SDL_RenderCopy(screen::screenatt.ren,screen::screenatt.tools,
3236
&screen::screenatt.toolclips[selected_tool_], &tool_pic_box);
3337

38+
if (global::blnPaused) {
39+
SDL_RenderCopy(screen::screenatt.ren,screen::screenatt.tools,
40+
&screen::screenatt.toolclips[ToolPause], &pause_location);
41+
}
3442
}
3543
}
3644
/*****************************************************************************/

src/version.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/*****************************************************************************/
1616
//Date Version Types
1717
/** The day of the last build of the program, currently not used. */
18-
#define DEFINED_VER_DATE "28"
18+
#define DEFINED_VER_DATE "29"
1919

2020
/** The month of the last build of the program, currently not used. */
2121
#define DEFINED_VER_MONTH "05"
@@ -37,13 +37,13 @@
3737
/*****************************************************************************/
3838
/** The version number in a format used by Boilerplate.rc, It is in the following format
3939
[MAJOR].[MINOR].[PATCH].[BUILDNUMBER] */
40-
#define DEFINED_VER_RC_FILEVERSION 1,4,1,3
40+
#define DEFINED_VER_RC_FILEVERSION 1,4,1,4
4141

4242
/** Is the same as DEFINED_VER_RC_FILEVERSION but is a null terminated string */
43-
#define DEFINED_VER_RC_FILEVERSION_STRING "1, 4, 1, 3\0"
43+
#define DEFINED_VER_RC_FILEVERSION_STRING "1, 4, 1, 4\0"
4444

4545
/** A more specific string of the file version */
46-
#define DEFINED_VER_FULLVERSION_STRING "1.4.1-beta.3\0"
46+
#define DEFINED_VER_FULLVERSION_STRING "1.4.1-rc.1\0"
4747

4848
//Software Status
4949
/**
@@ -55,10 +55,10 @@ Software Status can be the following:
5555
| Beta | b | This version will compile and / or run but does not work as expected (or crashes often). |
5656
| Alpha | a | This version does not work at all; it usually won't compile at all or crashes more times than it works; best not to use versions in this state. |
5757
*/
58-
#define DEFINED_VER_STATUS "Beta"
58+
#define DEFINED_VER_STATUS "Release Candidate"
5959

6060
/** See the table for DEFINED_VER_STATUS */
61-
#define DEFINED_VER_STATUS_SHORT "b"
61+
#define DEFINED_VER_STATUS_SHORT "rc"
6262
/// @}
6363
/*****************************************************************************/
6464
#endif //__VERSION_HEADER__

0 commit comments

Comments
 (0)