Skip to content

Commit

Permalink
Update 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
makuke1234 committed Jan 3, 2022
1 parent b8f51cd commit 0ca042c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PongD2D

![Release version](https://img.shields.io/badge/release-v1.2.0-green.svg)
![Release version](https://img.shields.io/badge/release-v1.3.0-green.svg)
![C version](https://img.shields.io/badge/version-C20-blue.svg)
![C++ version](https://img.shields.io/badge/version-C++20-blue.svg)

Expand All @@ -26,6 +26,10 @@ Windows binaries can be downloaded [here](https://github.com/makuke1234/PongD2D/

# Changelog

* 1.3.0
* Make scoring more engaging, points are given for whole game instead of the number
of bounces, game ends at 10 points

* 1.2.0
* Made ball movement more random/realistic
* Added random number generator, mt19937-like engine
Expand Down
19 changes: 15 additions & 4 deletions src/logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ DWORD WINAPI PongLogic_thread(LPVOID param)
else if (geoRel > D2D1_GEOMETRY_RELATION_DISJOINT)
{
logic->scoring.ballAngle = fmodf((float)M_PI - logic->scoring.ballAngle, 2.0f * (float)M_PI); // 180 - angle
++logic->scoring.leftScore;
float percentAngle = logic->scoring.absBall.x;
logic->scoring.absBall.x = PONG_WALL_X + PONG_BALL_X;
percentAngle = clamp(fabsf(logic->scoring.absBall.x - percentAngle) / PONG_BALL_X, 0.0f, 0.75f);
Expand Down Expand Up @@ -227,7 +226,6 @@ DWORD WINAPI PongLogic_thread(LPVOID param)
else if (geoRel > D2D1_GEOMETRY_RELATION_DISJOINT)
{
logic->scoring.ballAngle = fmodf((float)M_PI - logic->scoring.ballAngle, 2.0f * (float)M_PI); // 180 - angle
++logic->scoring.rightScore;
float percentAngle = logic->scoring.absBall.x;
logic->scoring.absBall.x = PONG_MINW - (PONG_WALL_X + PONG_BALL_X);
percentAngle = clamp(fabsf(logic->scoring.absBall.x - percentAngle) / PONG_BALL_X, 0.0f, 0.75f);
Expand Down Expand Up @@ -258,7 +256,7 @@ DWORD WINAPI PongLogic_thread(LPVOID param)
}
else if (geoRel > D2D1_GEOMETRY_RELATION_DISJOINT)
{
logic->scoring.winnerIdx = 1;
++logic->scoring.rightScore;
collides = true;
}

Expand All @@ -276,13 +274,26 @@ DWORD WINAPI PongLogic_thread(LPVOID param)
}
else if (geoRel > D2D1_GEOMETRY_RELATION_DISJOINT)
{
++logic->scoring.leftScore;
collides = true;
}
}

if (collides)
{
logic->scoring.mode = GameMode_gameOver;
if (logic->scoring.leftScore >= 10 || logic->scoring.rightScore >= 10)
{
if (logic->scoring.rightScore > logic->scoring.leftScore)
{
logic->scoring.winnerIdx = 1;
}
logic->scoring.mode = GameMode_gameOver;
}
else
{
PongLogic_calcAbsBall(logic);
logic->scoring.notPaused = false;
}
}

PongLogic_thread_release_rsc: ;
Expand Down
4 changes: 2 additions & 2 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

#define PONG_WALL_MAX ((PONG_MINH - PONG_WALL_Y) / 2.0f)

#define VERSION_STR "1.2.0"
#define VERSION_SEQ 1,2,0
#define VERSION_STR "1.3.0"
#define VERSION_SEQ 1,3,0


#endif
11 changes: 1 addition & 10 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,16 +700,7 @@ void PongWnd_onRender(PongWnd_t * restrict pong)
DWRITE_MEASURING_MODE_NATURAL
);

uint32_t lScore = pong->logic.scoring.leftScore;
uint32_t rScore = pong->logic.scoring.rightScore;
uint32_t maxScore = (pong->logic.scoring.winnerIdx == 1) ? rScore : lScore;

wsprintfW(
temp,
L"%s wins with a score: %u",
(pong->logic.scoring.winnerIdx == 1) ? L"Right" : L"Left",
maxScore
);
wsprintfW(temp, L"%s wins!", (pong->logic.scoring.winnerIdx == 1) ? L"Right" : L"Left");
dxRTDrawTextW(
(ID2D1RenderTarget *)pong->dx.pRT,
temp,
Expand Down

0 comments on commit 0ca042c

Please sign in to comment.