diff options
Diffstat (limited to 'AmpelJonas')
-rw-r--r-- | AmpelJonas/AmpelJonas.vcxproj | 175 | ||||
-rw-r--r-- | AmpelJonas/AmpelJonas.vcxproj.filters | 83 | ||||
-rw-r--r-- | AmpelJonas/Makefile | 2 | ||||
-rw-r--r-- | AmpelJonas/cCar.cpp | 84 | ||||
-rw-r--r-- | AmpelJonas/cCar.h | 22 | ||||
-rw-r--r-- | AmpelJonas/cCrossroad.cpp | 178 | ||||
-rw-r--r-- | AmpelJonas/cCrossroad.h | 17 | ||||
-rw-r--r-- | AmpelJonas/cObject.h | 7 | ||||
-rw-r--r-- | AmpelJonas/cObjectHandler.h | 11 | ||||
-rw-r--r-- | AmpelJonas/cPeasant.cpp | 51 | ||||
-rw-r--r-- | AmpelJonas/cPeasant.h | 20 | ||||
-rw-r--r-- | AmpelJonas/cPeasantTrafficLight.cpp | 84 | ||||
-rw-r--r-- | AmpelJonas/cPeasantTrafficLight.h | 30 | ||||
-rw-r--r-- | AmpelJonas/cTrafficLight.cpp | 139 | ||||
-rw-r--r-- | AmpelJonas/cTrafficLight.h | 27 | ||||
-rw-r--r-- | AmpelJonas/main.cpp | 12 | ||||
-rw-r--r-- | AmpelJonas/stdafx.cpp | 8 | ||||
-rw-r--r-- | AmpelJonas/stdafx.h | 29 | ||||
-rw-r--r-- | AmpelJonas/targetver.h | 8 |
19 files changed, 15 insertions, 972 deletions
diff --git a/AmpelJonas/AmpelJonas.vcxproj b/AmpelJonas/AmpelJonas.vcxproj deleted file mode 100644 index 771a41c..0000000 --- a/AmpelJonas/AmpelJonas.vcxproj +++ /dev/null @@ -1,175 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" 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"> - <ProjectGuid>{91D16C6D-C1C1-4FF5-AA46-AAB7E7B2B2B1}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>AmpelJonas</RootNamespace> - <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v140</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)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <SDLCheck>true</SDLCheck> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <SDLCheck>true</SDLCheck> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <SDLCheck>true</SDLCheck> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <SDLCheck>true</SDLCheck> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClInclude Include="cCar.h" /> - <ClInclude Include="cCrossroad.h" /> - <ClInclude Include="cObject.h" /> - <ClInclude Include="cObjectHandler.h" /> - <ClInclude Include="cPeasant.h" /> - <ClInclude Include="cPeasantTrafficLight.h" /> - <ClInclude Include="cRender.h" /> - <ClInclude Include="cTrafficLight.h" /> - <ClInclude Include="stdafx.h" /> - <ClInclude Include="targetver.h" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="cCar.cpp" /> - <ClCompile Include="cCrossroad.cpp" /> - <ClCompile Include="cPeasant.cpp" /> - <ClCompile Include="cPeasantTrafficLight.cpp" /> - <ClCompile Include="cTrafficLight.cpp" /> - <ClCompile Include="main.cpp" /> - <ClCompile Include="cObject.cpp" /> - <ClCompile Include="cObjectHandler.cpp" /> - <ClCompile Include="cRender.cpp" /> - <ClCompile Include="stdafx.cpp" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/AmpelJonas/AmpelJonas.vcxproj.filters b/AmpelJonas/AmpelJonas.vcxproj.filters deleted file mode 100644 index 5afdbac..0000000 --- a/AmpelJonas/AmpelJonas.vcxproj.filters +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Ressourcendateien"> - <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> - <Filter Include="Game"> - <UniqueIdentifier>{136559fc-b520-4b29-b0e8-3c65612b3f81}</UniqueIdentifier> - </Filter> - <Filter Include="Game\Headers"> - <UniqueIdentifier>{ca493b7f-1c64-4d61-8eb5-f8f92504d57d}</UniqueIdentifier> - </Filter> - <Filter Include="Game\Source"> - <UniqueIdentifier>{66d5bf72-191b-41f8-82bc-153596a427de}</UniqueIdentifier> - </Filter> - <Filter Include="Engine"> - <UniqueIdentifier>{41cd36d9-535a-4f7e-a947-79dd5136ed9d}</UniqueIdentifier> - </Filter> - <Filter Include="Engine\Header"> - <UniqueIdentifier>{37e4a21a-712c-4c0d-8cf7-fa21a20424cb}</UniqueIdentifier> - </Filter> - <Filter Include="Engine\Source"> - <UniqueIdentifier>{c887f383-8151-41d2-a9e0-ccdeb35b9538}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClInclude Include="cRender.h"> - <Filter>Engine\Header</Filter> - </ClInclude> - <ClInclude Include="cObject.h"> - <Filter>Engine\Header</Filter> - </ClInclude> - <ClInclude Include="cObjectHandler.h"> - <Filter>Engine\Header</Filter> - </ClInclude> - <ClInclude Include="cCrossroad.h"> - <Filter>Game\Headers</Filter> - </ClInclude> - <ClInclude Include="stdafx.h" /> - <ClInclude Include="targetver.h" /> - <ClInclude Include="cTrafficLight.h"> - <Filter>Game\Headers</Filter> - </ClInclude> - <ClInclude Include="cPeasantTrafficLight.h"> - <Filter>Game\Headers</Filter> - </ClInclude> - <ClInclude Include="cCar.h"> - <Filter>Game\Headers</Filter> - </ClInclude> - <ClInclude Include="cPeasant.h"> - <Filter>Game\Headers</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <ClCompile Include="cRender.cpp"> - <Filter>Engine\Source</Filter> - </ClCompile> - <ClCompile Include="cObject.cpp"> - <Filter>Engine\Source</Filter> - </ClCompile> - <ClCompile Include="cObjectHandler.cpp"> - <Filter>Engine\Source</Filter> - </ClCompile> - <ClCompile Include="cCrossroad.cpp"> - <Filter>Game\Source</Filter> - </ClCompile> - <ClCompile Include="main.cpp" /> - <ClCompile Include="stdafx.cpp" /> - <ClCompile Include="cTrafficLight.cpp"> - <Filter>Game\Source</Filter> - </ClCompile> - <ClCompile Include="cPeasantTrafficLight.cpp"> - <Filter>Game\Source</Filter> - </ClCompile> - <ClCompile Include="cCar.cpp"> - <Filter>Game\Source</Filter> - </ClCompile> - <ClCompile Include="cPeasant.cpp"> - <Filter>Game\Source</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/AmpelJonas/Makefile b/AmpelJonas/Makefile index 32709e2..539032f 100644 --- a/AmpelJonas/Makefile +++ b/AmpelJonas/Makefile @@ -3,7 +3,7 @@ CFLAGS = -Wall -g LDFLAGS = -lm -lpthread -lcurses OUTPUT = Kreuzung -OBJ = main.o cCar.o cCrossroad.o cObject.o cObjectHandler.o cPeasant.o cPeasantTrafficLight.o cRender.o cTrafficLight.o +OBJ = main.o cObject.o cObjectHandler.o cRender.o prog: $(OBJ) $(CC) $(CFLAGS) -o $(OUTPUT) $(OBJ) $(LDFLAGS) diff --git a/AmpelJonas/cCar.cpp b/AmpelJonas/cCar.cpp deleted file mode 100644 index 50122ac..0000000 --- a/AmpelJonas/cCar.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "cCar.h" - -cCar::cCar(int _direction, int *_phase) -{ - pPhase = _phase; - iDirection = _direction; - if (iDirection ==_CAR_DIR_NORTH) { //South or north - car = new cObject(4, 4); - car->setPosition(_SIZE_X_ / 2 - 4, - 4 ); - car->drawRectangle('+', 'X', sPos{ 0,0 }, sPos{3,3}, _COL_RED, _COL_RED); - } - else if (iDirection == _CAR_DIR_SOUTH) { //South or north - car = new cObject(4, 4); - car->setPosition(_SIZE_X_ / 2 +1, _SIZE_Y_); - car->drawRectangle('+', 'X', sPos{ 0,0 }, sPos{ 3,3 }, _COL_RED, _COL_RED); - } - else if(iDirection == _CAR_DIR_WEST){ - car = new cObject(6, 3); - car->setPosition( -6, _SIZE_Y_ / 2 + 1); - car->drawRectangle('+', ' ', sPos{ 0,0 }, sPos{5, 2}, _COL_BLUE, _COL_BLUE); - car->drawText("AUTO", sPos{ 1,1 }, _COL_BLUE); - } - else if (iDirection == _CAR_DIR_EAST) - { - car = new cObject(6, 3); - car->setPosition(_SIZE_X_, _SIZE_Y_ / 2 -3); - car->drawRectangle('+', ' ', sPos{ 0,0 }, sPos{ 5, 2 }, _COL_BLUE, _COL_BLUE); - car->drawText("AUTO", sPos{ 1,1 }, _COL_BLUE); - } -} - -cCar::~cCar() -{ - delete car; -} - -cObject *cCar::getObject() -{ - return car; -} - -void cCar::drive() -{ - sPos oldPos; - switch(iDirection) - { - case _CAR_DIR_EAST: - oldPos = car->getPosition(); - if (!((*pPhase != 5 && *pPhase != 4) && oldPos.x == (_SIZE_X_ / 2) + 11)){ - car->setPosition(oldPos.x - 1, oldPos.y); - } - if (oldPos.x < -6) { - car->setPosition(_SIZE_X_, oldPos.y); - } - break; - case _CAR_DIR_WEST: - oldPos = car->getPosition(); - if (!((*pPhase != 5 && *pPhase != 4) && oldPos.x == (_SIZE_X_ / 2) - 15)){ - car->setPosition(oldPos.x + 1, oldPos.y); - } - if (oldPos.x > _SIZE_X_) { - car->setPosition(-6 , oldPos.y); - } - break; - case _CAR_DIR_NORTH: - oldPos = car->getPosition(); - if (!((*pPhase != 0 && *pPhase != 9 && *pPhase != -1) && oldPos.y == (_SIZE_Y_ / 2) - 11)) { - car->setPosition(oldPos.x, oldPos.y + 1); - } - if (oldPos.y > _SIZE_Y_) { - car->setPosition(oldPos.x, -4); - } - break; - case _CAR_DIR_SOUTH: - oldPos = car->getPosition(); - if (!((*pPhase != 0 && *pPhase != 9 && *pPhase != -1) && oldPos.y == (_SIZE_Y_ / 2) + 8)) { - car->setPosition(oldPos.x, oldPos.y - 1); - } - if (oldPos.y < -4) { - car->setPosition(oldPos.x, _SIZE_Y_); - } - break; - } -} diff --git a/AmpelJonas/cCar.h b/AmpelJonas/cCar.h deleted file mode 100644 index c505079..0000000 --- a/AmpelJonas/cCar.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "stdafx.h" - -#define _CAR_DIR_SOUTH 2 -#define _CAR_DIR_NORTH 4 -#define _CAR_DIR_EAST 1 -#define _CAR_DIR_WEST 3 - -class cCar -{ -public: - cCar(int _direction, int *_phase); - ~cCar(); - - cObject *getObject(); - - void drive(); -private: - cObject *car; - int iDirection; - int *pPhase; -};
\ No newline at end of file diff --git a/AmpelJonas/cCrossroad.cpp b/AmpelJonas/cCrossroad.cpp deleted file mode 100644 index 82c8ed1..0000000 --- a/AmpelJonas/cCrossroad.cpp +++ /dev/null @@ -1,178 +0,0 @@ -#include "cCrossroad.h" - -cCrossroad::cCrossroad() -{ - render = new cRender(' ', _COL_GREEN, _SIZE_X_, _SIZE_Y_); - //handler = new cObjectHandler(render); -} - -cCrossroad::~cCrossroad() -{ - delete render; - //delete handler; -} - -void cCrossroad::run() -{ - int iWait = 4; - int iPhase = -1; - int iFrames = 0; - - cObjectHandler handler(render); - cObject *backround = new cObject(_SIZE_X_, _SIZE_Y_); - - //Objects - cTrafficLight tlNorth(_TL_NORTH_, _TL_COL_GREEN_); - cTrafficLight tlSouth(_TL_SOUTH_, _TL_COL_GREEN_); - cTrafficLight tlEast(_TL_EAST_, _TL_COL_RED_); - cTrafficLight tlWest(_TL_WEST_, _TL_COL_RED_); - - cPeasantTrafficLight ptl1(_CTL_1, _CTL_COL_GREEN); - cPeasantTrafficLight ptl2(_CTL_2, _CTL_COL_RED); - cPeasantTrafficLight ptl3(_CTL_3, _CTL_COL_RED); - cPeasantTrafficLight ptl4(_CTL_4, _CTL_COL_GREEN); - cPeasantTrafficLight ptl5(_CTL_5, _CTL_COL_GREEN); - cPeasantTrafficLight ptl6(_CTL_6, _CTL_COL_RED); - cPeasantTrafficLight ptl7(_CTL_7, _CTL_COL_RED); - cPeasantTrafficLight ptl8(_CTL_8, _CTL_COL_GREEN); - - cCar carSouth(_CAR_DIR_SOUTH, &iPhase); - cCar carNorth(_CAR_DIR_NORTH, &iPhase); - cCar carEast(_CAR_DIR_EAST, &iPhase); - cCar carWest(_CAR_DIR_WEST, &iPhase); - - cPeasant peasantNorth(_PE_DIR_NORTH, &iPhase); - cPeasant peasantWest(_PE_DIR_WEST, &iPhase); - - //init - backround->setPosition(0, 0); - backround->drawRectangle('�', '�', sPos{ 0, _SIZE_Y_ / 2 - 4 }, sPos{ _SIZE_X_ - 1, _SIZE_Y_ / 2 + 4 }, _COL_DEFAULT, _COL_DEFAULT); - backround->drawRectangle('�', '�', sPos{ _SIZE_X_ / 2 - 6, 0 }, sPos{ _SIZE_X_ / 2 + 6, _SIZE_Y_ }, _COL_DEFAULT, _COL_DEFAULT); - - //add objects to handler - handler.createObject(backround); - - handler.createObject(tlNorth.getObject()); - handler.createObject(tlSouth.getObject()); - handler.createObject(tlEast.getObject()); - handler.createObject(tlWest.getObject()); - - handler.createObject(ptl1.getObject()); - handler.createObject(ptl2.getObject()); - handler.createObject(ptl3.getObject()); - handler.createObject(ptl4.getObject()); - handler.createObject(ptl5.getObject()); - handler.createObject(ptl6.getObject()); - handler.createObject(ptl7.getObject()); - handler.createObject(ptl8.getObject()); - - handler.createObject(carSouth.getObject()); - handler.createObject(carNorth.getObject()); - handler.createObject(carEast.getObject()); - handler.createObject(carWest.getObject()); - - handler.createObject(peasantNorth.getObject()); - handler.createObject(peasantWest.getObject()); - - handler.write(); - render->render(); - - //main Loop - - //Starting with vertical Green, horizontal red - - while(1) - { - if (iWait <= 0) - { - iPhase++; - switch (iPhase) - { - case 0: //ptls to red - ptl1.next(); - ptl4.next(); - ptl5.next(); - ptl8.next(); - iWait = 4; - break; - case 1: //switch to yellow - tlNorth.next(); - tlSouth.next(); - iWait = 4; - break; - case 2: //to red - tlNorth.next(); - tlSouth.next(); - iWait = 4; - break; - case 3: //Yellow-Red - tlEast.next(); - tlWest.next(); - iWait = 4; - break; - case 4: //Green - tlEast.next(); - tlWest.next(); - ptl2.next(); - ptl3.next(); - ptl7.next(); - ptl6.next(); - iWait = 10; - break; - case 5: //vert ptls to red - ptl2.next(); - ptl3.next(); - ptl7.next(); - ptl6.next(); - iWait = 4; - break; - case 6: //Yellow-red - tlEast.next(); - tlWest.next(); - iWait = 4; - break; - case 7: //red - tlEast.next(); - tlWest.next(); - iWait = 4; - break; - case 8: //yellow-red - tlNorth.next(); - tlSouth.next(); - iWait = 4; - break; - case 9: //green - tlNorth.next(); - tlSouth.next(); - ptl1.next(); - ptl4.next(); - ptl5.next(); - ptl8.next(); - iPhase = -1; - iWait = 10; - break; - } - } - - - carWest.drive(); - carEast.drive(); - carNorth.drive(); - carSouth.drive(); - - if (iFrames % 2 == 0) { //Run every 2nd frame - peasantNorth.run(); - peasantWest.run(); - } - - - - handler.write(); - render->render(); - - iWait--; - iFrames++; - backround->drawText(to_string(iFrames) , sPos{ 0,0 }, _COL_DEFAULT); //Framecounter - usleep(100*1000); - } -} diff --git a/AmpelJonas/cCrossroad.h b/AmpelJonas/cCrossroad.h deleted file mode 100644 index 18f7352..0000000 --- a/AmpelJonas/cCrossroad.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "stdafx.h" - -#define _SIZE_X_ 150 -#define _SIZE_Y_ 50 - -class cCrossroad -{ -public: - cCrossroad(void); - ~cCrossroad(void); - - void run(void); -private: - cRender *render; - //cObjectHandler *handler; -}; diff --git a/AmpelJonas/cObject.h b/AmpelJonas/cObject.h index abdba3c..d268a0a 100644 --- a/AmpelJonas/cObject.h +++ b/AmpelJonas/cObject.h @@ -1,7 +1,7 @@ #pragma once -#include "stdafx.h" +#include "cRender.h" -struct sObject +struct sObject { sPos pos; @@ -27,6 +27,5 @@ public: private: //wColor, cScreen, sizeX and sizeY are inherited from cRender sPos pos; - -}; +}; diff --git a/AmpelJonas/cObjectHandler.h b/AmpelJonas/cObjectHandler.h index 47598f2..1749c9b 100644 --- a/AmpelJonas/cObjectHandler.h +++ b/AmpelJonas/cObjectHandler.h @@ -1,10 +1,15 @@ #pragma once -#include "stdafx.h" + +#include <vector> + +#include "cObject.h" //movemodes #define _MOVE_RELATIVE 0 #define _MOVE_ABSOULUTE 1 +using namespace std; + class cObject; //Circular dependency break (Bad practice. I Know.) class cObjectHandler @@ -18,7 +23,7 @@ public: int moveObject(int _object, sPos _pos, int _mode); //Alters position of _object by _pos either relative to old position or Absolute - //Depending on selected _mode (_MOVE_RELATIVE / _MOVE_ABSOLUTE). + //Depending on selected _mode (_MOVE_RELATIVE / _MOVE_ABSOLUTE). int destroyObject(int _object); //removes _object from vector after deleting it @@ -29,4 +34,4 @@ public: private: vector<cObject*> objects; cRender *render; -};
\ No newline at end of file +}; diff --git a/AmpelJonas/cPeasant.cpp b/AmpelJonas/cPeasant.cpp deleted file mode 100644 index 280c16f..0000000 --- a/AmpelJonas/cPeasant.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "cPeasant.h" - -cPeasant::cPeasant(int _direction, int *_phase) -{ - pPhase = _phase; - iDirection = _direction; - pe = new cObject(1, 1); - pe->drawPoint(203, sPos{0,0}, true, _COL_YELLOW); - - switch (iDirection) - { - case _PE_DIR_NORTH: - pe->setPosition(_SIZE_X_ / 2 - 7, -1); - break; - case _PE_DIR_WEST: - pe->setPosition(-1, _SIZE_Y_ / 2 - 5); - break; - } -} - -cPeasant::~cPeasant() -{ - delete pe; -} - -cObject *cPeasant::getObject() -{ - return pe; -} - -void cPeasant::run() -{ - sPos oldPos = pe->getPosition(); - switch (iDirection) - { - case _PE_DIR_NORTH: - if(!(oldPos.y == _SIZE_Y_ / 2 - 5 && *pPhase != -1)) - pe->setPosition(oldPos.x, oldPos.y + 1); - - if(oldPos.y > _SIZE_Y_) - pe->setPosition(oldPos.x, -1); - break; - case _PE_DIR_WEST: - if (!(oldPos.x == _SIZE_X_ / 2 - 7 && *pPhase != 4)) - pe->setPosition(oldPos.x + 1, oldPos.y); - - if(oldPos.x > _SIZE_X_) - pe->setPosition(-1, oldPos.y); - break; - } -}
\ No newline at end of file diff --git a/AmpelJonas/cPeasant.h b/AmpelJonas/cPeasant.h deleted file mode 100644 index b8f448e..0000000 --- a/AmpelJonas/cPeasant.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "stdafx.h" - -#define _PE_DIR_NORTH 0 -#define _PE_DIR_WEST 1 - -class cPeasant -{ -public: - cPeasant(int _direction, int *_phase); - ~cPeasant(); - - cObject *getObject(); - - void run(); -private: - cObject *pe; - int iDirection; - int *pPhase; -};
\ No newline at end of file diff --git a/AmpelJonas/cPeasantTrafficLight.cpp b/AmpelJonas/cPeasantTrafficLight.cpp deleted file mode 100644 index 6e348ab..0000000 --- a/AmpelJonas/cPeasantTrafficLight.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "cPeasantTrafficLight.h" - -cPeasantTrafficLight::cPeasantTrafficLight(int _type, int _startphase) -{ - iPhase = _startphase; - iPhase == _CTL_COL_GREEN ? iPhase = _CTL_COL_RED : iPhase = _CTL_COL_GREEN; //switch arround bc switch occurs before lights are switched - iType = _type; - - _type % 2 == 0 ? tl = new cObject(1, 2) : tl = new cObject(2, 1); - - //tl->setPosition(_SIZE_X_ / 2, _SIZE_Y_ / 2); - - switch (_type) - { - case _CTL_1: - tl->setPosition(_SIZE_X_ / 2 - 9, _SIZE_Y_ / 2 - 6); - break; - case _CTL_4: - tl->setPosition(_SIZE_X_ / 2 + 10, _SIZE_Y_ / 2 - 6); - break; - case _CTL_5: - tl->setPosition(_SIZE_X_ / 2 + 10, _SIZE_Y_ / 2 + 5); - break; - case _CTL_8: - tl->setPosition(_SIZE_X_ / 2 - 9, _SIZE_Y_ / 2 + 5); - break; - case _CTL_2: - tl->setPosition(_SIZE_X_ / 2 - 8, _SIZE_Y_ / 2 - 7); - break; - case _CTL_3: - tl->setPosition(_SIZE_X_ / 2 + 7, _SIZE_Y_ / 2 - 7); - break; - case _CTL_6: - tl->setPosition(_SIZE_X_ / 2 + 7, _SIZE_Y_ / 2 + 7); - break; - case _CTL_7: - tl->setPosition(_SIZE_X_ / 2 - 8, _SIZE_Y_ / 2 + 7); - break; - } - - next(); -} - -cPeasantTrafficLight::~cPeasantTrafficLight() -{ - delete tl; -} - -void cPeasantTrafficLight::next() -{ - iPhase == _CTL_COL_GREEN ? iPhase = _CTL_COL_RED : iPhase = _CTL_COL_GREEN; - switch (iType) - { - case _CTL_1: - case _CTL_4: - tl->drawPoint('o', sPos{ 0,0 }, true, _COL_DEFAULT); - tl->drawPoint('o', sPos{ 0,1 }, true, _COL_DEFAULT); - iPhase == _CTL_COL_GREEN ? tl->drawPoint('o', sPos{ 0,1 }, true, _COL_GREEN) : tl->drawPoint('o', sPos{ 0,0 }, true, _COL_RED); - break; - case _CTL_5: - case _CTL_8: - tl->drawPoint('o', sPos{ 0,0 }, true, _COL_DEFAULT); - tl->drawPoint('o', sPos{ 0,1 }, true, _COL_DEFAULT); - iPhase == _CTL_COL_GREEN ? tl->drawPoint('o', sPos{ 0,0 }, true, _COL_GREEN) : tl->drawPoint('o', sPos{ 0,1 }, true, _COL_RED); - break; - case _CTL_2: - case _CTL_7: - tl->drawPoint('o', sPos{ 0,0 }, true, _COL_DEFAULT); - tl->drawPoint('o', sPos{ 1,0 }, true, _COL_DEFAULT); - iPhase == _CTL_COL_GREEN ? tl->drawPoint('o', sPos{ 1,0 }, true, _COL_GREEN) : tl->drawPoint('o', sPos{ 0,0 }, true, _COL_RED); - break; - case _CTL_6: - case _CTL_3: - tl->drawPoint('o', sPos{ 0,0 }, true, _COL_DEFAULT); - tl->drawPoint('o', sPos{ 1,0 }, true, _COL_DEFAULT); - iPhase == _CTL_COL_GREEN ? tl->drawPoint('o', sPos{ 0,0 }, true, _COL_GREEN) : tl->drawPoint('o', sPos{ 1,0 }, true, _COL_RED); - break; - } -} - -cObject *cPeasantTrafficLight::getObject() -{ - return tl; -}
\ No newline at end of file diff --git a/AmpelJonas/cPeasantTrafficLight.h b/AmpelJonas/cPeasantTrafficLight.h deleted file mode 100644 index 88ec99b..0000000 --- a/AmpelJonas/cPeasantTrafficLight.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "stdafx.h" - -#define _CTL_COL_RED 0 -#define _CTL_COL_GREEN 1 - -//Counted clockwise, starting with the upper tl of west lane -#define _CTL_1 2 -#define _CTL_2 1 -#define _CTL_3 3 -#define _CTL_4 4 -#define _CTL_5 6 -#define _CTL_6 5 -#define _CTL_7 7 -#define _CTL_8 8 - -class cPeasantTrafficLight -{ -public: - cPeasantTrafficLight(int _type, int _startphase); - ~cPeasantTrafficLight(); - - void next(); - - cObject *getObject(); -private: - cObject *tl; - int iPhase; - int iType; -};
\ No newline at end of file diff --git a/AmpelJonas/cTrafficLight.cpp b/AmpelJonas/cTrafficLight.cpp deleted file mode 100644 index 9844803..0000000 --- a/AmpelJonas/cTrafficLight.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include "cTrafficLight.h" - -cTrafficLight::cTrafficLight(int _type, int _startphase) -{ - iPhase = _startphase - 1; //-1 because iPhase is incremented before switch statement - iType = _type; - if (_type == _TL_SOUTH_ ) { - tl = new cObject(3, 5); - tl->setPosition(_SIZE_X_ / 2 + 10, _SIZE_Y_ / 2 + 7); - tl->drawRectangle('#', NULL, sPos{ 0,0 }, sPos{ 2,4 }, _COL_WHITE, NULL); - } - else if (_type == _TL_NORTH_) { - tl = new cObject(3, 5); - tl->setPosition(_SIZE_X_ / 2 - 11, _SIZE_Y_ / 2 - 11); - tl->drawRectangle('#', NULL, sPos{ 0,0 }, sPos{ 2,4 }, _COL_WHITE, NULL); - } - else if (_type == _TL_EAST_) { - tl = new cObject(5, 3); - tl->setPosition(_SIZE_X_ / 2 + 10, _SIZE_Y_ / 2 - 9); - tl->drawRectangle('#', NULL, sPos{ 0,0 }, sPos{ 4,2 }, _COL_WHITE, NULL); - } - else if (_type == _TL_WEST_) { - tl = new cObject(5, 3); - tl->setPosition(_SIZE_X_ / 2 - 13, _SIZE_Y_ / 2 + 7); - tl->drawRectangle('#', NULL, sPos{ 0,0 }, sPos{ 4,2 }, _COL_WHITE, NULL); - } - - next(); -} - -cTrafficLight::~cTrafficLight() -{ - delete tl; -} - -void cTrafficLight::next() -{ - iPhase >= _TL_COL_RED_YELLOW_ ? iPhase = _TL_COL_GREEN_ : iPhase++; - - switch(iPhase) - { - case _TL_COL_GREEN_: - if (iType == _TL_SOUTH_) { - - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 1,2 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 1,3 }, true, _COL_GREEN); - } - else if (iType == _TL_NORTH_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_GREEN); - tl->drawPoint('0', sPos{ 1,2 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 1,3 }, true, _COL_DEFAULT); - } - else if (iType == _TL_EAST_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 2,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 3,1 }, true, _COL_GREEN); - } - else if (iType == _TL_WEST_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_GREEN); - tl->drawPoint('0', sPos{ 2,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 3,1 }, true, _COL_DEFAULT); - } - break; - case _TL_COL_YELLOW_: - if (iType == _TL_SOUTH_) { - - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 1,2 }, true, _COL_YELLOW); - tl->drawPoint('0', sPos{ 1,3 }, true, _COL_DEFAULT); - } - else if (iType == _TL_NORTH_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 1,2 }, true, _COL_YELLOW); - tl->drawPoint('0', sPos{ 1,3 }, true, _COL_DEFAULT); - } - else if (iType == _TL_EAST_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 2,1 }, true, _COL_YELLOW); - tl->drawPoint('0', sPos{ 3,1 }, true, _COL_DEFAULT); - } - else if (iType == _TL_WEST_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 2,1 }, true, _COL_YELLOW); - tl->drawPoint('0', sPos{ 3,1 }, true, _COL_DEFAULT); - } - break; - case _TL_COL_RED_: - if (iType == _TL_SOUTH_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_RED); - tl->drawPoint('0', sPos{ 1,2 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 1,3 }, true, _COL_DEFAULT); - } - else if (iType == _TL_NORTH_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 1,2 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 1,3 }, true, _COL_RED); - } - else if (iType == _TL_EAST_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_RED); - tl->drawPoint('0', sPos{ 2,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 3,1 }, true, _COL_DEFAULT); - } - else if (iType == _TL_WEST_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 2,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 3,1 }, true, _COL_RED); - } - break; - case _TL_COL_RED_YELLOW_: - if (iType == _TL_SOUTH_) { - - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_RED); - tl->drawPoint('0', sPos{ 1,2 }, true, _COL_YELLOW); - tl->drawPoint('0', sPos{ 1,3 }, true, _COL_DEFAULT); - } - else if (iType == _TL_NORTH_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 1,2 }, true, _COL_YELLOW); - tl->drawPoint('0', sPos{ 1,3 }, true, _COL_RED); - } - else if (iType == _TL_EAST_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_RED); - tl->drawPoint('0', sPos{ 2,1 }, true, _COL_YELLOW); - tl->drawPoint('0', sPos{ 3,1 }, true, _COL_DEFAULT); - } - else if (iType == _TL_WEST_) { - tl->drawPoint('0', sPos{ 1,1 }, true, _COL_DEFAULT); - tl->drawPoint('0', sPos{ 2,1 }, true, _COL_YELLOW); - tl->drawPoint('0', sPos{ 3,1 }, true, _COL_RED); - } - break; - } -} - -cObject *cTrafficLight::getObject() -{ - return tl; -}
\ No newline at end of file diff --git a/AmpelJonas/cTrafficLight.h b/AmpelJonas/cTrafficLight.h deleted file mode 100644 index c17cdb7..0000000 --- a/AmpelJonas/cTrafficLight.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#define _TL_SOUTH_ 0 -#define _TL_NORTH_ 1 -#define _TL_EAST_ 2 -#define _TL_WEST_ 3 - -#define _TL_COL_GREEN_ 0 -#define _TL_COL_YELLOW_ 1 -#define _TL_COL_RED_ 2 -#define _TL_COL_RED_YELLOW_ 3 - -#include "stdafx.h" - -class cTrafficLight -{ -public: - cTrafficLight(int _type, int _startphase); - ~cTrafficLight(); - - void next(); - - cObject *getObject(); -private: - cObject *tl; - int iPhase; - int iType; -};
\ No newline at end of file diff --git a/AmpelJonas/main.cpp b/AmpelJonas/main.cpp index 47a214b..adf9113 100644 --- a/AmpelJonas/main.cpp +++ b/AmpelJonas/main.cpp @@ -1,14 +1,8 @@ -#include "stdafx.h" +#include "cRender.h" +#include "cObject.h" +#include "cObjectHandler.h" int main() { - cCrossroad *crossroad; - crossroad = new cCrossroad; - crossroad->run(); - delete crossroad; - - cout << endl; - cin.get(); - return 0; } diff --git a/AmpelJonas/stdafx.cpp b/AmpelJonas/stdafx.cpp deleted file mode 100644 index b50f832..0000000 --- a/AmpelJonas/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : Quelldatei, die nur die Standard-Includes einbindet. -// AmpelJonas.pch ist der vorkompilierte Header. -// stdafx.obj enthält die vorkompilierten Typinformationen. - -#include "stdafx.h" - -// TODO: Auf zusätzliche Header verweisen, die in STDAFX.H -// und nicht in dieser Datei erforderlich sind. diff --git a/AmpelJonas/stdafx.h b/AmpelJonas/stdafx.h deleted file mode 100644 index 1e65f85..0000000 --- a/AmpelJonas/stdafx.h +++ /dev/null @@ -1,29 +0,0 @@ -// stdafx.h: Includedatei f�r Standardsystem-Includedateien -// oder h�ufig verwendete projektspezifische Includedateien, -// die nur in unregelm��igen Abst�nden ge�ndert werden. -// - -#pragma once -//#include "targetver.h" - -#include <stdio.h> -#include <iostream> - -#ifdef _WIN32 -#include <tchar.h> -#elif __linux__ -#include <unistd.h> -#endif - -#include <vector> - -#include "cRender.h" -#include "cObject.h" -#include "cObjectHandler.h" -#include "cCrossroad.h" -#include "cTrafficLight.h" -#include "cPeasantTrafficLight.h" -#include "cCar.h" -#include "cPeasant.h" - -using namespace std; diff --git a/AmpelJonas/targetver.h b/AmpelJonas/targetver.h deleted file mode 100644 index a765413..0000000 --- a/AmpelJonas/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Durch Einbeziehen von"SDKDDKVer.h" wird die höchste verfügbare Windows-Plattform definiert. - -// Wenn Sie die Anwendung für eine frühere Windows-Plattform erstellen möchten, schließen Sie "WinSDKVer.h" ein, und -// legen Sie das _WIN32_WINNT-Makro auf die zu unterstützende Plattform fest, bevor Sie "SDKDDKVer.h" einschließen. - -#include <SDKDDKVer.h> |