Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1630443
adding allegro files to the assignment
MatthewE2001 Mar 4, 2022
835ba0d
Fixing allegro issues
MatthewE2001 Mar 4, 2022
d418899
adding notes and plans for the project
MatthewE2001 Mar 18, 2022
f6272be
planning out how to send the messages
MatthewE2001 Mar 20, 2022
4c6e5ef
working on object creation
MatthewE2001 Mar 22, 2022
51f52bf
creating game object file
MatthewE2001 Mar 22, 2022
095d19f
adding another game object file
MatthewE2001 Mar 22, 2022
19178dc
planning more object creation
MatthewE2001 Mar 25, 2022
ee3a462
moving the game object files to the right folder
MatthewE2001 Mar 25, 2022
3b3cec2
fixing the file issues and working on game objects
MatthewE2001 Mar 25, 2022
70e6859
planning game object usage in main
MatthewE2001 Mar 25, 2022
e1ed0a1
adding a background photo for allegro
MatthewE2001 Mar 27, 2022
6d88f3f
trying to implement object spawn/despawn
MatthewE2001 Mar 28, 2022
8ff702f
adjusting game object position methods
MatthewE2001 Mar 28, 2022
4cb3ac5
filling out game object info and preparing for info sending
MatthewE2001 Mar 28, 2022
8bf636d
position changes for game objects
MatthewE2001 Mar 28, 2022
e0f5c94
drawing objects every update
MatthewE2001 Mar 28, 2022
5c23d76
working on the info sending functions
MatthewE2001 Mar 29, 2022
e4ce72e
notes on planning sending and receiving
MatthewE2001 Mar 29, 2022
8ade0f1
working on having some level of object sending
MatthewE2001 Mar 31, 2022
04a0833
trying to make some info for sending out data
MatthewE2001 Mar 31, 2022
045ea82
working on a network manager
MatthewE2001 Apr 1, 2022
7799655
working on network manager client
MatthewE2001 Apr 4, 2022
99c59fb
planning out state packets
MatthewE2001 Apr 4, 2022
aa4bce1
working more on network manager client
MatthewE2001 Apr 5, 2022
dcece9d
planning time management
MatthewE2001 Apr 5, 2022
fb4b489
network manager into sending packets
MatthewE2001 Apr 7, 2022
a324276
fixing errors i forgot
MatthewE2001 Apr 7, 2022
f2c2429
setting up a hopefully working build
MatthewE2001 Apr 7, 2022
b9d5ee8
working more on network manager connections
MatthewE2001 Apr 8, 2022
86712d1
trying to prepare assignment 2 for submission
MatthewE2001 Apr 14, 2022
3d964ec
adding input and output for server manager
MatthewE2001 Apr 14, 2022
f6949f0
making project run
MatthewE2001 Apr 14, 2022
d7fa6f8
setting up woods png
MatthewE2001 Apr 14, 2022
c594abd
adding a bit of info storage to client
MatthewE2001 Apr 15, 2022
b960c62
working on making the background image show
MatthewE2001 Apr 15, 2022
09afd26
trying to solve the pathing issues
MatthewE2001 Apr 19, 2022
49beb07
working on loading bitmaps
MatthewE2001 Apr 22, 2022
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.
18 changes: 17 additions & 1 deletion RoboCat/Chapter3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
<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>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|X64'">
<LinkIncremental>true</LinkIncremental>
Expand Down Expand Up @@ -128,7 +132,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 @@ -371,6 +375,9 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Inc\ByteSwap.h" />
<ClInclude Include="Inc\Colour.h" />
<ClInclude Include="Inc\GraphicsLibrary.h" />
<ClInclude Include="Inc\InputSystem.h" />
<ClInclude Include="Inc\LinkingContext.h" />
<ClInclude Include="Inc\MemoryBitStream.h" />
<ClInclude Include="Inc\OutputWindow.h" />
Expand All @@ -383,14 +390,23 @@
<ClInclude Include="Inc\RoboCatPCH.h" />
<ClInclude Include="Inc\RoboCatShared.h" />
<ClInclude Include="Inc\UDPSocket.h" />
<ClCompile Include="Src\Colour.cpp" />
<ClCompile Include="Src\GameObject.cpp" />
<ClCompile Include="Src\GraphicsLibrary.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()
{

}
119 changes: 119 additions & 0 deletions RoboCat/Src/GameObject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#include "GameObject.h"

GameObject::GameObject()
{
mColor = Colour(0, 255, 0);
}

GameObject::~GameObject()
{

}

void GameObject::CreateObject()
{
int val;
val = rand() % 3;

if (val == 0)
{
al_draw_filled_circle(400, 400, 10, al_map_rgb(0, 255, 0));
objectType = 'g';
positionX = 400;
positionY = 400;
}
else if (val == 1)
{
al_draw_filled_circle(400, 400, 10, al_map_rgb(255, 0, 0));
objectType = 'r';
positionX = 400;
positionY = 400;

//al_draw_triangle();
}
else if (val == 2)
{
al_draw_filled_circle(400, 400, 10, al_map_rgb(0, 0, 255));
objectType = 'b';
positionX = 400;
positionY = 400;

//al_draw_rectangle();
}

//probably no need for a final else statement
}

void GameObject::DeleteObject()
{
//idk if there is any deletion i need to do necessarily
//possibly just undrawing things

}

void GameObject::UpdatePosition()
{
int val;
val = rand() % 4;

if (val == 0)
{
//have it move up and to the right
positionX += 20;
positionY += 20;
}

if (val == 1)
{
//move down and to the right
positionX += 20;
positionY -= 20;
}

if (val == 2)
{
//down and to the left
positionX -= 20;
positionY -= 20;
}

if (val == 3)
{
//up and to the left
positionX -= 20;
positionY += 20;
}
}

void GameObject::DrawObjects()
{
if (objectType == 'r')
{
al_draw_filled_circle(positionX, positionY, 10, al_map_rgb(255, 0, 0));
}

if (objectType == 'g')
{
al_draw_filled_circle(positionX, positionY, 10, al_map_rgb(0, 255, 0));
}

if (objectType == 'b')
{
al_draw_filled_circle(positionX, positionY, 10, al_map_rgb(0, 0, 255));
}
}

char GameObject::GetObjectType()
{
return objectType;
}

float GameObject::GetPositionX()
{
return positionX;
}

float GameObject::GetPositionY()
{
return positionY;
}
Loading