Skip to content

Commit 3d11f04

Browse files
committed
Update to v1.4.1-beta.3
## [1.4.1-beta.3] - Unreleased ### Added * Math function specifically to deal with vector math. ### Fixed * Spelling mistakes * Various Code mistakes * Drag tool not un-pausing correctly ### Changed * Updated Doxygen file * Info tool now displays if ball is paused
1 parent 4016670 commit 3d11f04

File tree

10 files changed

+243
-152
lines changed

10 files changed

+243
-152
lines changed

docs/ChangesLog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
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.2] - Unreleased
6+
## [1.4.1-beta.3] - Unreleased
77
### Added
88
* Math function specifically to deal with vector math.
99

1010
### Fixed
1111
* Spelling mistakes
12+
* Various Code mistakes
13+
* Drag tool not un-pausing correctly
14+
15+
### Changed
16+
* Updated Doxygen file
17+
* Info tool now displays if ball is paused
1218

1319
## [1.4.0-R] - 2018-03-27
1420
### Added

project/Physics-Simulator.cbp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@
164164
<Unit filename="../src/vector_math.h" />
165165
<Unit filename="../src/version.h" />
166166
<Extensions>
167-
<code_completion />
168-
<envvars />
169-
<debugger />
170-
<lib_finder disable_auto="1" />
171167
<DoxyBlocks>
172168
<comment_style block="5" line="0" />
173169
<doxyfile_project project_number="v1.4.0-R" output_directory="gh-pages" />
@@ -177,6 +173,7 @@
177173
<doxyfile_dot class_diagrams="1" have_dot="1" />
178174
<general use_at_in_tags="1" />
179175
</DoxyBlocks>
176+
<lib_finder disable_auto="1" />
180177
</Extensions>
181178
</Project>
182179
</CodeBlocks_project_file>

project/doxygen/Doxyfile

Lines changed: 188 additions & 116 deletions
Large diffs are not rendered by default.

src/cannonball.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ void clsCannonball::update(double newdeltat) {
163163

164164
double total_v;
165165
total_v = math::getVectorLength(vel_);
166-
if (total_v < global::physics::kMinVelocity || isnan(total_v) ) {
166+
if (total_v < global::physics::kMinVelocity || std::isnan(total_v) ) {
167167
blnstarted_ = false;
168168
if (global::blnDebugMode) {
169-
if ( isnan(total_v) ) { printf("Ball velocity is NaN; killing it.\n"); }
169+
if ( std::isnan(total_v) ) { printf("Ball velocity is NaN; killing it.\n"); }
170170
else { printf("Ball moving too slow; killing it.\n"); }
171171
} //end if debug mode
172172
} //end if should kill
@@ -385,6 +385,11 @@ void clsCannonball::writeInfo() {
385385
printf("Velocity: \t \t (%5.5f, %5.5f)\n",vel_.x,vel_.y);
386386
printf("Acceleration: \t \t (%5.5f, %5.5f)\n",acc_.x,acc_.y);
387387
printf("Forces: \t \t (%5.5f, %5.5f)\n", forces_.x, forces_.y);
388+
if (paused_) {
389+
printf("Ball is paused.\n");
390+
} else {
391+
printf("Ball is not paused.\n");
392+
}
388393

389394
}
390395
/*****************************************************************************/

src/cannonball.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <cstdlib>
66
#include <vector>
77
#include <time.h>
8+
#include <cmath>
89
#include "screen.h"
910
/*****************************************************************************/
1011
/////////////////////////////////////////////////

src/core.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void cannonballs::addNew(LOC mouseC, LOC mouseO, double HoldTime ) {
5757
mouseO.y = global::config.values.uintScreenHeight - mouseO.y;
5858
intCannonBallNum++;
5959
clsCannonball tempBall;
60-
tempBall.setValues(radius, mouseO,fire_v, angle, intCannonBallNum);
60+
tempBall.setValues(radius, mouseO, fire_v, angle, intCannonBallNum);
6161
if (intCannonBallNum > 1) {
6262
if(balls[0].isPaused()) { tempBall.togglePause(); }
6363
}
@@ -85,8 +85,9 @@ void cannonballs::checkCollisons(uint j) {
8585
B = balls[i].getBOX();
8686
if ( checkOverlap(A, B) ) {
8787
doCollide(j, i);
88-
/* ball_b_loc = balls[i].getdbLOC();
89-
do {
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 {
9091
ball_b_loc.x++;
9192
ball_b_loc.y++;
9293
balls[i].setdbLOC(ball_b_loc);
@@ -243,7 +244,7 @@ void cannonballs::doCollide(uint numA, uint numB) {
243244
break;
244245
case CollideInelastic:
245246
//uses the same equations as below but some energy is lost.
246-
247+
247248
TotalAMomentum = math::vectorMul(TotalAMomentum,
248249
(double)global::physics::kCoefficientRestitution);
249250
TotalBMomentum = math::vectorMul(TotalAMomentum,
@@ -329,6 +330,7 @@ void core::fireRandom() {
329330
LOC mouseo, mousec;
330331
// time delay can be anywhere from 0.25 to 10 seconds
331332
double time_delay = ((rand() % (10000-250) + 250) / 1000);
333+
if (time_delay <= 0.25) { time_delay = 0.25; }
332334

333335
mouseo.x = rand() % cnfg.uintScreenWidth;
334336
mouseo.y = rand() % cnfg.uintScreenHeight;
@@ -361,8 +363,8 @@ char core::handleEvent(SDL_Event* e ) {
361363
if ( e->type == SDL_QUIT ) { return 'q'; }
362364

363365
if ( e->type == SDL_MOUSEBUTTONDOWN || e->type == SDL_MOUSEBUTTONUP ) {
364-
if (e->type == SDL_MOUSEBUTTONDOWN) {holding = true;}
365-
else if (e->type == SDL_MOUSEBUTTONUP) {holding = false;}
366+
if (e->type == SDL_MOUSEBUTTONDOWN) { holding = true; }
367+
else if (e->type == SDL_MOUSEBUTTONUP) { holding = false; }
366368
// there is a mouse-based event, so now we have to check what tool we are using.
367369
//if (global::blnDebugMode) { printf("Mouse event found.\n"); }
368370
switch ( toolbar.getTool() ) {
@@ -500,7 +502,7 @@ void core::doDeleTool(SDL_Event* e) {
500502
if( e->type == SDL_MOUSEBUTTONDOWN ){
501503
SDL_GetMouseState(&currentmouse.x, &currentmouse.y);
502504
ball_num = findSelectedBall(currentmouse);
503-
if (ball_num == -1) {return;}
505+
if (ball_num == -1) { return; }
504506
cannonballs::balls[ball_num].blnstarted_ = false;
505507
}
506508
}
@@ -534,7 +536,7 @@ void core::doDragTool(SDL_Event* e) {
534536
if (e->type == SDL_MOUSEBUTTONDOWN) { ball_num = findSelectedBall(currentmouse); }
535537
//else if (e->type == SDL_MOUSEBUTTONUP) { ball_num = -1; }
536538

537-
if (ball_num == -1) {return;}
539+
if (ball_num == -1) { return; }
538540

539541
if (e->type == SDL_MOUSEMOTION && holding) {
540542
currentmouse.y = global::config.values.uintScreenHeight - currentmouse.y;
@@ -544,14 +546,21 @@ void core::doDragTool(SDL_Event* e) {
544546
//if(global::blnDebugMode) { printf("Tool Drag event\n"); }
545547
if ( holding && !(cannonballs::balls[ball_num].isPaused()) ) {
546548
cannonballs::balls[ball_num].togglePause();
547-
} else if (!(holding) && cannonballs::balls[ball_num].isPaused()
548-
&& !(cannonballs::balls.back().isPaused()) &&
549-
!(cannonballs::balls.front().isPaused())) {
550-
// will only unpause the dragged ball if the other balls are also
551-
// unpaused. I check the first and last balls to avoid the chance
552-
// that the selected ball is the first or last.
553-
cannonballs::balls[ball_num].togglePause();
554-
ball_num = -1;
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+
}
555564
}
556565
}
557566
/*****************************************************************************/

src/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ int main(int argc, char *argv[]) {
171171
} while (!quit); //keep looping until we get a quit
172172

173173
// clear vectors is not empty
174-
if(!cannonballs::ropes.empty()) {cannonballs::ropes = VectorRope();}
175-
if(global::blnDebugMode) {printf("Ropes cleared.\n");}
174+
if(!cannonballs::ropes.empty()) { cannonballs::ropes = VectorRope(); }
175+
if(global::blnDebugMode) { printf("Ropes cleared.\n"); }
176176

177-
if(!cannonballs::balls.empty()) {cannonballs::balls = VectorCannon();}
178-
if(global::blnDebugMode) {printf("Balls cleared.\n");}
177+
if(!cannonballs::balls.empty()) { cannonballs::balls = VectorCannon(); }
178+
if(global::blnDebugMode) { printf("Balls cleared.\n"); }
179179
return 0;
180180
}
181181
/*****************************************************************************/

src/rope.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ dblXY clsRope::ballWallForces(dblXY ball_one_forces, double angle) {
173173
if (angle == M_PI / 2 || angle == 3/2 * M_PI ) {
174174
tension.x = 0;
175175
tension.y = ball_one_forces.y;
176-
if (!(signbit((double)spot_.one.y-(double)spot_.two.y) ^ signbit(ball_one_forces.y))) {
176+
if (!(std::signbit((double)spot_.one.y-(double)spot_.two.y) ^ std::signbit(ball_one_forces.y))) {
177177
// force and direction to spot two are both positive or both negative, therefore
178178
// reverse the force for tension
179179
tension.y *= -1;
@@ -187,7 +187,7 @@ dblXY clsRope::ballWallForces(dblXY ball_one_forces, double angle) {
187187
} else {
188188
tension.y = 0;
189189
tension.x = ball_one_forces.x;
190-
if ((signbit((double)spot_.one.x-(double)spot_.two.x) ^ signbit(ball_one_forces.x))) {
190+
if ((std::signbit((double)spot_.one.x-(double)spot_.two.x) ^ std::signbit(ball_one_forces.x))) {
191191
// force and direction to spot two are both positive or both negative, therefore
192192
// reverse the force for tension
193193
tension.x *= -1;

src/vector_math.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __VECTOR_MATH_HEADER__
33
/*****************************************************************************/
44
#include <math.h>
5+
#include <cmath>
56
#include "global.h"
67
/*****************************************************************************/
78
/////////////////////////////////////////////////

src/version.h

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

2020
/** The month of the last build of the program, currently not used. */
21-
#define DEFINED_VER_MONTH "03"
21+
#define DEFINED_VER_MONTH "05"
2222

2323
/** The year of the last build of the program, currently not used. */
24-
#define DEFINED_VER_YEAR "2019"
24+
#define DEFINED_VER_YEAR "2020"
2525

2626
/** The Ubuntu style of the date of the last build. It is in YY.MM format. */
27-
#define DEFINED_VER_UBUNTU_VERSION_STYLE "19.03"
27+
#define DEFINED_VER_UBUNTU_VERSION_STYLE "20.05"
2828
/*****************************************************************************/
2929
/** The Major number of the version number */
3030
#define DEFINED_VER_MAJOR 1
@@ -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,2
40+
#define DEFINED_VER_RC_FILEVERSION 1,4,1,3
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, 2\0"
43+
#define DEFINED_VER_RC_FILEVERSION_STRING "1, 4, 1, 3\0"
4444

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

4848
//Software Status
4949
/**

0 commit comments

Comments
 (0)