Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Assets/Woods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion RoboCat/Chapter3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
<LinkIncremental>true</LinkIncremental>
<GenerateManifest>true</GenerateManifest>
<OutDir>Bin\$(Configuration)\</OutDir>
<Allegro_AddonImage>true</Allegro_AddonImage>
<Allegro_AddonTTF>true</Allegro_AddonTTF>
<Allegro_AddonPrimitives>true</Allegro_AddonPrimitives>
<Allegro_AddonFont>true</Allegro_AddonFont>
<Allegro_AddonColor>true</Allegro_AddonColor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|X64'">
<LinkIncremental>true</LinkIncremental>
Expand Down Expand Up @@ -128,7 +133,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<AdditionalIncludeDirectories>..\SDL\include;Inc;..\</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>RoboCatPCH.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
Expand Down Expand Up @@ -372,8 +377,11 @@
<ItemGroup>
<ClInclude Include="Inc\AckRange.h" />
<ClInclude Include="Inc\ByteSwap.h" />
<ClInclude Include="Inc\Colour.h" />
<ClInclude Include="Inc\DeliveryNotificationManager.h" />
<ClInclude Include="Inc\GraphicsLibrary.h" />
<ClInclude Include="Inc\InFlightPacket.h" />
<ClInclude Include="Inc\InputSystem.h" />
<ClInclude Include="Inc\LinkingContext.h" />
<ClInclude Include="Inc\MemoryBitStream.h" />
<ClInclude Include="Inc\OutputWindow.h" />
Expand All @@ -389,16 +397,25 @@
<ClInclude Include="Inc\TransmissionData.h" />
<ClInclude Include="Inc\UDPSocket.h" />
<ClCompile Include="Src\AckRange.cpp" />
<ClCompile Include="Src\Colour.cpp" />
<ClCompile Include="Src\DeliveryNotificationManager.cpp" />
<ClCompile Include="Src\GameObject.cpp" />
<ClCompile Include="Src\GraphicsLibrary.cpp" />
<ClCompile Include="Src\InFlightPacket.cpp" />
<ClCompile Include="Src\InputSystem.cpp" />
<ClCompile Include="Src\Main.cpp" />
<ClCompile Include="Src\MemoryBitStream.cpp" />
<ClCompile Include="Src\NetworkManager.cpp" />
<ClCompile Include="Src\NetworkManagerServer.cpp" />
<ClCompile Include="Src\OutputWindow.cpp" />
<ClCompile Include="Src\SocketAddress.cpp" />
<ClCompile Include="Src\SocketAddressFactory.cpp" />
<ClCompile Include="Src\SocketUtil.cpp" />
<ClCompile Include="Src\StringUtils.cpp" />
<ClCompile Include="Src\TCPSocket.cpp" />
<ClInclude Include="Src\GameObject.h" />
<ClInclude Include="Src\NetworkManager.h" />
<ClInclude Include="Src\NetworkManagerServer.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Src\RoboCatPCH.cpp">
Expand Down
45 changes: 45 additions & 0 deletions RoboCat/Inc/Colour.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#pragma once

/*
Allegro Wrapper Functions
Written by Adel Talhouk in FA21
Colour.h

File information:
This file contains data used for colours.
*/



class Colour
{
//-------------------------Private data-------------------------

//Red channel
unsigned __int8 mR;

//Green channel
unsigned __int8 mG;

//Blue channel
unsigned __int8 mB;

//Alpha channel
unsigned __int8 mA;

//-------------------------Public data-------------------------
public:

//Constructor(s)
Colour(unsigned __int8 r, unsigned __int8 g, unsigned __int8 b);
Colour(unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, unsigned __int8 a);

//Destructor
~Colour();

//Accessor(s)
unsigned __int8 getR() { return mR; };
unsigned __int8 getG() { return mG; };
unsigned __int8 getB() { return mB; };
unsigned __int8 getA() { return mA; };
};
68 changes: 68 additions & 0 deletions RoboCat/Inc/GraphicsLibrary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#pragma once

/*
Allegro Wrapper Functions
Written by Adel Talhouk in FA21
GraphicsLibrary.h

File information:
This file contains function abstractions from Allegro 5, wrapped up in my Graphics Library. This will
be used to render images and text to the screen.

Source I am consulting: Allegro 5.0.10 Manual - http://cdn.allegro.cc/file/library/allegro/5.0.10/allegro-5.0.10-manual.pdf
*/

#include <string>
#include <vector>

#include "Colour.h"


//https://github.com/liballeg/allegro_wiki/wiki/Allegro-in-Visual-Studio#using-nuget-within-visual-studio
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_acodec.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_primitives.h>

class GraphicsLibrary
{
//-------------------------Private data-------------------------

//Screen data
float mScreenSizeX;
float mScreenSizeY;

//Allegro display
ALLEGRO_DISPLAY* mpDisplay;

//Other images to draw
std::vector<std::pair<std::string, ALLEGRO_BITMAP*>> mBitmapPointersVector;

friend class InputSystem;

//-------------------------Public data-------------------------
public:

//Constructor(s)
GraphicsLibrary(float screenSizeX, float screenSizeY);

//Destructor
~GraphicsLibrary();

//Accessor(s)
float getScreenSizeX() { return mScreenSizeX; };
float getScreenSizeY() { return mScreenSizeY; };

//Mutator(s)

//Functions
bool init(std::string backgroundFilePath);
void render();
void loadImage(std::string imageFilePath, std::string imageIdentifier);

//Drawing functions
void drawImage(std::string imageIdentifier, float posX, float posY);
void drawTintedImage(std::string imageIdentifier, float posX, float posY, Colour col);
};
72 changes: 72 additions & 0 deletions RoboCat/Inc/InputSystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#pragma once

/*
Allegro Wrapper Functions
Written by Adel Talhouk in FA21
InputSystem.h

File information:
This file contains the keycodes for input, which can be used in any way desired by other classes
and files.
*/

#include "GraphicsLibrary.h"


//Include allegro libraries for input
#include <allegro5/allegro.h>
#include <allegro5/events.h>

enum KeyCode
{
Esc = ALLEGRO_KEY_ESCAPE,
R = ALLEGRO_KEY_R,
S = ALLEGRO_KEY_S,
D = ALLEGRO_KEY_D
};

enum MouseButton
{
LeftMouse = 0,
RightMouse = 1,
MiddleMouse = 2
};

enum InputMode
{
NONE = -1,
KeyPressed = ALLEGRO_EVENT_KEY_DOWN,
KeyReleased = ALLEGRO_EVENT_KEY_UP,
MouseDown = ALLEGRO_EVENT_MOUSE_BUTTON_DOWN,
MouseUp = ALLEGRO_EVENT_MOUSE_BUTTON_UP
};

class InputSystem
{
//-------------------------Private data-------------------------

//Event queue
ALLEGRO_EVENT_QUEUE* mpEventQueue;

//Event
ALLEGRO_EVENT mEvent;

//-------------------------Public data-------------------------
public:

//Constructor(s)
InputSystem();

//Destructor
~InputSystem();

//Accessor(s)
float getMouseX();
float getMouseY();
std::pair<float, float> getMousePosition();

//Functions
bool init(GraphicsLibrary* pGraphicsLib);
MouseButton getMouseInput();
KeyCode getKeyboardInput();
};
32 changes: 32 additions & 0 deletions RoboCat/Src/Colour.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Allegro Wrapper Functions
Written by Adel Talhouk in FA21
Colour.cpp
*/

#include "Colour.h"
#include "RoboCatPCH.h"

//Constructor - without alpha
Colour::Colour(unsigned __int8 r, unsigned __int8 g, unsigned __int8 b)
{
mR = r;
mG = g;
mB = b;
mA = 255;
}

//Constructor - with alpha
Colour::Colour(unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, unsigned __int8 a)
{
mR = r;
mG = g;
mB = b;
mA = a;
}

//Destructor
Colour::~Colour()
{

}
Loading