style: window size & black background

This commit is contained in:
2024-01-08 11:43:17 +01:00
parent d227676285
commit c7c7c91818
5 changed files with 32 additions and 14 deletions
+3
View File
@@ -135,6 +135,9 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClInclude Include="main.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
+5
View File
@@ -22,4 +22,9 @@
<Filter>Fichiers sources</Filter> <Filter>Fichiers sources</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClInclude Include="main.h">
<Filter>Fichiers d%27en-tête</Filter>
</ClInclude>
</ItemGroup>
</Project> </Project>
+3 -1
View File
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup /> <PropertyGroup>
<ShowAllFiles>false</ShowAllFiles>
</PropertyGroup>
</Project> </Project>
+10 -13
View File
@@ -1,28 +1,25 @@
#include <SFML/Graphics.hpp> #include "main.h";
int main() int main()
{ {
sf::RenderWindow window(sf::VideoMode(1024, 800), "Space Invader", sf::Style::Titlebar | sf::Style::Close); RenderWindow window(VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Space Invader", Style::Titlebar | Style::Close);
window.setFramerateLimit(60);
window.setVerticalSyncEnabled(true);
while (window.isOpen()) while (window.isOpen())
{ {
sf::Event event; Event event;
while (window.pollEvent(event)) while (window.pollEvent(event))
{ {
if (event.type == sf::Event::Closed) if (event.type == Event::Closed)
{ {
window.close(); window.close();
} }
else if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == sf::Keyboard::Escape)
{
window.close();
}
}
}
// Update here window.clear(Color::Black);
window.display();
}
} }
return 0; return 0;
+11
View File
@@ -0,0 +1,11 @@
#pragma once
#include <cstdlib>
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace std;
using namespace sf;
const int SCREEN_WIDTH = 1024;
const int SCREEN_HEIGHT = 1024;