Skip to content

Commit 1015b47

Browse files
committed
Final bugfixes
Fullscreen mode (Borderless) New AI version
1 parent f80e667 commit 1015b47

File tree

6 files changed

+150
-62
lines changed

6 files changed

+150
-62
lines changed

installer/ShipBattle.aip renamed to ShipBattle.aip

+67-29
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
11
[Setup]
2-
AIVersion=8.2
2+
AIVersion=9.3
33
AIEdition=0
44
GUID={6D782483-B6AC-498E-AB2F-172813AEEF05}
55
AppName=Ship Battle
6-
AppVersion=1.0
6+
AppVersion=1.1
77
AppDescription=Play a classic ship battle against the computer
88
CompanyName=Ludwig Füchsl
99
WebSite=https://github.com/Ohjurot
1010
SupportLink=https://github.com/Ohjurot
1111
InstallLevel=3
1212
UpgradeMode=0
13-
IfInstalled=0
13+
IfInstalled=2
1414
RunAsAdmin=1
1515
Windows 10=1
16+
Windows 11=1
1617
SystemType=1
1718
Internet=0
1819
CloseApp=0
1920
CloseAppFile=File.exe
2021
CloseAppText=App Name
2122
VisualCpp=1
22-
VisualCppVersion=5
23+
VisualCppVersion=6
2324
LinkVisualCpp=https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
2425
PackageType=0
25-
SetupFolder=D:\Dev\cpp\speedcoding\ShipBattle
26-
SetupFileName=ShipBattle_V1_0_Setup
26+
SetupFolder=F:\Dev\30_OpenSource\ShipBattle
27+
SetupFileName=ShipBattle_V1_1_Setup
2728
IconFile=Default
28-
SourceDir=D:\Dev\cpp\speedcoding\ShipBattle\dist
29+
SourceDir=
2930
InstallDir=<ProgramFiles>\<AppName>
3031
MainExe=<InstallDir>\ShipBattle.exe
3132
ProgramGroup=<AppName>
3233
Uninstall=1
3334
ShowAddRemove=1
35+
ProductIcon=0
3436
SilentUninstall=0
3537
UninstallForce=0
3638
UninstallRestart=0
@@ -63,12 +65,11 @@ AltInstallDir=<ProgramFiles>\<AppName>
6365
DataExtractParam=-o"<InstallDir>" -aoa
6466
UninstallFileName=Uninstall.exe
6567
LangIDMethod=0
66-
AllowInstallIfNoSpace=0
6768
AllowInstallIfPrereqFailed=0
6869
SetupParameters=
6970
Theme=1
70-
WizardBitmap=<AIDir>\Bitmaps\Wizard\02.bmp
71-
HeaderBitmap=<AIDir>\Bitmaps\Header\03.bmp
71+
WizardBitmap=<AIDir>\Bitmaps\Wizard\New.bmp
72+
HeaderBitmap=<AIDir>\Bitmaps\Header\New.bmp
7273
LogoBitmap=<AIDir>\Bitmaps\Logo\01.bmp
7374
DialogWelcome=1
7475
DialogLicense=1
@@ -81,30 +82,37 @@ DialogFinish=1
8182
ShowPublisher=1
8283
HideFileNames=0
8384
Beep=0
84-
License=D:\Dev\cpp\speedcoding\ShipBattle\installer\LICENSE.txt
85+
License=installer\LICENSE.txt
8586
Readme=
8687
AcceptAgreement=1
8788
Languages=English,
8889
DefaultLanguage=English
8990
AutoDetectLanguage=0
90-
InfoUserName=0
91-
InfoUserNameReq=0
92-
InfoCompany=0
93-
InfoCompanyReq=0
94-
InfoCustom=0
95-
InfoCustomReq=0
96-
InfoCustomName=
97-
InfoCustomType=0
98-
InfoSerial=0
99-
InfoSerialReq=0
100-
SerialsCount=0
91+
HideOtherLanguages=0
92+
QueryText=0
93+
QueryTextName=
94+
QueryTextReq=0
95+
QueryTextHide=0
96+
QueryCustom=0
97+
QueryCustomName=
98+
QueryCustomReq=0
99+
QueryCustomHide=0
100+
QueryCustomType=0
101+
QueryCustomMustExists=0
102+
QueryKey=0
103+
QueryKeyName=
104+
QueryKeyReq=0
105+
QueryKeyHide=0
106+
QueryKeyHideReg=0
107+
KeysCount=0
101108
InfoCustomBox=0
102109
InfoCustomBoxReq=0
103110
InfoCustomBoxName=
104111
CustomComboBox=0
105112
CustomComboBoxName=
106113
CustomComboBoxItems=
107114
CustomComboDefItem=
115+
ComboBoxDisableOnUpgrade=0
108116
CustomComponents=0
109117
CustomComponentsText=
110118
CustomComponentsDesc=
@@ -117,19 +125,27 @@ LaunchFile=1
117125
LaunchFileName=<InstallDir>\ShipBattle.exe
118126
LaunchFileChecked=1
119127
LaunchFileAdmin=0
128+
FinishCurrentDir=1
120129
CustomAction=0
121130
CustomActionName=Visit Web Site
122131
CustomActionCommand=<WebSite>
123132
CustomActionChecked=0
124133
CustomActionAdmin=0
125-
FinishCurrentDir=1
126-
TotalFiles=1
134+
TotalFiles=23
135+
SourceDirFiles=0
136+
SourceDirSize=0
127137

128138
[GUI]
139+
FontName=Tahoma
140+
LogoMode=1
141+
LogoOffset=0
142+
LogoIconSize=2
143+
Theme=0
144+
LogoAlignClient=1
129145
LogoAutoSize=0
130-
LogoTransparent=0
131146
LogoStretch=0
132147
LogoProportional=0
148+
LogoTransparent=0
133149

134150
[Options]
135151
OptionUpdateFileVersion=0
@@ -142,16 +158,38 @@ OptionExcludeHiddenFiles=1
142158
OptionExcludeEmptyFolders=1
143159
OptionExcludeExtensions=
144160
OptionNoTreeView=0
145-
OptionRelativePath=0
161+
OptionRelativePath=1
146162
OptionSignFile=0
147163
OptionSignFileAll=0
148164
OptionSignCommand=/K signtool sign /f MyCert.pfx "<SetupExe>"
149165

150166
[Files]
151167
0=<AIDir>\Uninstall.exe?<InstallDir>\Uninstall.exe?1?1
168+
1=installer\LICENSE.txt?<InstallDir>\LICENSE.txt?1?1
169+
2=bin\Release\ShipBattle.exe?<InstallDir>\ShipBattle.exe?1?1
170+
3=bin\Release\shader\ImageQuadPS.cso?<InstallDir>\shader\ImageQuadPS.cso?1?1
171+
4=bin\Release\shader\ImageQuadVS.cso?<InstallDir>\shader\ImageQuadVS.cso?1?1
172+
5=bin\Release\shader\RootSignature.cso?<InstallDir>\shader\RootSignature.cso?1?1
173+
6=bin\res\screen_play.png?<InstallDir>\res\screen_play.png?1?1
174+
7=bin\res\screen_start.png?<InstallDir>\res\screen_start.png?1?1
175+
8=bin\res\stat_game_lost.png?<InstallDir>\res\stat_game_lost.png?1?1
176+
9=bin\res\stat_game_win.png?<InstallDir>\res\stat_game_win.png?1?1
177+
10=bin\res\stat_hit.png?<InstallDir>\res\stat_hit.png?1?1
178+
11=bin\res\stat_nohit.png?<InstallDir>\res\stat_nohit.png?1?1
179+
12=bin\res\stat_place_fleet.png?<InstallDir>\res\stat_place_fleet.png?1?1
180+
13=bin\res\stat_place_shot.png?<InstallDir>\res\stat_place_shot.png?1?1
181+
14=bin\res\stat_shot_traveling.png?<InstallDir>\res\stat_shot_traveling.png?1?1
182+
15=bin\res\stat_wait_enemy.png?<InstallDir>\res\stat_wait_enemy.png?1?1
183+
16=bin\res\tilemap.png?<InstallDir>\res\tilemap.png?1?1
184+
17=bin\res\tr0.bad?<InstallDir>\res\tr0.bad?1?1
185+
18=bin\res\tr1.bad?<InstallDir>\res\tr1.bad?1?1
186+
19=bin\res\tr2.bad?<InstallDir>\res\tr2.bad?1?1
187+
20=bin\res\tr3.bad?<InstallDir>\res\tr3.bad?1?1
188+
21=bin\res\tr4.bad?<InstallDir>\res\tr4.bad?1?1
189+
22=bin\res\tr5.bad?<InstallDir>\res\tr5.bad?1?1
152190

153191
[Shortcuts]
154-
0=<ProgramGroup>*?<AppName>*?<InstallDir>\ShipBattle.exe*?*?*?<InstallDir>*?*?0*?Normal
155-
1=<Desktop>*?<AppName>*?<InstallDir>\ShipBattle.exe*?*?*?<InstallDir>*?*?0*?Normal
156-
2=<ProgramGroup>*?Uninstall <AppName>*?<InstallDir>\Uninstall.exe*?*?*?<InstallDir>*?*?0*?Normal
192+
0=<ProgramGroup>*?<AppName>*?<InstallDir>\ShipBattle.exe*?*?*?<InstallDir>*?*?0*?Normal*?No
193+
1=<Desktop>*?<AppName>*?<InstallDir>\ShipBattle.exe*?*?*?<InstallDir>*?*?0*?Normal*?No
194+
2=<ProgramGroup>*?Uninstall <AppName>*?<InstallDir>\Uninstall.exe*?*?*?<InstallDir>*?*?0*?Normal*?No
157195

src/game/tools/ShipFunctions.cpp

+35-31
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
bool ShipFunctions::shipCheckBounds(Ship* ptrShip) {
55
if (ptrShip->isVertical) {
6-
return ((ptrShip->posy + ptrShip->length) < 10);
6+
return ((ptrShip->posy + ptrShip->length) <= 10);
77
}
88
else {
9-
return ((ptrShip->posx + ptrShip->length) < 10);
9+
return ((ptrShip->posx + ptrShip->length) <= 10);
1010
}
1111
}
1212

@@ -45,35 +45,8 @@ bool ShipFunctions::shipCheckCollision(Ship* arrShips, Ship* checker, unsigned i
4545
Ship* otherShip = &arrShips[i];
4646

4747
// Only for other ships
48-
if (i != index) {
49-
// Overlap [Vertical | Vertical]
50-
if (otherShip->isVertical && placeShip->isVertical &&
51-
otherShip->posx == placeShip->posx &&
52-
((placeShip->posy + placeShip->length >= otherShip->posy) || (otherShip->posy + otherShip->length >= placeShip->posy))
53-
) {
54-
return false;
55-
}
56-
// Overlap [Horizontal | Horizontal]
57-
if (!otherShip->isVertical && !placeShip->isVertical &&
58-
otherShip->posy == placeShip->posy &&
59-
((placeShip->posx + placeShip->length >= otherShip->posx) || (otherShip->posx + otherShip->length >= placeShip->posx))
60-
) {
61-
return false;
62-
}
63-
// Crossing other Vertical
64-
if (otherShip->isVertical &&
65-
((placeShip->posx <= otherShip->posx) && ((placeShip->posx + placeShip->length) >= otherShip->posx)) &&
66-
((otherShip->posy <= placeShip->posy) && ((otherShip->posy + otherShip->length) >= placeShip->posy))
67-
) {
68-
return false;
69-
}
70-
// Crossing this Vertical
71-
if (placeShip->isVertical &&
72-
((otherShip->posx <= placeShip->posx) && ((otherShip->posx + otherShip->length) >= placeShip->posx)) &&
73-
((placeShip->posy <= otherShip->posy) && ((placeShip->posy + placeShip->length) >= otherShip->posy))
74-
) {
75-
return false;
76-
}
48+
if (i != index && shipIntersect(placeShip, otherShip)) {
49+
return false;
7750
}
7851
}
7952

@@ -150,3 +123,34 @@ void ShipFunctions::drawShips(Ship* arrShips, unsigned int count, QuadManger& ma
150123
}
151124
}
152125
}
126+
127+
bool ShipFunctions::shipIntersect(Ship* s1, Ship* s2)
128+
{
129+
// Line 1
130+
int l1x1 = s1->posx;
131+
int l1y1 = s1->posy;
132+
int l1x2 = s1->isVertical ? l1x1 : s1->posx + s1->length - 1;
133+
int l1y2 = s1->isVertical ? s1->posy + s1->length - 1 : l1y1;
134+
135+
// Line 2
136+
int l2x1 = s2->posx;
137+
int l2y1 = s2->posy;
138+
int l2x2 = s2->isVertical ? l2x1 : s2->posx + s2->length - 1;
139+
int l2y2 = s2->isVertical ? s2->posy + s2->length - 1 : l2y1;
140+
141+
/*
142+
* Intersection test seen as AABB
143+
*
144+
* cs yo Conditions (or):
145+
* xo a ------ o 1) b2 > a1
146+
* | s1 | 2) a2 > b1
147+
* | |
148+
* o ------ b xo
149+
* yo cs
150+
*/
151+
152+
// cs xo yo
153+
if ((l2x2 < l1x1 && l2y2 < l1y1) || (l2x1 < l1x1 && l2x2 < l1x1) || (l2y1 < l1y1 && l2y2 < l1y1)) return false;
154+
if ((l2x1 > l1x2 && l2y1 > l1y2) || (l2x1 > l1x2 && l2x2 > l1x2) || (l2y1 > l1y2 && l2y2 > l1y2)) return false;
155+
return true;
156+
}

src/game/tools/ShipFunctions.h

+2
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ class ShipFunctions {
1515
static void randomShips(Ship* arrShips, unsigned int count);
1616
static void drawShip(Ship* ship, QuadManger& manager);
1717
static void drawShips(Ship* arrShips, unsigned int count, QuadManger& manager);
18+
19+
static bool shipIntersect(Ship* s1, Ship* s2);
1820
};

src/gfx/GWindow.cpp

+41-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "GWindow.h"
33

44
GWindow::GWindow(EasyHWND::WindowClass& wClass, ID3D12Device* ptrDevice, ID3D12CommandQueue* ptrQueue)
5-
: EasyHWND::Window(wClass, L"Ship Battle V1.0 © Copyright 2021 by Ludwig Füchsl", 100, 100, 960, 540, WS_OVERLAPPEDWINDOW, WS_EX_OVERLAPPEDWINDOW),
5+
: EasyHWND::Window(wClass, L"Ship Battle V1.1", 100, 100, 960, 540, WS_OVERLAPPEDWINDOW, WS_EX_OVERLAPPEDWINDOW | WS_EX_APPWINDOW),
66
m_iostate({})
77
{
88
HRESULT hr;
@@ -115,6 +115,9 @@ bool GWindow::handleWindowMessage(LRESULT* ptrLRESULT, HWND hwnd, UINT msg, WPAR
115115
if (wParam == VK_RETURN) {
116116
m_iostate.enterIsDown = TRUE;
117117
}
118+
else if (wParam == VK_F11) {
119+
setFullscreen(!m_fullscreen);
120+
}
118121
break;
119122
}
120123

@@ -242,6 +245,43 @@ GameIOState GWindow::getCurrentIOState() {
242245
return m_iostate;
243246
}
244247

248+
void GWindow::setFullscreen(bool fullscreen)
249+
{
250+
// New styles
251+
DWORD style = WS_OVERLAPPEDWINDOW | WS_VISIBLE, exStyle = WS_EX_OVERLAPPEDWINDOW | WS_EX_APPWINDOW;
252+
if (fullscreen)
253+
{
254+
style = WS_POPUP | WS_VISIBLE;
255+
exStyle = WS_EX_APPWINDOW;
256+
}
257+
258+
// Update style
259+
SetWindowLong((HWND)*this, GWL_STYLE, (LONG)style);
260+
SetWindowLong((HWND)*this, GWL_EXSTYLE, (LONG)exStyle);
261+
262+
// Update bounds
263+
if (fullscreen)
264+
{
265+
auto monitor = MonitorFromWindow((HWND)*this, MONITOR_DEFAULTTONEAREST);
266+
MONITORINFO info{};
267+
info.cbSize = sizeof(MONITORINFO);
268+
if (GetMonitorInfo(monitor, &info))
269+
{
270+
AdjustWindowRectEx(&info.rcMonitor, style, false, exStyle);
271+
SetWindowPos((HWND)*this, nullptr, info.rcMonitor.left, info.rcMonitor.top, info.rcMonitor.right - info.rcMonitor.left, info.rcMonitor.bottom - info.rcMonitor.top, SWP_NOZORDER);
272+
}
273+
}
274+
else
275+
{
276+
ShowWindow((HWND)*this, SW_MAXIMIZE);
277+
}
278+
279+
// Update window
280+
UpdateWindow((HWND)*this);
281+
282+
m_fullscreen = fullscreen;
283+
}
284+
245285
void GWindow::createDepthBuffer(ID3D12Device* device)
246286
{
247287
HRESULT hr;

src/gfx/GWindow.h

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class GWindow : public EasyHWND::Window{
2222
inline int getWidth() const { return m_width; }
2323
inline int getHeight() const { return m_height; }
2424

25+
void setFullscreen(bool fullscreen);
26+
2527
private:
2628
void createDepthBuffer(ID3D12Device* device);
2729
void destroyDepthBuffer();
@@ -33,6 +35,7 @@ class GWindow : public EasyHWND::Window{
3335
GameIOState m_iostate;
3436

3537
bool m_needsResize = false;
38+
bool m_fullscreen = false;
3639

3740
unsigned int m_heapIncrement = 0;
3841

src/wWinMain.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ INT WINAPI wWinMain(HINSTANCE _In_ hInstance, HINSTANCE _In_opt_ hPrevInstance,
4545
GContext ctx;
4646

4747
// Window
48-
EasyHWND::WindowClass cls(L"ShipBattle_WND", CS_OWNDC);
48+
EasyHWND::WindowClass cls(L"ShipBattle_WND", CS_OWNDC, LoadIcon(NULL, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW));
4949
GWindow wnd(cls, ctx.getDevice(), ctx.getQueue());
5050
wnd.setWindowVisibility(true);
5151

5252
// Maximize
5353
ShowWindow((HWND)wnd, SW_MAXIMIZE);
54+
wnd.setFullscreen(true);
5455

5556
// Upload buffer
5657
GBuffer<BYTE, 1024 * 1024 * 32> uploadBuffer(ctx.getDevice(), D3D12_HEAP_TYPE_UPLOAD);

0 commit comments

Comments
 (0)