Skip to content

Commit 586b5e7

Browse files
author
Patrick Rye
committed
Update to v1.2.4-beta
21 September 2015 Released version 1.2.4-Beta Change log: -Added: Balls are different colors -Changed: Ball ID is now set in Screen set -Changed: Unrealistic method added in 1.1.9-Beta can be toggled easier (with define) Its funny to enable and watch even if it doesn't do what it is supposed to
1 parent 105c6b9 commit 586b5e7

File tree

6 files changed

+59
-21
lines changed

6 files changed

+59
-21
lines changed

ChangesLog.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
21 September 2015
2+
Released version 1.2.4-Beta
3+
4+
Change log:
5+
-Added: Balls are different colors
6+
-Changed: Ball ID is now set in Screen set
7+
-Changed: Unrealistic method added in 1.1.9-Beta can be toggled easier (with define)
8+
Its funny to enable and watch even if it doesn't do what it is supposed to
9+
110
21 September 2015
211
Released version 1.2.3-Beta
312

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,22 @@ The first time you run the program a Config.ini will be created it should look s
3535

3636
```
3737
Config File for the Cannon.exe
38-
1.2.0.25-b
38+
1.2.4.60-b
3939
Screen Width: 640
4040
Screen Height: 480
4141
Log Ball's path: 0
4242
Enable Drag Mode (experimental): 0
43+
Draw Ball path on screen: 0
4344
```
4445

4546
You can use this to change things like the screen height and width, and other stuff.
4647

4748
"Log Ball's Path" (if enabled with a 1 instead of 0), will cause a a file called "logfile.log", which will contain the placement of every ball on every update (it gets quite big as you can guess).
4849

4950
"Enable drag Mode" (if enabled with a 1 instead of 0), will cause the cannonballs to be effected by drag. It is listed as experimental because I based the equations used off of several things I found
50-
online and I cannot verify how accuate it is.
51+
online and I cannot verify how accurate it is.
52+
53+
"Draw Ball path on Screen" (if enabled with a 1 instead of 0), will cause small pixels to trail after each ball.
5154

5255
Once you start the program you will be greeted with a beautiful white screen. To create a new cannonball you click (and hold down the button)
5356
you can now move your move around to change the angle that the new cannonball will be fired at; as well as the longer the line the faster it will go.

src/cannonball.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ void clsCannonball::update(double newdeltat) {
111111
show();
112112
}
113113
/**********************************************************************************************************************************************/
114-
void clsCannonball::setSDLScreen(SDL_Texture* SDLball, SDL_Texture* SDLpxel, WINATT SDLwindow) {
114+
void clsCannonball::setSDLScreen(SDL_Texture* SDLball, SDL_Texture* SDLpxel, WINATT SDLwindow, uint newID) {
115+
ballID = newID;
116+
//set the color of the ball
117+
//Set some ID's to have specific colors, but otherwise randomize them
118+
Color.Red = rand() % 255;
119+
Color.Green = rand() % 255;
120+
Color.Blue = rand() % 255;
121+
115122
ball = SDLball;
116123
pixel = SDLpxel;
117124
SDL_QueryTexture(ball,NULL,NULL, &Screen_place.w, &Screen_place.h);
@@ -133,12 +140,18 @@ void clsCannonball::show() {
133140

134141
//set the ball alpha
135142
SDL_SetTextureAlphaMod(ball, alpha);
143+
SDL_SetTextureColorMod(ball, Color.Red, Color.Green, Color.Blue);
136144

137145
//Place the ball
138146
SDL_RenderCopy(window.ren,ball,NULL,&Screen_place);
147+
148+
//reset ball Alpha and color so it doesn't effect the next ball
149+
SDL_SetTextureAlphaMod(ball, 0xFF);
150+
SDL_SetTextureColorMod(ball, 0xFF, 0xFF, 0xFF);
151+
139152
}
140153
/**********************************************************************************************************************************************/
141-
void clsCannonball::setValues(double r, LOC init_place, double init_vel, double init_angle, uint ID) {
154+
void clsCannonball::setValues(double r, LOC init_place, double init_vel, double init_angle) {
142155
props.radius = r; //in meters
143156

144157
acc.x = 0.00;
@@ -150,8 +163,6 @@ void clsCannonball::setValues(double r, LOC init_place, double init_vel, double
150163

151164
vel.x = (double)(init_vel) * (cos(init_angle));
152165
vel.y = (double)(init_vel) * (sin(init_angle));
153-
154-
ballID = ID;
155166
blnstarted = true;
156167

157168
Drag_calcvalues();
@@ -193,6 +204,7 @@ void clsCannonball::drawPath(LOC newplace) {
193204

194205
//If there have been enough updates since the last time the path was updated,
195206
//then update the path array otherwise inc updates
207+
SDL_SetTextureColorMod(pixel, Color.Red, Color.Green, Color.Blue);
196208
if ( UpdatesSinceLast >= 25 ) {
197209
UpdatesSinceLast = 0;
198210
//First move all the old locations down one spot in the array
@@ -208,5 +220,6 @@ void clsCannonball::drawPath(LOC newplace) {
208220
dst.x = (uint)(path[i].x + Screen_place.w / 2);
209221
SDL_RenderCopy(window.ren, pixel, NULL, &dst);
210222
} //end for
223+
SDL_SetTextureColorMod(pixel, 0xFF, 0xFF, 0xFF);
211224
}
212225
/**********************************************************************************************************************************************/

src/cannonball.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <math.h>
66
#include <cstdio>
77
#include <cstdlib>
8+
//#include <time.h>
89
#include "config.h"
910
#include "global.h"
1011
#include "screen.h"
@@ -32,20 +33,27 @@ struct stcBox {
3233
uint bottom;
3334
};
3435

36+
struct stcColor {
37+
Uint8 Red;
38+
Uint8 Green;
39+
Uint8 Blue;
40+
};
41+
3542
typedef struct stcDoubleValues dblXY;
3643
typedef struct stcPhysicalProperties PP;
3744
typedef struct stcBox BOX;
45+
typedef struct stcColor clr;
3846
/**********************************************************************************************************************************************/
3947
class clsCannonball {
4048
public:
4149
/** Default constructor */
4250
clsCannonball();
43-
void setValues(double, LOC, double, double, uint);
51+
void setValues(double, LOC, double, double);
4452
LOC getplace(void);
4553
void setplace(LOC);
4654

4755
void update(double);
48-
void setSDLScreen(SDL_Texture*, SDL_Texture*, WINATT);
56+
void setSDLScreen(SDL_Texture*, SDL_Texture*, WINATT, uint);
4957
dblXY getVelocity(void);
5058
void setVelocity(dblXY);
5159
PP getPhysicalProps(void);
@@ -56,7 +64,7 @@ class clsCannonball {
5664
private:
5765
uint ballID;
5866
bool blnDragEnabled;
59-
67+
clr Color;
6068
SDL_Texture* ball;
6169
SDL_Texture* pixel;
6270
WINATT window;

src/main.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* FIXME (GamerMan7799#1#): The balls will become stuck together for seemingly random reasons */
2-
/* TODO (GamerMan7799#1#): Balls are different colors based on their IDS */
2+
/* TODO (GamerMan7799#5#): Collision Method can be set in Config */
3+
/* TODO (GamerMan7799#9#): Allow setting of same Physics Values in Config */
34
/**********************************************************************************************************************************************************************/
45
#include <SDL2/SDL.h>
56
#include <cstdio>
@@ -41,7 +42,7 @@ namespace Global {
4142
const float fMinVelocity = 0.0; //If a ball has less velocity than the it will "die"
4243
const float fCoefficientRestitution = 0.76; //How much total energy remains after a collision
4344
//(see https://en.wikipedia.org/wiki/Coefficient_of_restitution for more info)
44-
const uchar CollisionMethod = CollideInelastic;
45+
const uchar CollisionMethod = CollideInelastic; //The collision method to use (see above)
4546
}
4647

4748
namespace Equations { //Holds Values for different equations that are not physics related
@@ -55,6 +56,8 @@ namespace Global {
5556
/**********************************************************************************************************************************************************************/
5657
//This is the maximum number of cannonballs which can be "alive" at a time
5758
#define DEFINED_CANNONBALL_LIMIT 20
59+
//IF this is not commented out then program will use unrealistic method that will increase velocity the closer they are together
60+
//#define DEFINED_USE_R2_VEL_MODDER
5861
/**********************************************************************************************************************************************************************/
5962
clsCannonball Cannonballs[DEFINED_CANNONBALL_LIMIT];
6063
/**********************************************************************************************************************************************************************/
@@ -72,7 +75,7 @@ int main(int argc, char *argv[]) {
7275

7376
//Since all the Cannonballs will share the same SDL screen stuff place them all together
7477
for (uint i = 0; i < DEFINED_CANNONBALL_LIMIT; i++) {
75-
Cannonballs[i].setSDLScreen( CannonWindow.getBallTexture(), CannonWindow.getPixelTexture(), CannonWindow.getWindow() );
78+
Cannonballs[i].setSDLScreen( CannonWindow.getBallTexture(), CannonWindow.getPixelTexture(), CannonWindow.getWindow(), i );
7679
}
7780

7881
bool quit = false;
@@ -160,7 +163,7 @@ void addNewCannonball(LOC mouseC, LOC mouseO, double HoldTime ) {
160163
//loop through array to find next available cannonball slot
161164
for (uint i = 0; i < DEFINED_CANNONBALL_LIMIT; i++) {
162165
if (!Cannonballs[i].blnstarted) {
163-
Cannonballs[i].setValues(radius, mouseO, fire_v, angle, i);
166+
Cannonballs[i].setValues(radius, mouseO, fire_v, angle);
164167
return;
165168
} //end if not started
166169
} //end for cannonballs.
@@ -199,9 +202,10 @@ void doCollision(uint numA, uint numB) {
199202
Aprops = Cannonballs[numA].getPhysicalProps();
200203
Bprops = Cannonballs[numB].getPhysicalProps();
201204

205+
#ifdef DEFINED_USE_R2_VEL_MODDER
202206
//This part here has no actual basis on real life,
203207
//it is just my attempt at preventing the cannonballs from sticking together
204-
/*LOC CenterA, CenterB, DeltaCenters;
208+
LOC CenterA, CenterB, DeltaCenters;
205209
double VelModder;
206210
CenterA = Cannonballs[numA].getplace();
207211
CenterB = Cannonballs[numB].getplace();
@@ -216,8 +220,9 @@ void doCollision(uint numA, uint numB) {
216220
Avel.x *= (double) VelModder;
217221
Avel.y *= (double) VelModder;
218222
Bvel.x *= (double) VelModder;
219-
Bvel.y *= (double) VelModder;*/
223+
Bvel.y *= (double) VelModder;
220224
//End of non real stuff
225+
#endif
221226

222227
double Aangle, Bangle, ContactAngle;
223228
double Atotal_v, Btotal_v;

src/version.h

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

2020
//Miscellaneous Version Types
21-
#define DEFINED_VER_BUILDS_COUNT 20
22-
#define DEFINED_VER_RC_FILEVERSION 1,2,3,60
23-
#define DEFINED_VER_RC_FILEVERSION_STRING "1, 2, 3, 60\0"
24-
#define DEFINED_VER_FULLVERSION_STRING "1.2.3.60"
21+
#define DEFINED_VER_BUILDS_COUNT 25
22+
#define DEFINED_VER_RC_FILEVERSION 1,2,4,61
23+
#define DEFINED_VER_RC_FILEVERSION_STRING "1, 2, 4, 61\0"
24+
#define DEFINED_VER_FULLVERSION_STRING "1.2.4.61"
2525

2626
//These values are to keep track of your versioning state, don't modify them.
2727
#define DEFINED_VER_BUILD_HISTORY 1

0 commit comments

Comments
 (0)