Début TP2 + Handling des événements de touches de mouvement
This commit is contained in:
@@ -1,160 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{90ae3964-e572-47ec-a7fb-b550481dc822}</ProjectGuid>
|
||||
<RootNamespace>SQCSim2021</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="blockarray3d.h" />
|
||||
<ClInclude Include="blockinfo.h" />
|
||||
<ClInclude Include="chunk.h" />
|
||||
<ClInclude Include="define.h" />
|
||||
<ClInclude Include="main.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="blockarray3d.cpp" />
|
||||
<ClCompile Include="blockinfo.cpp" />
|
||||
<ClCompile Include="chunk.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\Users\Mark_\Downloads\tp01.pdf" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="main.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="blockinfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="define.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="blockarray3d.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="chunk.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="blockinfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="blockarray3d.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="chunk.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\Users\Mark_\Downloads\tp01.pdf" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,26 +0,0 @@
|
||||
#include "blockarray3d.h"
|
||||
|
||||
BlockArray3d::BlockArray3d(int x, int y, int z) : m_x(x), m_y(y), m_z(z) {
|
||||
m_blocks = new BlockType[x * y * z];
|
||||
Reset(BTYPE_AIR);
|
||||
}
|
||||
|
||||
BlockArray3d::BlockArray3d(BlockArray3d& ba) : m_x(ba.m_x), m_y(ba.m_y), m_z(ba.m_z) {
|
||||
m_blocks = new BlockType[ba.m_x*ba.m_y*ba.m_z];
|
||||
|
||||
for (int index = 0; index < (m_x * m_y * m_z); ++index)
|
||||
m_blocks[index] = ba.m_blocks[index];
|
||||
}
|
||||
|
||||
BlockArray3d::~BlockArray3d() { delete[] m_blocks; }
|
||||
|
||||
void BlockArray3d::Set(int x, int y, int z, BlockType type) { m_blocks[GetPosition(x, y, z)] = type; }
|
||||
|
||||
BlockType BlockArray3d::Get(int x, int y, int z) const { return m_blocks[GetPosition(x, y, z)]; }
|
||||
|
||||
void BlockArray3d::Reset(BlockType type) {
|
||||
for (int index = 0; index < (m_x * m_y * m_z); ++index)
|
||||
m_blocks[index] = type;
|
||||
}
|
||||
|
||||
int BlockArray3d::GetPosition(int x, int y, int z) const { return x + (z * m_x) + (y * m_z * m_x); }
|
@@ -1,24 +0,0 @@
|
||||
#ifndef BLOCKARRAY3D_H__
|
||||
#define BLOCKARRAY3D_H__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
class BlockArray3d {
|
||||
public:
|
||||
BlockArray3d(int x, int y, int z);
|
||||
BlockArray3d(BlockArray3d& ba);
|
||||
virtual ~BlockArray3d();
|
||||
|
||||
void Set(int x, int y, int z, BlockType type);
|
||||
BlockType Get(int x, int y, int z) const;
|
||||
void Reset(BlockType type);
|
||||
|
||||
private:
|
||||
BlockType* m_blocks;
|
||||
int m_x;
|
||||
int m_y;
|
||||
int m_z;
|
||||
|
||||
int GetPosition(int x, int y, int z) const;
|
||||
};
|
||||
#endif
|
@@ -1,13 +0,0 @@
|
||||
#include "blockinfo.h"
|
||||
|
||||
BlockInfo::BlockInfo(BlockType type, const std::string& name): m_name(name), m_type(type) { m_durability = 0; }
|
||||
|
||||
BlockInfo::~BlockInfo() { }
|
||||
|
||||
BlockType BlockInfo::GetType() const { return m_type; }
|
||||
|
||||
void BlockInfo::SetDurability(int durability) { m_durability = durability; }
|
||||
|
||||
int BlockInfo::GetDurability() const { return m_durability; }
|
||||
|
||||
void BlockInfo::Show() const { std::cout << "Name: " << m_name << "; Type " << m_type << "; Durability: " << m_durability << std::endl; }
|
@@ -1,23 +0,0 @@
|
||||
#ifndef BLOCKINFO_H__
|
||||
#define BLOCKINFO_H__
|
||||
|
||||
#include "define.h"
|
||||
|
||||
class BlockInfo {
|
||||
public:
|
||||
BlockInfo(BlockType type, const std::string& name);
|
||||
~BlockInfo();
|
||||
|
||||
BlockType GetType() const;
|
||||
|
||||
void SetDurability(int durability);
|
||||
int GetDurability() const;
|
||||
void Show() const;
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
int m_durability;
|
||||
BlockType m_type;
|
||||
};
|
||||
#endif
|
||||
|
@@ -1,13 +0,0 @@
|
||||
#include "chunk.h"
|
||||
|
||||
Chunk::Chunk(): BlockArray3d(CHUNK_SIZE_X, CHUNK_SIZE_Y, CHUNK_SIZE_Z) {}
|
||||
|
||||
Chunk::Chunk(Chunk& chk) : BlockArray3d(chk) {}
|
||||
|
||||
Chunk::~Chunk() {}
|
||||
|
||||
void Chunk::RemoveBlock(int x, int y, int z) { Set(x, y, z, BTYPE_AIR); }
|
||||
|
||||
void Chunk::SetBlock(int x, int y, int z, BlockType type) { Set(x, y, z, type); }
|
||||
|
||||
BlockType Chunk::GetBlock(int x, int y, int z) const { return Get(x, y, z); }
|
@@ -1,20 +0,0 @@
|
||||
#ifndef CHUNK_H__
|
||||
#define CHUNK_H__
|
||||
|
||||
#include "define.h"
|
||||
#include "blockarray3d.h"
|
||||
|
||||
class Chunk : public BlockArray3d {
|
||||
public:
|
||||
Chunk();
|
||||
Chunk(Chunk& chk);
|
||||
virtual ~Chunk();
|
||||
|
||||
void RemoveBlock(int x, int y, int z);
|
||||
void SetBlock(int x, int y, int z, BlockType type);
|
||||
BlockType GetBlock(int x, int y, int z) const;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,17 +0,0 @@
|
||||
#ifndef DEFINE_H__
|
||||
#define DEFINE_H__
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#define CHUNK_SIZE_X 16
|
||||
#define CHUNK_SIZE_Y 128
|
||||
#define CHUNK_SIZE_Z 16
|
||||
|
||||
enum BlockType {
|
||||
BTYPE_AIR,
|
||||
BTYPE_DIRT,
|
||||
BTYPE_GRASS
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,64 +0,0 @@
|
||||
#include "main.h"
|
||||
|
||||
int main() {
|
||||
|
||||
Chunk* testchunk = new Chunk();
|
||||
std::vector<BlockInfo*> testblock;
|
||||
|
||||
std::cout << "-Test 1-------BlockInfo------------------" << std::endl;
|
||||
|
||||
testblock.push_back(new BlockInfo(BTYPE_AIR, "The air in the sky"));
|
||||
testblock.push_back(new BlockInfo(BTYPE_DIRT, "The dirt on the ground"));
|
||||
testblock.push_back(new BlockInfo(BTYPE_GRASS, "The grass on the dirt"));
|
||||
|
||||
testblock[1]->SetDurability(5);
|
||||
testblock[2]->SetDurability(6);
|
||||
|
||||
for (int index = 0; index < testblock.size(); ++index)
|
||||
testblock[index]->Show();
|
||||
|
||||
std::cout << "GetDurability: " << testblock[0]->GetDurability() << " and " << testblock[1]->GetDurability() << " and " << testblock[2]->GetDurability() << std::endl;
|
||||
std::cout << "GetType: " << testblock[0]->GetType() << " and " << testblock[1]->GetType() << " and " << testblock[2]->GetType() << std::endl;
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "-Test 2--------Chunk/BlockArray3D---------" << std::endl;
|
||||
testchunk->SetBlock(1, 0, 0, BTYPE_DIRT);
|
||||
testchunk->SetBlock(2, 0, 0, BTYPE_GRASS);
|
||||
testblock.push_back(new BlockInfo(testchunk->GetBlock(0, 0, 0), "A new block in the chunk"));
|
||||
testblock.push_back(new BlockInfo(testchunk->GetBlock(1, 0, 0), "A dirty block in the chunk"));
|
||||
testblock.push_back(new BlockInfo(testchunk->GetBlock(2, 0, 0), "A grassy block in the chunk"));
|
||||
|
||||
for (int index = 3; index < testblock.size(); ++index)
|
||||
testblock[index]->Show();
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "-Test 3--------Chunk Copy------------------" << std::endl;
|
||||
Chunk testchunkcopy(*testchunk);
|
||||
|
||||
delete testchunk;
|
||||
|
||||
testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(0, 0, 0), "A block in a copied chunk"));
|
||||
testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(1, 0, 0), "A dirty block in a copied chunk"));
|
||||
testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(1, 0, 0), "A grassy block in a copied chunk"));
|
||||
|
||||
for (int index = 6; index < testblock.size(); ++index)
|
||||
testblock[index]->Show();
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "-Test 3--------Chunk Reset/Remove Block-----" << std::endl;
|
||||
testchunkcopy.Reset(BTYPE_GRASS);
|
||||
testchunkcopy.RemoveBlock(3, 0, 0);
|
||||
testchunkcopy.SetBlock(4, 0, 0, BTYPE_DIRT);
|
||||
|
||||
testblock.clear();
|
||||
|
||||
for (int index = 0; index < 10; ++index)
|
||||
testblock.push_back(new BlockInfo(testchunkcopy.GetBlock(index, 0, 0), "A block in a reset chunk containing lots of grass"));
|
||||
|
||||
for (int index = 0; index < testblock.size(); ++index)
|
||||
testblock[index]->Show();
|
||||
|
||||
testblock.clear();
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
#ifndef MAIN_H__
|
||||
#define MAIN_H__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "define.h"
|
||||
#include "chunk.h"
|
||||
#include "blockinfo.h"
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user