diff --git a/2517597.jpg b/2517597.jpg new file mode 100644 index 00000000..ebaa86ef Binary files /dev/null and b/2517597.jpg differ diff --git a/Kirby.png b/Kirby.png new file mode 100644 index 00000000..66d294a3 Binary files /dev/null and b/Kirby.png differ diff --git a/RoboCat/Chapter3.vcxproj b/RoboCat/Chapter3.vcxproj index 8c859a81..753e15c6 100644 --- a/RoboCat/Chapter3.vcxproj +++ b/RoboCat/Chapter3.vcxproj @@ -31,12 +31,13 @@ {B3B75176-8D81-4E7B-A5D0-C2E5423844D3} SimpleSample Win32Proj + 10.0 Application MultiByte - v142 + v143 Application @@ -92,6 +93,9 @@ true true Bin\$(Configuration)\ + true + true + true true @@ -128,7 +132,7 @@ ProgramDatabase EnableFastChecks ..\SDL\include;Inc;..\ - Use + NotUsing RoboCatPCH.h @@ -370,10 +374,10 @@ - + + + - - @@ -385,12 +389,10 @@ - - - - - + + + @@ -405,7 +407,6 @@ Create RoboCatPCH.h - diff --git a/RoboCat/Colour.cpp b/RoboCat/Colour.cpp new file mode 100644 index 00000000..7a5ef3d1 --- /dev/null +++ b/RoboCat/Colour.cpp @@ -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() +{ + +} \ No newline at end of file diff --git a/RoboCat/Colour.h b/RoboCat/Colour.h new file mode 100644 index 00000000..216b028c --- /dev/null +++ b/RoboCat/Colour.h @@ -0,0 +1,43 @@ +#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; }; +}; diff --git a/RoboCat/GraphicsLibrary.cpp b/RoboCat/GraphicsLibrary.cpp new file mode 100644 index 00000000..ea5254d6 --- /dev/null +++ b/RoboCat/GraphicsLibrary.cpp @@ -0,0 +1,126 @@ +/* +Allegro Wrapper Functions +Written by Adel Talhouk in FA21 +GraphicsLibrary.cpp +*/ + +#include "GraphicsLibrary.h" +#include "RoboCatPCH.h" + +#include +#include + +//Constructor +GraphicsLibrary::GraphicsLibrary(float screenSizeX, float screenSizeY) +{ + //Setup data - screen size + mScreenSizeX = screenSizeX; + mScreenSizeY = screenSizeY; + + //Allegro display + mpDisplay = nullptr; +} + +//Destructor +GraphicsLibrary::~GraphicsLibrary() +{ + //Delete bitmaps + std::vector>::iterator iterator; + for (iterator = mBitmapPointersVector.begin(); iterator != mBitmapPointersVector.end(); ++iterator) + { + al_destroy_bitmap(iterator->second); + } + mBitmapPointersVector.clear(); + + //Clean up display + al_destroy_display(mpDisplay); + mpDisplay = nullptr; +} + +bool GraphicsLibrary::init(std::string backgroundFilePath) +{ + //Init allegro + if (!al_init()) + { + std::cout << "error initting Allegro\n"; + system("pause"); + return false; + } + + //Init image addon + if (!al_init_image_addon()) + { + std::cout << "error initting image add-on\n"; + system("pause"); + return false; + } + + //Init font add on + if (!al_init_font_addon()) + { + std::cout << "error initting font add-on\n"; + system("pause"); + return false; + } + + //Init ttf add on + if (!al_init_ttf_addon()) + { + std::cout << "error initting ttf add-on\n"; + system("pause"); + return false; + } + + //Setup display + mpDisplay = al_create_display(mScreenSizeX, mScreenSizeY); + + if (mpDisplay == nullptr) + { + return false; + } + + return true; +} + +void GraphicsLibrary::render() +{ + //Flip display buffers + al_flip_display(); +} + +void GraphicsLibrary::loadImage(std::string imageFilePath, std::string imageIdentifier) +{ + //Add the name of the image and the loaded bitmap to the vector of pairs + mBitmapPointersVector.push_back(std::make_pair(imageIdentifier, al_load_bitmap(imageFilePath.c_str()))); +} + +void GraphicsLibrary::drawImage(std::string imageIdentifier, float posX, float posY) +{ + //Find the image and draw if it exists + std::vector>::iterator iterator; + + for (iterator = mBitmapPointersVector.begin(); iterator != mBitmapPointersVector.end(); ++iterator) + { + if (iterator->first == imageIdentifier) + { + al_draw_bitmap(iterator->second, posX, posY, 0); + } + } +} + +void GraphicsLibrary::drawTintedImage(std::string imageIdentifier, float posX, float posY, Colour col) +{ + //Find the image and draw if it exists + std::vector>::iterator iterator; + + //Set colour + ALLEGRO_COLOR colour = al_map_rgba(col.getR(), col.getG(), col.getB(), col.getA()); + + for (iterator = mBitmapPointersVector.begin(); iterator != mBitmapPointersVector.end(); ++iterator) + { + if (iterator->first == imageIdentifier) + { + al_draw_tinted_bitmap(iterator->second, colour, posX, posY, 0); + } + } +} \ No newline at end of file diff --git a/RoboCat/GraphicsLibrary.h b/RoboCat/GraphicsLibrary.h new file mode 100644 index 00000000..a8a9519c --- /dev/null +++ b/RoboCat/GraphicsLibrary.h @@ -0,0 +1,67 @@ +#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 +#include + +#include "Colour.h" + +//https://github.com/liballeg/allegro_wiki/wiki/Allegro-in-Visual-Studio#using-nuget-within-visual-studio +#include +#include +#include +#include +#include +#include + +class GraphicsLibrary +{ + //-------------------------Private data------------------------- + + //Screen data + float mScreenSizeX; + float mScreenSizeY; + + //Allegro display + ALLEGRO_DISPLAY* mpDisplay; + + //Other images to draw + std::vector> 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); +}; \ No newline at end of file diff --git a/RoboCat/Inc/RoboCatShared.h b/RoboCat/Inc/RoboCatShared.h index d7eac1bc..bc232e1f 100644 --- a/RoboCat/Inc/RoboCatShared.h +++ b/RoboCat/Inc/RoboCatShared.h @@ -51,15 +51,10 @@ class GameObject; #include "RoboMath.h" -#include "TransmissionData.h" -#include "InFlightPacket.h" - #include "LinkingContext.h" #include "ByteSwap.h" #include "MemoryBitStream.h" -#include "AckRange.h" -#include "Timing.h" #include "StringUtils.h" #include "SocketAddress.h" #include "SocketAddressFactory.h" @@ -67,4 +62,3 @@ class GameObject; #include "TCPSocket.h" #include "SocketUtil.h" #include "OutputWindow.h" -#include "DeliveryNotificationManager.h" diff --git a/RoboCat/InputSystem.cpp b/RoboCat/InputSystem.cpp new file mode 100644 index 00000000..3ab059ec --- /dev/null +++ b/RoboCat/InputSystem.cpp @@ -0,0 +1,136 @@ +/* +Allegro Wrapper Functions +Written by Adel Talhouk in FA21 +InputSystem.cpp +*/ + +#include "InputSystem.h" +#include "RoboCatPCH.h" + +#include + +//Constructor +InputSystem::InputSystem() +{ + //Create an event queue + mpEventQueue = al_create_event_queue(); +} + +//Destructor +InputSystem::~InputSystem() +{ + //Cleanup event queue + al_destroy_event_queue(mpEventQueue); + mpEventQueue = nullptr; +} + +float InputSystem::getMouseX() +{ + //Update mouse state + ALLEGRO_MOUSE_STATE mouseState; + al_get_mouse_state(&mouseState); + + return mouseState.x; +} + +float InputSystem::getMouseY() +{ + //Update mouse state + ALLEGRO_MOUSE_STATE mouseState; + al_get_mouse_state(&mouseState); + + return mouseState.y; +} + +std::pair InputSystem::getMousePosition() +{ + //Update mouse state + ALLEGRO_MOUSE_STATE mouseState; + al_get_mouse_state(&mouseState); + + return std::make_pair(mouseState.x, mouseState.y); +} + +//Init +bool InputSystem::init(GraphicsLibrary* pGraphicsLib) +{ + //Init keyboard + if (!al_install_keyboard()) + { + std::cout << "error installing Allegro keyboard plugin\n"; + system("pause"); + return false; + } + + //Init mouse + if (!al_install_mouse()) + { + std::cout << "error installing Allegro mouse plugin\n"; + system("pause"); + return false; + } + + //Register screen event source + al_register_event_source(mpEventQueue, al_get_display_event_source(pGraphicsLib->mpDisplay)); + + //Register keyboard event source + al_register_event_source(mpEventQueue, al_get_keyboard_event_source()); + + //Register mouse event source + al_register_event_source(mpEventQueue, al_get_mouse_event_source()); + + return true; +} + +MouseButton InputSystem::getMouseInput() +{ + //If there is an event + al_wait_for_event(mpEventQueue, &mEvent); + + if (mEvent.type == InputMode::MouseDown) + { + //Update mouse state + ALLEGRO_MOUSE_STATE mouseState; + al_get_mouse_state(&mouseState); + + //Check the button pressed + if (mouseState.buttons & 1) //Left mouse held + { + return MouseButton::LeftMouse; + } + else if (mouseState.buttons & 2) //Right mouse held + { + return MouseButton::RightMouse; + } + else if (mouseState.buttons & 4) //Middle mouse held + { + return MouseButton::MiddleMouse; + } + } +} + +KeyCode InputSystem::getKeyboardInput() +{ + //If there is an event + al_wait_for_event(mpEventQueue, &mEvent); + + if (mEvent.type == InputMode::KeyPressed) + { + //Check the type + switch (mEvent.keyboard.keycode) + { + case KeyCode::Escape: + return KeyCode::Escape; + break; + + case KeyCode::R: + return KeyCode::R; + break; + + default: + /*return KeyCode::NONE*/; + } + } + + //return KeyCode::NONE; +} \ No newline at end of file diff --git a/RoboCat/InputSystem.h b/RoboCat/InputSystem.h new file mode 100644 index 00000000..3a69029e --- /dev/null +++ b/RoboCat/InputSystem.h @@ -0,0 +1,68 @@ +#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 + +enum KeyCode +{ + Escape = ALLEGRO_KEY_ESCAPE, + R = ALLEGRO_KEY_R +}; + +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 getMousePosition(); + + //Functions + bool init(GraphicsLibrary* pGraphicsLib); + MouseButton getMouseInput(); + KeyCode getKeyboardInput(); +}; \ No newline at end of file diff --git a/RoboCat/Src/Main.cpp b/RoboCat/Src/Main.cpp index 3b0ac9de..3078e25c 100644 --- a/RoboCat/Src/Main.cpp +++ b/RoboCat/Src/Main.cpp @@ -1,8 +1,531 @@ - #include "RoboCatPCH.h" +#include "allegro_wrapper_functions-main/GraphicsLibrary.h" +#include "allegro_wrapper_functions-main/Colour.h" +#include "allegro_wrapper_functions-main/InputSystem.h" + +#include +#include +#include +#include + +using namespace std; #if _WIN32 +enum PacketTypes +{ + CREATE, + UPDATE, + DESTROY, + HELLO +}; + +enum ObjectTypes +{ + PLAYER, + COIN, + TOMATO +}; + +UDPSocketPtr CreateBoundSocket(std::string IP) +{ + UDPSocketPtr cliSock = SocketUtil::CreateUDPSocket(SocketAddressFamily::INET); + SocketAddressPtr cliAddr = SocketAddressFactory::CreateIPv4FromString(IP); + if (cliAddr == nullptr) + { + SocketUtil::ReportError("Create Client Socket"); + ExitProcess(1); + } + cliSock->Bind(*cliAddr); + return cliSock; +} + +class Packet +{ + private: + int* buffer; + long int timeStamp; + + public: + Packet(int* b, long int time) + { + buffer = b; + timeStamp = time; + } + + long int getTimeStamp() { return timeStamp; }; + int* getBuffer() { return buffer; }; + + friend bool operator<(const Packet& a, const Packet& b) + { + return a.timeStamp > b.timeStamp; + }; +}; + +class PlayerGameObject +{ + private: + int xPos; + int yPos; + string imageName; + bool isPlayer1; + public: + PlayerGameObject(int x, int y, string fileName, bool isPlayer) + { + xPos = x; + yPos = y; + imageName = fileName; + isPlayer1 = isPlayer; + }; + int getX() { return xPos; }; + int getY() { return yPos; }; + void Update(int keyPress) + { + if (isPlayer1) + { + switch (keyPress) + { + case KeyCode::P1_Down: + yPos += 7; + break; + case KeyCode::P1_Left: + xPos -= 7; + break; + case KeyCode::P1_Right: + xPos += 7; + break; + case KeyCode::P1_Up: + yPos -= 7; + break; + } + } + else + { + switch (keyPress) + { + case KeyCode::P2_Down: + yPos += 7; + break; + case KeyCode::P2_Left: + xPos -= 7; + break; + case KeyCode::P2_Right: + xPos += 7; + break; + case KeyCode::P2_Up: + yPos -= 7; + break; + } + } + }; + string getImageName() { return imageName; }; + void setX(int x) { xPos = x; }; + void setY(int y) { yPos = y; }; +}; + +class CoinObject +{ + private: + int xPos, yPos; + public: + CoinObject(int x, int y) { xPos = x; yPos = y; }; + int getX() { return xPos; }; + int getY() { return yPos; }; +}; + +class TomatoObject +{ + private: + int xPos, yPos; + double mTimeUntilNextFrame, msPerFrame = 1000/60; + public: + TomatoObject(int x, int y) { xPos = x; yPos = y; }; + int getX() { return xPos; }; + int getY() { return yPos; }; + void Update(double deltaTime) + { + mTimeUntilNextFrame -= deltaTime; + if (mTimeUntilNextFrame <= 0) + { + mTimeUntilNextFrame = msPerFrame; + xPos--; + } + }; +}; + +/* Timer - high accuracy timer - uses Large Integer to prevent rollover +Dean Lawson +Champlain College +2011 +*/ + +class Timer +{ + +private: + LARGE_INTEGER mStartTime; + LARGE_INTEGER mEndTime; + LARGE_INTEGER mTimerFrequency; + double mElapsedTime; + double mFactor; + double mLastFactor; + bool mPaused; + + //helper function - uses current frequency for the Timer + double calcDifferenceInMS(LARGE_INTEGER from, LARGE_INTEGER to) const + { + double difference = (double)(to.QuadPart - from.QuadPart) / (double)mTimerFrequency.QuadPart; + difference *= mFactor; + return difference * 1000; + } +public: + Timer() + :mElapsedTime(0.0) + , mPaused(true) + , mFactor(1.0) + , mLastFactor(1.0) + { + QueryPerformanceFrequency(&mTimerFrequency); + mStartTime.QuadPart = 0; + mEndTime.QuadPart = 0; + } + ~Timer() + { + } + + void start() + { + QueryPerformanceCounter(&mStartTime); + + //reset end time as well + mEndTime.QuadPart = 0; + + mElapsedTime = 0.0; + + pause(false);//unpause + } + void stop() + { + QueryPerformanceCounter(&mEndTime); + mElapsedTime = calcDifferenceInMS(mStartTime, mEndTime); + } + double getElapsedTime() const//returns how much time has elapsed since start + { + //if we have an end time then the timer isn't running and we can just return the elapsed time + if (mEndTime.QuadPart != 0) + { + return mElapsedTime; + } + else //otherwise we need to get the current time, do the math and return that + { + LARGE_INTEGER currentTime; + QueryPerformanceCounter(¤tTime); + return calcDifferenceInMS(mStartTime, currentTime); + } + } + void sleepUntilElapsed(double ms) + { + LARGE_INTEGER currentTime, lastTime; + QueryPerformanceCounter(¤tTime); + double timeToSleep = ms - calcDifferenceInMS(mStartTime, currentTime); + + while (timeToSleep > 0.0) + { + lastTime = currentTime; + QueryPerformanceCounter(¤tTime); + double timeElapsed = calcDifferenceInMS(lastTime, currentTime); + timeToSleep -= timeElapsed; + if (timeToSleep > 10.0)//if we are going to be in this loop for a long time - + { //Sleep to relinquish back to Windows + Sleep(10); + } + } + } + void pause(bool shouldPause) + { + if (shouldPause && !mPaused)//want to pause and we are not currently paused + { + mPaused = true; + QueryPerformanceCounter(&mEndTime); + mElapsedTime += calcDifferenceInMS(mStartTime, mEndTime); + } + else if (!shouldPause && mPaused)//want to unpause and we are paused + { + mPaused = false; + QueryPerformanceCounter(&mStartTime); + } + } + inline double getFactor() const { return mFactor; }; + inline void multFactor(double mult) { mLastFactor = mFactor; mFactor *= mult; }; + inline void setFactor(double theFactor) { mLastFactor = mFactor; mFactor = theFactor; }; + inline void restoreLastFactor() { mFactor = mLastFactor; }; + +}; + +class GameState +{ + private: + bool isServer; + UDPSocketPtr sock; + SocketAddress otherAddr; + GraphicsLibrary* mLibrary; + InputSystem* mInputSystem; + PlayerGameObject* mPlayer; + PlayerGameObject* otherPlayer; + vector vCoins; + TomatoObject* tomato; + double mTimePerFrame = 1000/60; + long int timeBeforeProcessing = 5; + priority_queue mReceivedPackets; + public: + GameState(bool serverState, string ourAddr, string other) + { + isServer = serverState; + sock = CreateBoundSocket(ourAddr); + sock->SetNonBlockingMode(true); + otherAddr = *(SocketAddressFactory::CreateIPv4FromString(other)); + cout << otherAddr.ToString() << endl; + mLibrary = new GraphicsLibrary(800, 600); + mLibrary->init("../2517597.jpg"); + mInputSystem = new InputSystem(); + mInputSystem->init(mLibrary); + if (isServer) + { + mLibrary->loadImage("../kirby.png", "Player"); + mLibrary->loadImage("../homie.png", "Other Player"); + mPlayer = new PlayerGameObject(650, 100, "../kirby.png", isServer); + otherPlayer = new PlayerGameObject(100, 100, "../homie.png", isServer); + } + else + { + mLibrary->loadImage("../kirby.png", "Other Player"); + mLibrary->loadImage("../homie.png", "Player"); + otherPlayer = new PlayerGameObject(650, 100, "../kirby.png", isServer); + mPlayer = new PlayerGameObject(100, 100, "../homie.png", isServer); + } + } + ~GameState() + { + delete mLibrary; + } + //change receive method to return the packet, put the packet in a priority (?) queue of returned packets along with a time stamp, only process packets received x seconds ago + void Update()//make time a part of this so that it runs the same rate on all systems + { + Timer timer; + mLibrary->loadImage("../2517597.jpg", "background"); + mLibrary->loadImage("../coin.png", "coin"); + mLibrary->loadImage("../tomato.png", "tomato"); + mLibrary->drawImage("background", 0, 0); + mLibrary->drawImage("Player", mPlayer->getX(), mPlayer->getY()); + mLibrary->drawImage("Other Player", otherPlayer->getX(), otherPlayer->getY()); + if (isServer) + { + tomato = new TomatoObject(800, rand() % 540 + 20); + for (int i = 0; i < 10; i++) + vCoins.push_back(new CoinObject(rand() % 700 + 50, rand() % 500 + 50)); + } + else + { + tomato = new TomatoObject(800, 800); + SendPacket(sock, &otherAddr, PacketTypes::HELLO, 1, 1, 1); + } + mLibrary->render(); + bool escapePressed = false; + + while (!escapePressed) + { + timer.start(); + if (isServer) + { + tomato->Update(mTimePerFrame); + SendPacket(sock, &otherAddr, PacketTypes::UPDATE, ObjectTypes::TOMATO, tomato->getX(), tomato->getY()); + SendCoinPacket(sock, &otherAddr, PacketTypes::UPDATE, ObjectTypes::COIN, vCoins); + CheckForCollisions(mPlayer); + CheckForCollisions(otherPlayer); + } + else + { + mReceivedPackets.push(new Packet(ReceivePacket(sock, &otherAddr), static_cast(time(NULL)) + rand() % 6 - 3)); + } + SendPacket(sock, &otherAddr, PacketTypes::UPDATE, ObjectTypes::PLAYER, mPlayer->getX(), mPlayer->getY()); + int* temp = ReceivePacket(sock, &otherAddr); + mReceivedPackets.push(new Packet(temp, static_cast(time(NULL)) + rand() % 6 - 3)); + + while (!mReceivedPackets.empty() && static_cast (time(NULL)) - mReceivedPackets.top()->getTimeStamp() < timeBeforeProcessing) + { + Packet* tempPacket = mReceivedPackets.top(); + mReceivedPackets.pop(); + if (tempPacket != nullptr) + { + processPacket(tempPacket->getBuffer()); + } + delete tempPacket; + } + + for (auto& coin : vCoins) + { + mLibrary->drawImage("coin", coin->getX(), coin->getY()); + } + + mLibrary->drawImage("tomato", tomato->getX(), tomato->getY()); + int keyPress = mInputSystem->getKeyboardInput(); + mPlayer->Update(keyPress); + mLibrary->drawImage("Player", mPlayer->getX(), mPlayer->getY()); + mLibrary->drawImage("Other Player", otherPlayer->getX(), otherPlayer->getY()); + if (keyPress == KeyCode::KeyEscape) + escapePressed = true; + + mLibrary->render(); + mLibrary->drawImage("background", 0, 0); + timer.sleepUntilElapsed(mTimePerFrame); + } + } + void SendPacket(UDPSocketPtr ptr, SocketAddress* addr, int packetType, int objectType, + int pos_x, int pos_y) + { + const int packetSize = sizeof(int) * 25; + int packet[packetSize / sizeof(int)]; + packet[0] = packetType; + packet[1] = objectType; + packet[2] = pos_x; + packet[3] = pos_y; + + if (rand() % 16 != 5) + { + int bytesSent = ptr->SendTo((char*)packet, packetSize, *addr); + if (bytesSent <= 0) + { + SocketUtil::ReportError("Client SendTo"); + } + } + } + void SendCoinPacket(UDPSocketPtr ptr, SocketAddress* addr, int packetType, int objectType, vector coins) + { + int packet[25]; + packet[0] = packetType; + packet[1] = objectType; + for (int i = 2; i < 22; i += 2) + { + packet[i] = coins[i / 2 - 1]->getX(); + packet[i + 1] = coins[i / 2 - 1]->getY(); + } + + char* bytePacket = (char*)packet; + if (rand() % 16 != 5) + { + int bytesSent = ptr->SendTo(bytePacket, 100, *addr); + if (bytesSent <= 0) + { + SocketUtil::ReportError("Client SendTo"); + } + } + } + int* ReceivePacket(UDPSocketPtr ptr, SocketAddress* addr) + { + char buffer[100]; + { + int bytesReceived = ptr->ReceiveFrom(buffer, 100, *addr); + if (bytesReceived < 0) + { + SocketUtil::ReportError("Error receiving packet"); + } + else if (bytesReceived == 0) + return nullptr; + else + { + char* packet = new char[100]; + for (int i = 0; i < 100; i++) + { + packet[i] = buffer[i]; + } + int* pac = (int*)packet; + cout << pac[2] << ", " << pac[3] << endl; + return pac; + } + } + return nullptr; + } + + void processPacket(int* packet) + { + if (packet != nullptr) + { + cout << packet[0] << endl; + switch (packet[0]) + { + case PacketTypes::UPDATE: + { + switch (packet[1]) + { + case ObjectTypes::PLAYER: + { + otherPlayer->setX(packet[2]); + otherPlayer->setY(packet[3]); + break; + } + case ObjectTypes::COIN: + { + cout << "coin packet received" << endl; + vCoins.clear(); + for (int i = 2; i < 22; i += 2) + { + vCoins.push_back(new CoinObject(packet[i], packet[i + 1])); + } + cout << vCoins.size() << endl; + break; + } + case ObjectTypes::TOMATO: + { + tomato = new TomatoObject(packet[2], packet[3]); + break; + } + } + break; + } + case PacketTypes::HELLO: + { + SendCoinPacket(sock, &otherAddr, PacketTypes::UPDATE, ObjectTypes::COIN, vCoins); + break; + } + } + } + } + + void CheckForCollisions(PlayerGameObject* player) + { + for (vector::iterator it = vCoins.begin(); it < vCoins.end(); it++) + { + CoinObject* coin = *it; + if (((player->getX() < coin->getX() && player->getX() + 100 > coin->getX())//top left corner + && (player->getY() < coin->getY() && player->getY() + 100 > coin->getY())) + || ((player->getX() < coin->getX() + 50 && player->getX() + 100 > coin->getX() + 50)//bottom right + && (player->getY() < coin->getY() + 50 && player->getY() + 100 > coin->getY() + 50)) + || ((player->getX() < coin->getX() + 50 && player->getX() + 100 > coin->getX() + 50)//top right + && (player->getY() < coin->getY() && player->getY() + 100 > coin->getY())) + || ((player->getX() < coin->getX() && player->getX() + 100 > coin->getX())//bottom left + && (player->getY() < coin->getY() + 50 && player->getY() + 100 > coin->getY() + 50))) + { + vCoins.erase(it); + delete coin; + vCoins.push_back(new CoinObject(rand() % 700 + 50, rand() % 500 + 50)); + SendCoinPacket(sock, &otherAddr, PacketTypes::UPDATE, ObjectTypes::COIN, vCoins); + break; + } + } + if (((player->getX() < tomato->getX() && player->getX() + 100 > tomato->getX())//top left corner + && (player->getY() < tomato->getY() && player->getY() + 100 > tomato->getY())) + || ((player->getX() < tomato->getX() + 30 && player->getX() + 100 > tomato->getX() + 30)//bottom right + && (player->getY() < tomato->getY() + 30 && player->getY() + 100 > tomato->getY() + 30)) + || ((player->getX() < tomato->getX() + 30 && player->getX() + 100 > tomato->getX() + 30)//top right + && (player->getY() < tomato->getY() && player->getY() + 100 > tomato->getY())) + || ((player->getX() < tomato->getX() && player->getX() + 100 > tomato->getX())//bottom left + && (player->getY() < tomato->getY() + 30 && player->getY() + 100 > tomato->getY() + 30)) + || tomato->getX() <= 0) + { + tomato = new TomatoObject(800, rand() % 540 + 20); + } + } +}; int main(int argc, const char** argv) { @@ -16,10 +539,27 @@ int main(int argc, const char** argv) __argc = argc; __argv = argv; #endif - + srand(time(NULL)); SocketUtil::StaticInit(); + GameState* state; + + bool isServer = StringUtils::GetCommandLineArg(1) == "server"; + + if (isServer) + { + state = new GameState(true, "localhost:9000", "localhost:9001"); + } + else + { + state = new GameState(false, "localhost:9001", "localhost:9000"); + } + + state->Update(); + SocketUtil::CleanUp(); + delete state; + return 0; } diff --git a/RoboCat/log.txt b/RoboCat/log.txt new file mode 100644 index 00000000..4eca3960 --- /dev/null +++ b/RoboCat/log.txt @@ -0,0 +1,5905 @@ +127.0.0.1:9000 +701, 307 +650, 100 +1 +1 +700, 307 +650, 100 +1 +1 +699, 307 +650, 100 +1 +1 +698, 307 +650, 100 +1 +1 +697, 307 +650, 100 +1 +1 +696, 307 +650, 100 +1 +1 +695, 307 +694, 307 +1 +1 +650, 100 +693, 307 +1 +1 +692, 307 +650, 100 +1 +1 +691, 307 +690, 307 +1 +1 +650, 100 +689, 307 +1 +1 +650, 100 +688, 307 +1 +1 +650, 100 +687, 307 +1 +1 +650, 100 +686, 307 +1 +1 +650, 100 +685, 307 +1 +1 +650, 100 +684, 307 +1 +1 +650, 100 +683, 307 +1 +1 +650, 100 +682, 307 +1 +1 +650, 100 +650, 100 +1 +1 +680, 307 +650, 100 +1 +1 +679, 307 +650, 100 +1 +1 +678, 307 +650, 100 +1 +1 +677, 307 +650, 100 +1 +1 +650, 100 +675, 307 +1 +1 +650, 100 +674, 307 +1 +1 +673, 307 +650, 100 +1 +1 +672, 307 +650, 100 +1 +1 +671, 307 +650, 100 +1 +1 +670, 307 +650, 100 +1 +1 +669, 307 +650, 100 +1 +1 +668, 307 +667, 307 +1 +1 +650, 100 +666, 307 +1 +1 +650, 100 +665, 307 +1 +1 +650, 100 +664, 307 +1 +1 +650, 100 +663, 307 +1 +1 +650, 100 +662, 307 +1 +1 +650, 100 +661, 307 +1 +1 +650, 100 +660, 307 +1 +1 +650, 100 +659, 307 +1 +1 +650, 100 +658, 307 +1 +1 +650, 100 +657, 307 +1 +1 +650, 100 +656, 307 +1 +1 +650, 100 +655, 307 +1 +1 +650, 100 +654, 307 +1 +1 +650, 100 +653, 307 +1 +1 +650, 100 +652, 307 +1 +1 +650, 100 +651, 307 +1 +1 +650, 100 +650, 307 +1 +1 +650, 100 +649, 307 +1 +1 +650, 100 +648, 307 +1 +1 +650, 100 +647, 307 +1 +1 +650, 100 +646, 307 +1 +1 +650, 100 +645, 307 +1 +1 +650, 100 +644, 307 +1 +1 +650, 100 +643, 307 +1 +1 +650, 100 +642, 307 +1 +1 +650, 100 +641, 307 +1 +1 +650, 100 +640, 307 +1 +1 +650, 100 +639, 307 +1 +1 +650, 100 +638, 307 +1 +1 +650, 100 +637, 307 +1 +1 +650, 100 +636, 307 +1 +1 +635, 307 +650, 100 +1 +1 +634, 307 +650, 100 +1 +1 +633, 307 +650, 100 +1 +1 +632, 307 +650, 100 +1 +1 +631, 307 +650, 100 +1 +1 +630, 307 +650, 100 +1 +1 +629, 307 +650, 100 +1 +1 +628, 307 +650, 100 +1 +1 +627, 307 +650, 100 +1 +1 +626, 307 +650, 100 +1 +1 +625, 307 +650, 100 +1 +1 +624, 307 +650, 100 +1 +1 +623, 307 +650, 100 +1 +1 +622, 307 +650, 100 +1 +1 +621, 307 +650, 100 +1 +1 +620, 307 +650, 100 +1 +1 +619, 307 +650, 100 +1 +1 +650, 100 +617, 307 +1 +1 +650, 100 +616, 307 +1 +1 +650, 100 +615, 307 +1 +1 +650, 100 +614, 307 +1 +1 +650, 100 +613, 307 +1 +1 +650, 100 +612, 307 +1 +1 +650, 100 +611, 307 +1 +1 +610, 307 +650, 100 +1 +1 +609, 307 +650, 100 +1 +1 +608, 307 +650, 100 +1 +1 +607, 307 +650, 100 +1 +1 +606, 307 +650, 100 +1 +1 +605, 307 +650, 100 +1 +1 +604, 307 +650, 100 +1 +1 +603, 307 +650, 100 +1 +1 +602, 307 +650, 100 +1 +1 +601, 307 +650, 100 +1 +1 +600, 307 +650, 100 +1 +1 +599, 307 +650, 100 +1 +1 +598, 307 +650, 100 +1 +1 +597, 307 +650, 100 +1 +1 +596, 307 +650, 100 +1 +1 +595, 307 +650, 100 +1 +1 +594, 307 +650, 100 +1 +1 +593, 307 +650, 100 +1 +1 +592, 307 +650, 100 +1 +1 +591, 307 +590, 307 +1 +1 +650, 100 +589, 307 +1 +1 +650, 100 +588, 307 +1 +1 +650, 100 +587, 307 +1 +1 +650, 100 +586, 307 +1 +1 +650, 100 +585, 307 +1 +1 +650, 100 +584, 307 +1 +1 +650, 100 +583, 307 +1 +1 +650, 100 +582, 307 +1 +1 +650, 100 +581, 307 +1 +1 +650, 100 +580, 307 +1 +1 +650, 100 +579, 307 +1 +1 +650, 100 +578, 307 +1 +1 +650, 100 +577, 307 +1 +1 +650, 100 +576, 307 +1 +1 +650, 100 +575, 307 +1 +1 +650, 100 +574, 307 +1 +1 +650, 100 +650, 100 +1 +1 +572, 307 +650, 100 +1 +1 +571, 307 +650, 100 +1 +1 +570, 307 +569, 307 +1 +1 +650, 100 +568, 307 +1 +1 +650, 100 +567, 307 +1 +1 +650, 100 +566, 307 +1 +1 +650, 100 +565, 307 +1 +1 +650, 100 +650, 100 +1 +1 +563, 307 +650, 100 +1 +1 +562, 307 +650, 100 +1 +1 +561, 307 +650, 100 +1 +1 +560, 307 +650, 100 +1 +1 +559, 307 +650, 100 +1 +1 +558, 307 +650, 100 +1 +1 +557, 307 +650, 100 +1 +1 +556, 307 +650, 100 +1 +1 +555, 307 +650, 100 +1 +1 +554, 307 +650, 100 +1 +1 +553, 307 +650, 100 +1 +1 +552, 307 +650, 100 +1 +1 +551, 307 +650, 100 +1 +1 +550, 307 +549, 307 +1 +1 +650, 100 +650, 100 +1 +1 +547, 307 +650, 100 +1 +1 +546, 307 +650, 100 +1 +1 +545, 307 +650, 100 +1 +1 +650, 100 +543, 307 +1 +1 +650, 100 +542, 307 +1 +1 +650, 100 +541, 307 +1 +1 +650, 100 +650, 100 +1 +1 +539, 307 +650, 100 +1 +1 +538, 307 +650, 100 +1 +1 +537, 307 +650, 100 +1 +1 +536, 307 +650, 100 +1 +1 +535, 307 +650, 100 +1 +1 +650, 100 +533, 307 +1 +1 +650, 100 +532, 307 +1 +1 +650, 100 +531, 307 +1 +1 +650, 100 +530, 307 +1 +1 +650, 100 +529, 307 +1 +1 +650, 100 +528, 307 +1 +1 +650, 100 +527, 307 +1 +1 +650, 100 +526, 307 +1 +1 +650, 100 +525, 307 +1 +1 +650, 100 +524, 307 +1 +1 +650, 100 +523, 307 +1 +1 +650, 100 +522, 307 +1 +1 +650, 100 +521, 307 +1 +1 +650, 100 +520, 307 +1 +1 +650, 100 +519, 307 +1 +1 +650, 100 +518, 307 +1 +1 +650, 100 +517, 307 +1 +1 +650, 100 +516, 307 +1 +1 +650, 100 +515, 307 +1 +1 +650, 100 +514, 307 +1 +1 +650, 100 +513, 307 +1 +1 +650, 100 +512, 307 +1 +1 +650, 100 +511, 307 +1 +1 +650, 100 +510, 307 +1 +1 +650, 100 +509, 307 +1 +1 +650, 100 +508, 307 +1 +1 +650, 100 +507, 307 +1 +1 +650, 100 +506, 307 +1 +1 +650, 100 +505, 307 +1 +1 +650, 100 +504, 307 +1 +1 +650, 100 +503, 307 +1 +1 +650, 100 +502, 307 +1 +1 +650, 100 +501, 307 +1 +1 +650, 100 +500, 307 +1 +1 +650, 100 +499, 307 +1 +1 +650, 100 +498, 307 +1 +1 +650, 100 +497, 307 +1 +1 +650, 100 +496, 307 +1 +1 +650, 100 +495, 307 +1 +1 +494, 307 +650, 100 +1 +1 +493, 307 +650, 100 +1 +1 +492, 307 +650, 100 +1 +1 +491, 307 +650, 100 +1 +1 +490, 307 +650, 100 +1 +1 +489, 307 +650, 100 +1 +1 +488, 307 +650, 100 +1 +1 +487, 307 +650, 100 +1 +1 +486, 307 +650, 100 +1 +1 +485, 307 +650, 100 +1 +1 +484, 307 +650, 100 +1 +1 +650, 100 +482, 307 +1 +1 +650, 100 +480, 307 +1 +1 +650, 100 +479, 307 +1 +1 +650, 100 +478, 307 +1 +1 +650, 100 +477, 307 +1 +1 +650, 100 +476, 307 +1 +1 +650, 100 +650, 100 +1 +1 +474, 307 +650, 100 +1 +1 +473, 307 +650, 100 +1 +1 +471, 307 +650, 100 +1 +1 +470, 307 +650, 100 +1 +1 +469, 307 +650, 100 +1 +1 +468, 307 +650, 100 +1 +1 +467, 307 +650, 100 +1 +1 +466, 307 +650, 100 +1 +1 +465, 307 +650, 100 +1 +1 +464, 307 +650, 100 +1 +1 +463, 307 +650, 100 +1 +1 +462, 307 +650, 100 +1 +1 +461, 307 +650, 100 +1 +1 +460, 307 +1 +459, 307 +650, 100 +1 +1 +458, 307 +650, 100 +1 +1 +457, 307 +650, 100 +1 +1 +456, 307 +650, 100 +1 +1 +455, 307 +650, 100 +1 +1 +454, 307 +650, 100 +1 +1 +453, 307 +650, 100 +1 +1 +452, 307 +650, 100 +1 +1 +451, 307 +650, 100 +1 +1 +450, 307 +650, 100 +1 +1 +449, 307 +650, 100 +1 +1 +650, 100 +1 +447, 307 +650, 100 +1 +1 +446, 307 +650, 100 +1 +1 +445, 307 +650, 100 +1 +1 +650, 100 +1 +443, 307 +650, 100 +1 +1 +442, 307 +650, 100 +1 +1 +441, 307 +650, 100 +1 +1 +440, 307 +650, 100 +1 +1 +439, 307 +650, 100 +1 +1 +438, 307 +650, 100 +1 +1 +437, 307 +650, 100 +1 +1 +650, 100 +1 +435, 307 +650, 100 +1 +1 +434, 307 +1 +433, 307 +650, 100 +1 +1 +432, 307 +650, 100 +1 +1 +431, 307 +650, 100 +1 +1 +650, 100 +1 +429, 307 +650, 100 +1 +1 +428, 307 +650, 100 +1 +1 +427, 307 +650, 100 +1 +1 +426, 307 +650, 100 +1 +1 +425, 307 +1 +424, 307 +650, 100 +1 +1 +423, 307 +650, 100 +1 +1 +422, 307 +650, 100 +1 +1 +421, 307 +650, 100 +1 +1 +420, 307 +1 +419, 307 +650, 100 +1 +1 +418, 307 +650, 100 +1 +1 +417, 307 +650, 100 +1 +1 +416, 307 +650, 100 +1 +1 +415, 307 +650, 100 +1 +1 +414, 307 +650, 100 +1 +1 +413, 307 +650, 100 +1 +1 +412, 307 +650, 100 +1 +1 +411, 307 +650, 100 +1 +1 +410, 307 +650, 100 +1 +1 +409, 307 +1 +408, 307 +1 +407, 307 +650, 100 +1 +1 +406, 307 +650, 100 +1 +1 +405, 307 +650, 100 +1 +1 +404, 307 +650, 100 +1 +1 +403, 307 +650, 100 +1 +1 +402, 307 +650, 100 +1 +1 +401, 307 +650, 100 +1 +1 +400, 307 +650, 100 +1 +1 +399, 307 +650, 100 +1 +1 +398, 307 +650, 100 +1 +1 +397, 307 +650, 100 +1 +1 +396, 307 +650, 100 +1 +1 +395, 307 +650, 100 +1 +1 +394, 307 +650, 100 +1 +1 +393, 307 +650, 100 +1 +1 +392, 307 +650, 100 +1 +1 +391, 307 +650, 100 +1 +1 +390, 307 +650, 100 +1 +1 +389, 307 +650, 100 +1 +1 +388, 307 +650, 100 +1 +1 +387, 307 +650, 100 +1 +1 +386, 307 +650, 100 +1 +1 +385, 307 +650, 100 +1 +1 +384, 307 +650, 100 +1 +1 +383, 307 +650, 100 +1 +1 +650, 100 +1 +381, 307 +650, 100 +1 +1 +380, 307 +1 +379, 307 +650, 100 +1 +1 +378, 307 +650, 100 +1 +1 +377, 307 +650, 100 +1 +1 +376, 307 +650, 100 +1 +1 +375, 307 +650, 100 +1 +1 +374, 307 +650, 100 +1 +1 +373, 307 +650, 100 +1 +1 +372, 307 +650, 100 +1 +1 +371, 307 +650, 100 +1 +1 +370, 307 +1 +369, 307 +1 +368, 307 +650, 100 +1 +1 +367, 307 +650, 100 +1 +1 +366, 307 +650, 100 +1 +1 +365, 307 +650, 100 +1 +1 +364, 307 +650, 100 +1 +1 +363, 307 +1 +362, 307 +1 +361, 307 +650, 100 +1 +1 +359, 307 +650, 100 +1 +1 +358, 307 +650, 100 +1 +1 +357, 307 +650, 100 +1 +1 +356, 307 +1 +355, 307 +650, 100 +1 +1 +354, 307 +650, 100 +1 +1 +353, 307 +650, 100 +1 +1 +352, 307 +1 +351, 307 +650, 100 +1 +1 +350, 307 +650, 100 +1 +1 +349, 307 +650, 100 +1 +1 +650, 100 +1 +347, 307 +650, 100 +1 +1 +346, 307 +650, 100 +1 +1 +345, 307 +650, 100 +1 +1 +344, 307 +650, 100 +1 +1 +343, 307 +650, 100 +1 +1 +342, 307 +1 +341, 307 +650, 100 +1 +1 +340, 307 +650, 100 +1 +1 +339, 307 +650, 100 +1 +1 +338, 307 +650, 100 +1 +1 +337, 307 +650, 100 +1 +1 +336, 307 +650, 100 +1 +1 +335, 307 +650, 100 +1 +1 +334, 307 +650, 100 +1 +1 +333, 307 +650, 100 +1 +1 +332, 307 +650, 100 +1 +1 +331, 307 +650, 100 +1 +1 +650, 100 +1 +329, 307 +650, 100 +1 +1 +328, 307 +650, 100 +1 +1 +327, 307 +650, 100 +1 +1 +326, 307 +650, 100 +1 +1 +650, 100 +1 +324, 307 +650, 100 +1 +1 +323, 307 +1 +322, 307 +650, 100 +1 +1 +321, 307 +650, 100 +1 +1 +320, 307 +650, 100 +1 +1 +319, 307 +650, 100 +1 +1 +318, 307 +1 +650, 100 +1 +316, 307 +1 +315, 307 +650, 100 +1 +1 +314, 307 +650, 100 +1 +1 +650, 100 +1 +312, 307 +650, 100 +1 +1 +311, 307 +650, 100 +1 +1 +650, 100 +1 +309, 307 +650, 100 +1 +1 +308, 307 +650, 100 +1 +1 +307, 307 +650, 100 +1 +1 +306, 307 +650, 100 +1 +1 +305, 307 +650, 100 +1 +1 +304, 307 +1 +303, 307 +650, 100 +1 +1 +302, 307 +650, 100 +1 +1 +301, 307 +650, 100 +1 +1 +300, 307 +650, 100 +1 +1 +299, 307 +650, 100 +1 +1 +298, 307 +650, 100 +1 +1 +297, 307 +650, 100 +1 +1 +296, 307 +650, 100 +1 +1 +295, 307 +650, 100 +1 +1 +294, 307 +650, 100 +1 +1 +293, 307 +650, 100 +1 +1 +292, 307 +650, 100 +1 +1 +291, 307 +650, 100 +1 +1 +290, 307 +650, 100 +1 +1 +289, 307 +650, 100 +1 +1 +288, 307 +650, 100 +1 +1 +287, 307 +650, 100 +1 +1 +650, 100 +1 +285, 307 +650, 100 +1 +1 +284, 307 +650, 100 +1 +1 +283, 307 +650, 100 +1 +1 +282, 307 +650, 100 +1 +1 +281, 307 +650, 100 +1 +1 +280, 307 +1 +279, 307 +650, 100 +1 +1 +278, 307 +650, 100 +1 +1 +277, 307 +650, 100 +1 +1 +276, 307 +650, 100 +1 +1 +650, 100 +1 +274, 307 +650, 100 +1 +1 +273, 307 +650, 100 +1 +1 +272, 307 +650, 100 +1 +1 +271, 307 +650, 100 +1 +1 +270, 307 +1 +269, 307 +650, 100 +1 +1 +268, 307 +650, 100 +1 +1 +267, 307 +650, 100 +1 +1 +266, 307 +1 +265, 307 +650, 100 +1 +1 +264, 307 +650, 100 +1 +1 +263, 307 +650, 100 +1 +1 +262, 307 +650, 100 +1 +1 +650, 100 +1 +260, 307 +650, 100 +1 +1 +259, 307 +650, 100 +1 +1 +258, 307 +650, 100 +1 +1 +257, 307 +650, 100 +1 +1 +256, 307 +650, 100 +1 +1 +255, 307 +650, 100 +1 +1 +254, 307 +650, 100 +1 +1 +253, 307 +650, 100 +1 +1 +252, 307 +650, 100 +1 +1 +251, 307 +650, 100 +1 +1 +250, 307 +650, 100 +1 +1 +650, 100 +1 +248, 307 +650, 100 +1 +1 +247, 307 +650, 100 +1 +1 +246, 307 +650, 100 +1 +1 +245, 307 +650, 100 +1 +1 +244, 307 +650, 100 +1 +1 +243, 307 +650, 100 +1 +1 +650, 100 +1 +241, 307 +650, 100 +1 +1 +240, 307 +1 +239, 307 +650, 100 +1 +1 +238, 307 +650, 100 +1 +1 +237, 307 +650, 100 +1 +1 +236, 307 +650, 100 +1 +1 +235, 307 +650, 100 +1 +1 +234, 307 +650, 100 +1 +1 +233, 307 +650, 100 +1 +1 +232, 307 +650, 100 +1 +1 +231, 307 +650, 100 +1 +1 +230, 307 +650, 100 +1 +1 +229, 307 +650, 100 +1 +1 +228, 307 +650, 100 +1 +1 +227, 307 +650, 100 +1 +1 +226, 307 +650, 100 +1 +1 +225, 307 +650, 100 +1 +1 +224, 307 +650, 100 +1 +1 +223, 307 +650, 100 +1 +1 +222, 307 +650, 100 +1 +1 +221, 307 +650, 100 +1 +1 +220, 307 +650, 100 +1 +1 +219, 307 +1 +218, 307 +650, 100 +1 +1 +217, 307 +650, 100 +1 +1 +216, 307 +650, 100 +1 +1 +215, 307 +650, 100 +1 +1 +214, 307 +650, 100 +1 +1 +213, 307 +650, 100 +1 +1 +212, 307 +650, 100 +1 +1 +211, 307 +650, 100 +1 +1 +210, 307 +650, 100 +1 +1 +209, 307 +650, 100 +1 +1 +208, 307 +650, 100 +1 +1 +650, 100 +1 +206, 307 +650, 100 +1 +1 +205, 307 +650, 100 +1 +1 +204, 307 +650, 100 +1 +1 +203, 307 +650, 100 +1 +1 +202, 307 +650, 100 +1 +1 +201, 307 +650, 100 +1 +1 +200, 307 +650, 100 +1 +1 +199, 307 +650, 100 +1 +1 +198, 307 +1 +197, 307 +1 +196, 307 +650, 100 +1 +1 +195, 307 +650, 100 +1 +1 +194, 307 +1 +193, 307 +650, 100 +1 +1 +192, 307 +650, 100 +1 +1 +191, 307 +650, 100 +1 +1 +190, 307 +650, 100 +1 +1 +189, 307 +650, 100 +1 +1 +188, 307 +650, 100 +1 +1 +187, 307 +650, 100 +1 +1 +186, 307 +650, 100 +1 +1 +185, 307 +650, 100 +1 +1 +184, 307 +650, 100 +1 +1 +183, 307 +650, 100 +1 +1 +182, 307 +650, 100 +1 +1 +181, 307 +650, 100 +1 +1 +180, 307 +650, 100 +1 +1 +179, 307 +650, 100 +1 +1 +178, 307 +650, 100 +1 +1 +177, 307 +650, 100 +1 +1 +176, 307 +650, 100 +1 +1 +650, 100 +1 +174, 307 +650, 100 +1 +1 +173, 307 +650, 100 +1 +1 +172, 307 +650, 100 +1 +1 +650, 100 +1 +170, 307 +650, 100 +1 +1 +169, 307 +650, 100 +1 +1 +168, 307 +650, 100 +1 +1 +167, 307 +650, 100 +1 +1 +166, 307 +650, 100 +1 +1 +165, 307 +650, 100 +1 +1 +164, 307 +650, 100 +1 +1 +163, 307 +650, 100 +1 +1 +162, 307 +650, 100 +1 +1 +161, 307 +1 +160, 307 +650, 100 +1 +1 +159, 307 +650, 100 +1 +1 +158, 307 +650, 100 +1 +1 +157, 307 +650, 100 +1 +1 +156, 307 +650, 100 +1 +1 +155, 307 +650, 100 +1 +1 +154, 307 +650, 100 +1 +1 +153, 307 +650, 100 +1 +1 +650, 100 +1 +151, 307 +650, 100 +1 +1 +150, 307 +650, 100 +1 +1 +149, 307 +650, 100 +1 +1 +148, 307 +650, 100 +1 +1 +147, 307 +1 +146, 307 +650, 100 +1 +1 +145, 307 +650, 100 +1 +1 +144, 307 +650, 100 +1 +1 +143, 307 +650, 100 +1 +1 +650, 100 +1 +141, 307 +650, 100 +1 +1 +140, 307 +650, 100 +1 +1 +139, 307 +650, 100 +1 +1 +138, 307 +650, 100 +1 +1 +650, 100 +1 +136, 307 +650, 100 +1 +1 +135, 307 +650, 100 +1 +1 +134, 307 +1 +133, 307 +650, 100 +1 +1 +132, 307 +650, 100 +1 +1 +131, 307 +650, 100 +1 +1 +130, 307 +650, 100 +1 +1 +129, 307 +650, 100 +1 +1 +128, 307 +650, 100 +1 +1 +127, 307 +650, 100 +1 +1 +126, 307 +650, 100 +1 +1 +125, 307 +650, 100 +1 +1 +124, 307 +650, 100 +1 +1 +123, 307 +650, 100 +1 +1 +122, 307 +650, 100 +1 +1 +121, 307 +650, 100 +1 +1 +120, 307 +650, 100 +1 +1 +119, 307 +650, 100 +1 +1 +118, 307 +650, 100 +1 +1 +117, 307 +650, 100 +1 +1 +116, 307 +650, 100 +1 +1 +115, 307 +650, 100 +1 +1 +114, 307 +650, 100 +1 +1 +113, 307 +650, 100 +1 +1 +112, 307 +650, 100 +1 +1 +111, 307 +650, 100 +1 +1 +110, 307 +650, 100 +1 +1 +109, 307 +650, 100 +1 +1 +108, 307 +650, 100 +1 +1 +107, 307 +650, 100 +1 +1 +106, 307 +650, 100 +1 +1 +105, 307 +650, 100 +1 +1 +104, 307 +650, 100 +1 +1 +103, 307 +650, 100 +1 +1 +102, 307 +650, 100 +1 +1 +101, 307 +650, 100 +1 +1 +100, 307 +1 +99, 307 +650, 100 +1 +1 +98, 307 +650, 100 +1 +1 +97, 307 +650, 100 +1 +1 +96, 307 +650, 100 +1 +1 +95, 307 +650, 100 +1 +1 +94, 307 +650, 100 +1 +1 +93, 307 +650, 100 +1 +1 +92, 307 +650, 100 +1 +1 +91, 307 +650, 100 +1 +1 +650, 100 +1 +89, 307 +650, 100 +1 +1 +88, 307 +650, 100 +1 +1 +87, 307 +650, 100 +1 +1 +86, 307 +650, 100 +1 +1 +85, 307 +650, 100 +1 +1 +84, 307 +650, 100 +1 +1 +83, 307 +650, 100 +1 +1 +82, 307 +650, 100 +1 +1 +81, 307 +650, 100 +1 +1 +650, 100 +1 +79, 307 +650, 100 +1 +1 +78, 307 +1 +77, 307 +650, 100 +1 +1 +76, 307 +650, 100 +1 +1 +75, 307 +650, 100 +1 +1 +74, 307 +650, 100 +1 +1 +650, 100 +1 +72, 307 +650, 100 +1 +1 +71, 307 +650, 100 +1 +1 +70, 307 +1 +69, 307 +650, 100 +1 +1 +68, 307 +650, 100 +1 +1 +67, 307 +650, 100 +1 +1 +66, 307 +650, 100 +1 +1 +650, 100 +1 +64, 307 +650, 100 +1 +1 +63, 307 +650, 100 +1 +1 +62, 307 +650, 100 +1 +1 +61, 307 +650, 100 +1 +1 +60, 307 +650, 100 +1 +1 +59, 307 +650, 100 +1 +1 +58, 307 +650, 100 +1 +1 +57, 307 +650, 100 +1 +1 +56, 307 +650, 100 +1 +1 +55, 307 +650, 100 +1 +1 +54, 307 +650, 100 +1 +1 +53, 307 +650, 100 +1 +1 +52, 307 +650, 100 +1 +1 +51, 307 +650, 100 +1 +1 +50, 307 +650, 100 +1 +1 +49, 307 +650, 100 +1 +1 +48, 307 +1 +47, 307 +650, 100 +1 +1 +46, 307 +650, 100 +1 +1 +45, 307 +650, 100 +1 +1 +44, 307 +650, 100 +1 +1 +43, 307 +650, 100 +1 +1 +42, 307 +650, 100 +1 +1 +650, 100 +1 +40, 307 +650, 100 +1 +1 +39, 307 +650, 100 +1 +1 +38, 307 +650, 100 +1 +1 +37, 307 +650, 100 +1 +1 +36, 307 +1 +35, 307 +650, 100 +1 +1 +34, 307 +650, 100 +1 +1 +33, 307 +650, 100 +1 +1 +32, 307 +650, 100 +1 +1 +31, 307 +650, 100 +1 +1 +30, 307 +650, 100 +1 +1 +29, 307 +650, 100 +1 +1 +28, 307 +650, 100 +1 +1 +27, 307 +650, 100 +1 +1 +26, 307 +650, 100 +1 +1 +25, 307 +650, 100 +1 +1 +24, 307 +650, 100 +1 +1 +23, 307 +650, 100 +1 +1 +22, 307 +650, 100 +1 +1 +21, 307 +650, 100 +1 +1 +20, 307 +650, 100 +1 +1 +19, 307 +650, 100 +1 +1 +18, 307 +650, 100 +1 +1 +17, 307 +650, 100 +1 +1 +16, 307 +650, 100 +1 +1 +15, 307 +650, 100 +1 +1 +14, 307 +650, 100 +1 +1 +13, 307 +650, 100 +1 +1 +12, 307 +650, 100 +1 +1 +11, 307 +650, 100 +1 +1 +10, 307 +650, 100 +1 +1 +9, 307 +650, 100 +1 +1 +8, 307 +650, 100 +1 +1 +7, 307 +650, 100 +1 +1 +6, 307 +650, 100 +1 +1 +5, 307 +650, 100 +1 +1 +4, 307 +650, 100 +1 +1 +3, 307 +650, 100 +1 +1 +2, 307 +650, 100 +1 +1 +1, 307 +650, 100 +1 +1 +0, 307 +650, 100 +1 +1 +799, 446 +650, 100 +1 +1 +798, 446 +650, 100 +1 +1 +797, 446 +650, 100 +1 +1 +796, 446 +650, 100 +1 +1 +795, 446 +650, 100 +1 +1 +794, 446 +650, 100 +1 +1 +793, 446 +650, 100 +1 +1 +792, 446 +650, 100 +1 +1 +790, 446 +650, 100 +1 +1 +789, 446 +650, 100 +1 +1 +788, 446 +650, 100 +1 +1 +787, 446 +650, 100 +1 +1 +650, 100 +1 +785, 446 +650, 100 +1 +1 +784, 446 +650, 100 +1 +1 +783, 446 +650, 100 +1 +1 +782, 446 +1 +781, 446 +650, 100 +1 +1 +780, 446 +650, 100 +1 +1 +779, 446 +650, 100 +1 +1 +778, 446 +650, 100 +1 +1 +777, 446 +650, 100 +1 +1 +776, 446 +650, 100 +1 +1 +775, 446 +650, 100 +1 +1 +774, 446 +650, 100 +1 +1 +773, 446 +650, 100 +1 +1 +772, 446 +650, 100 +1 +1 +771, 446 +650, 100 +1 +1 +770, 446 +1 +769, 446 +650, 100 +1 +1 +768, 446 +650, 100 +1 +1 +650, 100 +1 +766, 446 +650, 100 +1 +1 +765, 446 +650, 100 +1 +1 +764, 446 +650, 100 +1 +1 +763, 446 +650, 100 +1 +1 +762, 446 +650, 100 +1 +1 +761, 446 +650, 100 +1 +1 +760, 446 +650, 100 +1 +1 +759, 446 +650, 100 +1 +1 +758, 446 +650, 100 +1 +1 +757, 446 +650, 100 +1 +1 +756, 446 +650, 100 +1 +1 +755, 446 +650, 100 +1 +1 +754, 446 +650, 100 +1 +1 +753, 446 +650, 100 +1 +1 +752, 446 +650, 100 +1 +1 +751, 446 +1 +750, 446 +650, 100 +1 +1 +749, 446 +650, 100 +1 +1 +748, 446 +650, 100 +1 +1 +747, 446 +650, 100 +1 +1 +746, 446 +650, 100 +1 +1 +650, 100 +1 +744, 446 +650, 100 +1 +1 +743, 446 +650, 100 +1 +1 +742, 446 +650, 100 +1 +1 +650, 100 +1 +740, 446 +1 +739, 446 +650, 100 +1 +1 +738, 446 +1 +737, 446 +650, 100 +1 +1 +736, 446 +650, 100 +1 +1 +735, 446 +650, 100 +1 +1 +734, 446 +650, 100 +1 +1 +733, 446 +650, 100 +1 +1 +732, 446 +650, 100 +1 +1 +731, 446 +650, 100 +1 +1 +730, 446 +650, 100 +1 +1 +729, 446 +650, 100 +1 +1 +728, 446 +650, 100 +1 +1 +727, 446 +650, 100 +1 +1 +726, 446 +650, 100 +1 +1 +725, 446 +650, 100 +1 +1 +724, 446 +1 +723, 446 +650, 100 +1 +1 +722, 446 +650, 100 +1 +1 +721, 446 +650, 100 +1 +1 +720, 446 +650, 100 +1 +1 +719, 446 +650, 100 +1 +1 +718, 446 +1 +717, 446 +650, 100 +1 +1 +716, 446 +650, 100 +1 +1 +715, 446 +1 +714, 446 +650, 100 +1 +1 +713, 446 +650, 100 +1 +1 +712, 446 +650, 100 +1 +1 +711, 446 +650, 100 +1 +1 +710, 446 +650, 100 +1 +1 +709, 446 +650, 100 +1 +1 +708, 446 +650, 100 +1 +1 +707, 446 +650, 100 +1 +1 +706, 446 +650, 100 +1 +1 +705, 446 +650, 100 +1 +1 +704, 446 +650, 100 +1 +1 +703, 446 +650, 100 +1 +1 +702, 446 +650, 100 +1 +1 +701, 446 +650, 100 +1 +1 +700, 446 +650, 100 +1 +1 +650, 100 +1 +698, 446 +650, 100 +1 +1 +697, 446 +650, 100 +1 +1 +696, 446 +650, 100 +1 +1 +695, 446 +650, 100 +1 +1 +694, 446 +650, 100 +1 +1 +693, 446 +650, 100 +1 +1 +650, 100 +1 +691, 446 +650, 100 +1 +1 +690, 446 +650, 100 +1 +1 +689, 446 +650, 107 +1 +1 +688, 446 +650, 107 +1 +1 +650, 107 +1 +686, 446 +650, 107 +1 +1 +685, 446 +650, 107 +1 +1 +684, 446 +650, 107 +1 +1 +683, 446 +1 +682, 446 +650, 107 +1 +1 +365, 313 +681, 446 +1 +1 +coin packet received +9 +650, 107 +680, 446 +1 +1 +650, 107 +679, 446 +1 +1 +678, 446 +650, 107 +1 +1 +677, 446 +650, 107 +1 +1 +676, 446 +650, 114 +1 +1 +675, 446 +650, 114 +1 +1 +674, 446 +650, 114 +1 +1 +673, 446 +650, 114 +1 +1 +672, 446 +650, 114 +1 +1 +671, 446 +650, 114 +1 +1 +670, 446 +650, 114 +1 +1 +669, 446 +1 +668, 446 +650, 114 +1 +1 +667, 446 +650, 114 +1 +1 +666, 446 +650, 114 +1 +1 +665, 446 +650, 114 +1 +1 +664, 446 +1 +663, 446 +650, 114 +1 +1 +662, 446 +650, 114 +1 +1 +661, 446 +650, 114 +1 +1 +660, 446 +650, 114 +1 +1 +659, 446 +650, 114 +1 +1 +658, 446 +650, 114 +1 +1 +657, 446 +650, 114 +1 +1 +656, 446 +650, 114 +1 +1 +655, 446 +1 +654, 446 +650, 114 +1 +1 +653, 446 +650, 114 +1 +1 +652, 446 +650, 114 +1 +1 +651, 446 +1 +650, 446 +650, 114 +1 +1 +649, 446 +650, 114 +1 +1 +648, 446 +650, 114 +1 +1 +647, 446 +650, 114 +1 +1 +646, 446 +650, 114 +1 +1 +645, 446 +650, 114 +1 +1 +644, 446 +650, 114 +1 +1 +643, 446 +650, 114 +1 +1 +642, 446 +650, 114 +1 +1 +641, 446 +650, 114 +1 +1 +640, 446 +650, 114 +1 +1 +639, 446 +650, 114 +1 +1 +638, 446 +650, 114 +1 +1 +637, 446 +650, 114 +1 +1 +636, 446 +650, 114 +1 +1 +635, 446 +650, 114 +1 +1 +650, 114 +1 +633, 446 +650, 114 +1 +1 +650, 114 +1 +631, 446 +650, 114 +1 +1 +630, 446 +650, 114 +1 +1 +629, 446 +650, 114 +1 +1 +628, 446 +650, 114 +1 +1 +627, 446 +650, 114 +1 +1 +626, 446 +650, 114 +1 +1 +625, 446 +650, 114 +1 +1 +624, 446 +650, 114 +1 +1 +623, 446 +650, 114 +1 +1 +622, 446 +650, 114 +1 +1 +621, 446 +650, 114 +1 +1 +620, 446 +650, 114 +1 +1 +619, 446 +650, 114 +1 +1 +618, 446 +650, 114 +1 +1 +617, 446 +650, 114 +1 +1 +616, 446 +650, 114 +1 +1 +650, 114 +1 +614, 446 +650, 114 +1 +1 +613, 446 +650, 114 +1 +1 +612, 446 +650, 114 +1 +1 +650, 114 +1 +610, 446 +650, 114 +1 +1 +609, 446 +650, 114 +1 +1 +608, 446 +650, 114 +1 +1 +607, 446 +650, 114 +1 +1 +606, 446 +650, 114 +1 +1 +605, 446 +650, 114 +1 +1 +650, 114 +1 +650, 114 +1 +650, 114 +1 +650, 114 +1 +600, 446 +650, 114 +1 +1 +599, 446 +650, 114 +1 +1 +598, 446 +650, 114 +1 +1 +597, 446 +650, 114 +1 +1 +596, 446 +650, 114 +1 +1 +595, 446 +650, 114 +1 +1 +594, 446 +1 +593, 446 +1 +592, 446 +650, 114 +1 +1 +591, 446 +650, 114 +1 +1 +590, 446 +650, 114 +1 +1 +650, 114 +1 +588, 446 +650, 114 +1 +1 +587, 446 +650, 114 +1 +1 +586, 446 +650, 114 +1 +1 +585, 446 +650, 114 +1 +1 +584, 446 +650, 114 +1 +1 +583, 446 +650, 114 +1 +1 +582, 446 +650, 114 +1 +1 +581, 446 +650, 114 +1 +1 +580, 446 +650, 114 +1 +1 +579, 446 +650, 114 +1 +1 +578, 446 +650, 114 +1 +1 +577, 446 +1 +576, 446 +650, 114 +1 +1 +575, 446 +650, 114 +1 +1 +574, 446 +650, 114 +1 +1 +573, 446 +650, 114 +1 +1 +572, 446 +1 +571, 446 +650, 114 +1 +1 +650, 114 +1 +569, 446 +650, 114 +1 +1 +568, 446 +650, 114 +1 +1 +567, 446 +650, 114 +1 +1 +566, 446 +650, 114 +1 +1 +565, 446 +650, 114 +1 +1 +564, 446 +650, 114 +1 +1 +563, 446 +650, 114 +1 +1 +562, 446 +650, 114 +1 +1 +561, 446 +1 +560, 446 +650, 114 +1 +1 +559, 446 +650, 114 +1 +1 +558, 446 +650, 114 +1 +1 +557, 446 +650, 114 +1 +1 +556, 446 +650, 114 +1 +1 +555, 446 +650, 114 +1 +1 +554, 446 +650, 114 +1 +1 +553, 446 +650, 114 +1 +1 +552, 446 +650, 114 +1 +1 +551, 446 +650, 114 +1 +1 +550, 446 +650, 114 +1 +1 +650, 114 +1 +548, 446 +650, 114 +1 +1 +547, 446 +650, 114 +1 +1 +546, 446 +650, 114 +1 +1 +545, 446 +650, 114 +1 +1 +544, 446 +650, 114 +1 +1 +543, 446 +1 +542, 446 +650, 114 +1 +1 +541, 446 +650, 114 +1 +1 +650, 114 +1 +539, 446 +650, 114 +1 +1 +538, 446 +650, 114 +1 +1 +537, 446 +650, 114 +1 +1 +536, 446 +650, 114 +1 +1 +535, 446 +650, 114 +1 +1 +534, 446 +650, 114 +1 +1 +533, 446 +650, 114 +1 +1 +532, 446 +650, 114 +1 +1 +531, 446 +650, 114 +1 +1 +530, 446 +650, 114 +1 +1 +650, 114 +1 +528, 446 +650, 114 +1 +1 +527, 446 +650, 114 +1 +1 +526, 446 +650, 114 +1 +1 +525, 446 +650, 114 +1 +1 +524, 446 +650, 114 +1 +1 +523, 446 +650, 114 +1 +1 +522, 446 +650, 114 +1 +1 +521, 446 +650, 114 +1 +1 +520, 446 +650, 114 +1 +1 +519, 446 +650, 114 +1 +1 +518, 446 +650, 114 +1 +1 +517, 446 +650, 114 +1 +1 +516, 446 +650, 114 +1 +1 +515, 446 +650, 114 +1 +1 +650, 114 +1 +513, 446 +650, 114 +1 +1 +512, 446 +650, 114 +1 +1 +650, 114 +1 +510, 446 +650, 114 +1 +1 +509, 446 +650, 114 +1 +1 +508, 446 +650, 114 +1 +1 +507, 446 +650, 114 +1 +1 +506, 446 +650, 114 +1 +1 +505, 446 +650, 114 +1 +1 +504, 446 +650, 114 +1 +1 +503, 446 +650, 114 +1 +1 +502, 446 +1 +501, 446 +650, 114 +1 +1 +500, 446 +650, 114 +1 +1 +499, 446 +650, 114 +1 +1 +498, 446 +650, 114 +1 +1 +497, 446 +650, 114 +1 +1 +496, 446 +650, 114 +1 +1 +495, 446 +650, 114 +1 +1 +494, 446 +650, 114 +1 +1 +493, 446 +650, 114 +1 +1 +492, 446 +650, 114 +1 +1 +491, 446 +650, 114 +1 +1 +490, 446 +650, 114 +1 +1 +489, 446 +1 +488, 446 +650, 114 +1 +1 +487, 446 +650, 114 +1 +1 +486, 446 +650, 114 +1 +1 +485, 446 +650, 114 +1 +1 +484, 446 +650, 114 +1 +1 +483, 446 +650, 114 +1 +1 +482, 446 +650, 114 +1 +1 +481, 446 +650, 114 +1 +1 +480, 446 +650, 114 +1 +1 +479, 446 +650, 114 +1 +1 +478, 446 +650, 114 +1 +1 +477, 446 +650, 114 +1 +1 +476, 446 +650, 114 +1 +1 +475, 446 +650, 114 +1 +1 +474, 446 +650, 114 +1 +1 +473, 446 +1 +472, 446 +650, 114 +1 +1 +471, 446 +650, 114 +1 +1 +470, 446 +650, 114 +1 +1 +469, 446 +650, 114 +1 +1 +468, 446 +650, 114 +1 +1 +467, 446 +650, 114 +1 +1 +466, 446 +650, 114 +1 +1 +465, 446 +650, 114 +1 +1 +464, 446 +650, 114 +1 +1 +463, 446 +650, 114 +1 +1 +462, 446 +650, 114 +1 +1 +461, 446 +650, 114 +1 +1 +460, 446 +650, 114 +1 +1 +459, 446 +650, 114 +1 +1 +458, 446 +650, 114 +1 +1 +457, 446 +650, 114 +1 +1 +456, 446 +650, 114 +1 +1 +455, 446 +650, 114 +1 +1 +454, 446 +650, 114 +1 +1 +453, 446 +650, 114 +1 +1 +452, 446 +650, 114 +1 +1 +451, 446 +650, 114 +1 +1 +450, 446 +650, 114 +1 +1 +449, 446 +650, 114 +1 +1 +448, 446 +650, 114 +1 +1 +447, 446 +650, 114 +1 +1 +446, 446 +650, 114 +1 +1 +445, 446 +650, 114 +1 +1 +444, 446 +650, 114 +1 +1 +443, 446 +650, 114 +1 +1 +442, 446 +650, 114 +1 +1 +441, 446 +650, 114 +1 +1 +440, 446 +650, 114 +1 +1 +439, 446 +650, 114 +1 +1 +438, 446 +650, 114 +1 +1 +437, 446 +650, 114 +1 +1 +436, 446 +650, 114 +1 +1 +435, 446 +650, 114 +1 +1 +434, 446 +650, 114 +1 +1 +433, 446 +650, 114 +1 +1 +432, 446 +650, 114 +1 +1 +431, 446 +650, 114 +1 +1 +430, 446 +650, 114 +1 +1 +429, 446 +650, 114 +1 +1 +428, 446 +650, 114 +1 +1 +427, 446 +650, 114 +1 +1 +426, 446 +650, 114 +1 +1 +650, 114 +1 +424, 446 +650, 114 +1 +1 +423, 446 +650, 114 +1 +1 +422, 446 +650, 114 +1 +1 +421, 446 +650, 114 +1 +1 +420, 446 +650, 114 +1 +1 +419, 446 +650, 114 +1 +1 +418, 446 +650, 114 +1 +1 +417, 446 +650, 114 +1 +1 +416, 446 +1 +415, 446 +650, 114 +1 +1 +414, 446 +650, 114 +1 +1 +413, 446 +650, 114 +1 +1 +412, 446 +650, 114 +1 +1 +411, 446 +1 +410, 446 +650, 114 +1 +1 +409, 446 +650, 114 +1 +1 +408, 446 +1 +407, 446 +650, 114 +1 +1 +406, 446 +650, 114 +1 +1 +405, 446 +650, 114 +1 +1 +404, 446 +650, 114 +1 +1 +403, 446 +650, 114 +1 +1 +402, 446 +650, 114 +1 +1 +401, 446 +650, 114 +1 +1 +400, 446 +650, 114 +1 +1 +399, 446 +650, 114 +1 +1 +398, 446 +1 +397, 446 +1 +396, 446 +650, 114 +1 +1 +395, 446 +650, 114 +1 +1 +394, 446 +650, 114 +1 +1 +393, 446 +650, 114 +1 +1 +392, 446 +650, 114 +1 +1 +391, 446 +650, 114 +1 +1 +390, 446 +650, 114 +1 +1 +389, 446 +650, 114 +1 +1 +388, 446 +650, 114 +1 +1 +387, 446 +650, 114 +1 +1 +386, 446 +650, 114 +1 +1 +385, 446 +650, 114 +1 +1 +384, 446 +650, 114 +1 +1 +383, 446 +650, 114 +1 +1 +650, 114 +1 +381, 446 +650, 114 +1 +1 +380, 446 +650, 114 +1 +1 +379, 446 +650, 114 +1 +1 +378, 446 +650, 114 +1 +1 +377, 446 +650, 114 +1 +1 +376, 446 +650, 114 +1 +1 +375, 446 +650, 114 +1 +1 +374, 446 +650, 114 +1 +1 +373, 446 +1 +372, 446 +650, 114 +1 +1 +371, 446 +650, 114 +1 +1 +370, 446 +650, 114 +1 +1 +369, 446 +650, 114 +1 +1 +368, 446 +650, 114 +1 +1 +367, 446 +650, 114 +1 +1 +366, 446 +650, 114 +1 +1 +365, 446 +650, 114 +1 +1 +364, 446 +650, 114 +1 +1 +363, 446 +650, 114 +1 +1 +362, 446 +650, 114 +1 +1 +361, 446 +650, 114 +1 +1 +360, 446 +650, 114 +1 +1 +359, 446 +650, 114 +1 +1 +358, 446 +650, 114 +1 +1 +357, 446 +650, 114 +1 +1 +356, 446 +650, 114 +1 +1 +355, 446 +650, 114 +1 +1 +354, 446 +650, 114 +1 +1 +353, 446 +650, 114 +1 +1 +352, 446 +650, 114 +1 +1 +351, 446 +650, 114 +1 +1 +350, 446 +650, 114 +1 +1 +349, 446 +650, 114 +1 +1 +348, 446 +1 +347, 446 +650, 114 +1 +1 +346, 446 +650, 114 +1 +1 +345, 446 +650, 114 +1 +1 +344, 446 +650, 114 +1 +1 +343, 446 +650, 114 +1 +1 +342, 446 +650, 114 +1 +1 +341, 446 +650, 114 +1 +1 +340, 446 +650, 114 +1 +1 +339, 446 +650, 114 +1 +1 +338, 446 +650, 114 +1 +1 +337, 446 +650, 114 +1 +1 +336, 446 +650, 114 +1 +1 +335, 446 +650, 114 +1 +1 +334, 446 +650, 114 +1 +1 +333, 446 +650, 114 +1 +1 +332, 446 +650, 114 +1 +1 +331, 446 +650, 114 +1 +1 +330, 446 +650, 114 +1 +1 +650, 114 +1 +328, 446 +650, 114 +1 +1 +327, 446 +650, 114 +1 +1 +326, 446 +650, 114 +1 +1 +325, 446 +650, 114 +1 +1 +324, 446 +650, 114 +1 +1 +323, 446 +650, 114 +1 +1 +322, 446 +650, 114 +1 +1 +321, 446 +650, 114 +1 +1 +320, 446 +650, 114 +1 +1 +319, 446 +650, 114 +1 +1 +318, 446 +650, 114 +1 +1 +317, 446 +650, 114 +1 +1 +316, 446 +650, 114 +1 +1 +315, 446 +650, 114 +1 +1 +314, 446 +650, 114 +1 +1 +313, 446 +650, 114 +1 +1 +312, 446 +650, 114 +1 +1 +311, 446 +650, 114 +1 +1 +310, 446 +650, 114 +1 +1 +309, 446 +650, 114 +1 +1 +308, 446 +650, 114 +1 +1 +307, 446 +650, 114 +1 +1 +306, 446 +650, 114 +1 +1 +305, 446 +650, 114 +1 +1 +304, 446 +650, 114 +1 +1 +303, 446 +650, 114 +1 +1 +302, 446 +650, 114 +1 +1 +301, 446 +650, 114 +1 +1 +650, 114 +1 +650, 114 +1 +298, 446 +650, 114 +1 +1 +297, 446 +650, 114 +1 +1 +296, 446 +650, 114 +1 +1 +295, 446 +650, 114 +1 +1 +294, 446 +650, 114 +1 +1 +293, 446 +1 +292, 446 +650, 114 +1 +1 +291, 446 +650, 114 +1 +1 +290, 446 +650, 114 +1 +1 +289, 446 +650, 114 +1 +1 +288, 446 +650, 114 +1 +1 +287, 446 +650, 114 +1 +1 +286, 446 +650, 114 +1 +1 +285, 446 +1 +284, 446 +650, 114 +1 +1 +283, 446 +650, 114 +1 +1 +282, 446 +650, 114 +1 +1 +281, 446 +650, 114 +1 +1 +280, 446 +1 +279, 446 +650, 114 +1 +1 +278, 446 +650, 114 +1 +1 +277, 446 +650, 114 +1 +1 +276, 446 +650, 114 +1 +1 +275, 446 +650, 114 +1 +1 +274, 446 +650, 114 +1 +1 +273, 446 +650, 114 +1 +1 +272, 446 +650, 114 +1 +1 +271, 446 +650, 114 +1 +1 +270, 446 +650, 114 +1 +1 +269, 446 +650, 114 +1 +1 +268, 446 +650, 114 +1 +1 +267, 446 +650, 114 +1 +1 +266, 446 +650, 114 +1 +1 +265, 446 +650, 114 +1 +1 +264, 446 +650, 114 +1 +1 +263, 446 +650, 114 +1 +1 +262, 446 +650, 114 +1 +1 +261, 446 +650, 114 +1 +1 +260, 446 +650, 114 +1 +1 +259, 446 +650, 114 +1 +1 +258, 446 +650, 114 +1 +1 +257, 446 +650, 114 +1 +1 +256, 446 +650, 114 +1 +1 +255, 446 +650, 114 +1 +1 +254, 446 +650, 114 +1 +1 +253, 446 +650, 114 +1 +1 +252, 446 +650, 114 +1 +1 +251, 446 +650, 114 +1 +1 +250, 446 +650, 114 +1 +1 +249, 446 +650, 114 +1 +1 +248, 446 +650, 114 +1 +1 +247, 446 +650, 114 +1 +1 +246, 446 +650, 114 +1 +1 +245, 446 +650, 114 +1 +1 +244, 446 +650, 114 +1 +1 +243, 446 +650, 114 +1 +1 +242, 446 +650, 114 +1 +1 +241, 446 +650, 114 +1 +1 +240, 446 +1 +239, 446 +650, 114 +1 +1 +238, 446 +650, 114 +1 +1 +237, 446 +650, 114 +1 +1 +236, 446 +650, 114 +1 +1 +235, 446 +650, 114 +1 +1 +234, 446 +650, 114 +1 +1 +233, 446 +650, 114 +1 +1 +231, 446 +650, 114 +1 +1 +230, 446 +650, 114 +1 +1 +229, 446 +650, 114 +1 +1 +228, 446 +650, 114 +1 +1 +227, 446 +1 +226, 446 +650, 114 +1 +1 +225, 446 +650, 114 +1 +1 +224, 446 +650, 114 +1 +1 +223, 446 +650, 114 +1 +1 +222, 446 +650, 114 +1 +1 +221, 446 +1 +220, 446 +650, 114 +1 +1 +219, 446 +650, 114 +1 +1 +218, 446 +650, 114 +1 +1 +217, 446 +650, 114 +1 +1 +216, 446 +650, 114 +1 +1 +215, 446 +650, 114 +1 +1 +214, 446 +650, 114 +1 +1 +213, 446 +650, 114 +1 +1 +212, 446 +650, 114 +1 +1 +211, 446 +650, 114 +1 +1 +210, 446 +650, 114 +1 +1 +209, 446 +650, 114 +1 +1 +208, 446 +1 +207, 446 +650, 114 +1 +1 +206, 446 +650, 114 +1 +1 +205, 446 +650, 114 +1 +1 +204, 446 +650, 114 +1 +1 +203, 446 +650, 114 +1 +1 +202, 446 +650, 114 +1 +1 +201, 446 +650, 114 +1 +1 +200, 446 +650, 114 +1 +1 +199, 446 +650, 114 +1 +1 +198, 446 +650, 114 +1 +1 +197, 446 +650, 114 +1 +1 +196, 446 +650, 114 +1 +1 +195, 446 +650, 114 +1 +1 +194, 446 +650, 114 +1 +1 +193, 446 +650, 114 +1 +1 +192, 446 +650, 114 +1 +1 +191, 446 +650, 114 +1 +1 +650, 114 +1 +189, 446 +650, 114 +1 +1 +188, 446 +650, 114 +1 +1 +187, 446 +1 +186, 446 +650, 114 +1 +1 +650, 114 +1 +184, 446 +650, 114 +1 +1 +183, 446 +650, 114 +1 +1 +182, 446 +650, 114 +1 +1 +181, 446 +650, 114 +1 +1 +180, 446 +650, 114 +1 +1 +179, 446 +650, 114 +1 +1 +178, 446 +650, 114 +1 +1 +650, 114 +1 +176, 446 +650, 114 +1 +1 +175, 446 +650, 114 +1 +1 +174, 446 +650, 114 +1 +1 +173, 446 +650, 114 +1 +1 +172, 446 +650, 114 +1 +1 +171, 446 +650, 114 +1 +1 +170, 446 +650, 114 +1 +1 +169, 446 +650, 114 +1 +1 +168, 446 +650, 114 +1 +1 +167, 446 +650, 114 +1 +1 +166, 446 +650, 114 +1 +1 +165, 446 +650, 114 +1 +1 +164, 446 +650, 114 +1 +1 +163, 446 +650, 114 +1 +1 +162, 446 +650, 114 +1 +1 +161, 446 +1 +160, 446 +650, 114 +1 +1 +159, 446 +650, 114 +1 +1 +158, 446 +650, 114 +1 +1 +157, 446 +650, 114 +1 +1 +156, 446 +650, 114 +1 +1 +155, 446 +650, 114 +1 +1 +154, 446 +650, 114 +1 +1 +153, 446 +650, 114 +1 +1 +152, 446 +650, 114 +1 +1 +151, 446 +650, 114 +1 +1 +150, 446 +650, 114 +1 +1 +149, 446 +650, 114 +1 +1 +148, 446 +650, 114 +1 +1 +650, 114 +1 +146, 446 +650, 114 +1 +1 +145, 446 +650, 114 +1 +1 +144, 446 +650, 114 +1 +1 +143, 446 +650, 114 +1 +1 +142, 446 +650, 114 +1 +1 +141, 446 +650, 114 +1 +1 +140, 446 +650, 114 +1 +1 +139, 446 +650, 114 +1 +1 +138, 446 +650, 114 +1 +1 +137, 446 +650, 114 +1 +1 +136, 446 +650, 114 +1 +1 +135, 446 +650, 114 +1 +1 +134, 446 +650, 114 +1 +1 +133, 446 +650, 114 +1 +1 +132, 446 +650, 114 +1 +1 +131, 446 +650, 114 +1 +1 +130, 446 +650, 114 +1 +1 +129, 446 +1 +128, 446 +650, 114 +1 +1 +127, 446 +650, 114 +1 +1 +126, 446 +650, 114 +1 +1 +125, 446 +650, 114 +1 +1 +124, 446 +1 +123, 446 +1 +122, 446 +650, 114 +1 +1 +121, 446 +650, 114 +1 +1 +120, 446 +650, 114 +1 +1 +119, 446 +650, 114 +1 +1 +118, 446 +650, 114 +1 +1 +117, 446 +650, 114 +1 +1 +116, 446 +650, 114 +1 +1 +115, 446 +650, 114 +1 +1 +114, 446 +650, 114 +1 +1 +113, 446 +650, 114 +1 +1 +112, 446 +650, 114 +1 +1 +111, 446 +650, 114 +1 +1 +110, 446 +650, 114 +1 +1 +650, 114 +1 +108, 446 +650, 114 +1 +1 +107, 446 +650, 114 +1 +1 +106, 446 +650, 114 +1 +1 +105, 446 +650, 114 +1 +1 +104, 446 +650, 114 +1 +1 +103, 446 +650, 114 +1 +1 +102, 446 +650, 114 +1 +1 +101, 446 +650, 114 +1 +1 +100, 446 +650, 114 +1 +1 +99, 446 +650, 114 +1 +1 +98, 446 +650, 114 +1 +1 +97, 446 +1 +96, 446 +650, 114 +1 +1 +95, 446 +650, 114 +1 +1 +94, 446 +650, 114 +1 +1 +93, 446 +650, 114 +1 +1 +650, 114 +1 +91, 446 +650, 114 +1 +1 +90, 446 +650, 114 +1 +1 +89, 446 +650, 114 +1 +1 +88, 446 +650, 114 +1 +1 +87, 446 +650, 114 +1 +1 +86, 446 +650, 114 +1 +1 +85, 446 +650, 114 +1 +1 +84, 446 +650, 114 +1 +1 +83, 446 +650, 114 +1 +1 +82, 446 +650, 114 +1 +1 +81, 446 +650, 114 +1 +1 +80, 446 +650, 114 +1 +1 +79, 446 +650, 114 +1 +1 +78, 446 +650, 114 +1 +1 +77, 446 +650, 114 +1 +1 +76, 446 +650, 114 +1 +1 +75, 446 +650, 114 +1 +1 +74, 446 +650, 114 +1 +1 +73, 446 +650, 114 +1 +1 +72, 446 +650, 114 +1 +1 +71, 446 +650, 114 +1 +1 +650, 114 +1 +69, 446 +650, 114 +1 +1 +68, 446 +650, 114 +1 +1 +67, 446 +650, 114 +1 +1 +66, 446 +650, 114 +1 +1 +65, 446 +650, 114 +1 +1 +64, 446 +650, 114 +1 +1 +63, 446 +650, 114 +1 +1 +62, 446 +650, 114 +1 +1 +61, 446 +650, 114 +1 +1 +60, 446 +650, 114 +1 +1 +59, 446 +650, 114 +1 +1 +58, 446 +650, 114 +1 +1 +57, 446 +650, 114 +1 +1 +56, 446 +650, 114 +1 +1 +55, 446 +650, 114 +1 +1 +54, 446 +650, 114 +1 +1 +53, 446 +650, 114 +1 +1 +52, 446 +650, 114 +1 +1 +51, 446 +650, 114 +1 +1 +50, 446 +1 +49, 446 +650, 114 +1 +1 +48, 446 +650, 114 +1 +1 +47, 446 +650, 114 +1 +1 +46, 446 +650, 114 +1 +1 +650, 114 +1 +44, 446 +650, 114 +1 +1 +43, 446 +650, 114 +1 +1 +42, 446 +650, 114 +1 +1 +41, 446 +650, 114 +1 +1 +40, 446 +650, 114 +1 +1 +39, 446 +650, 114 +1 +1 +38, 446 +650, 114 +1 +1 +37, 446 +650, 114 +1 +1 +36, 446 +650, 114 +1 +1 +35, 446 +650, 114 +1 +1 +34, 446 +650, 114 +1 +1 +33, 446 +1 +32, 446 +650, 114 +1 +1 +31, 446 +650, 114 +1 +1 +30, 446 +650, 114 +1 +1 +650, 114 +1 +28, 446 +650, 114 +1 +1 +27, 446 +650, 114 +1 +1 +26, 446 +650, 114 +1 +1 +25, 446 +650, 114 +1 +1 +24, 446 +650, 114 +1 +1 +23, 446 +650, 114 +1 +1 +22, 446 +650, 114 +1 +1 +21, 446 +650, 114 +1 +1 +20, 446 +650, 114 +1 +1 +19, 446 +650, 114 +1 +1 +18, 446 +650, 114 +1 +1 +17, 446 +650, 114 +1 +1 +16, 446 +650, 114 +1 +1 +15, 446 +1 +14, 446 +650, 114 +1 +1 +13, 446 +650, 114 +1 +1 +12, 446 +650, 114 +1 +1 +11, 446 +650, 114 +1 +1 +10, 446 +650, 114 +1 +1 +9, 446 +650, 114 +1 +1 +8, 446 +650, 114 +1 +1 +7, 446 +650, 114 +1 +1 +6, 446 +650, 114 +1 +1 +5, 446 +650, 114 +1 +1 +4, 446 +1 +650, 114 +1 +2, 446 +650, 114 +1 +1 +1, 446 +1 +0, 446 +650, 114 +1 +1 +650, 114 +1 +798, 419 +650, 114 +1 +1 +797, 419 +650, 114 +1 +1 +796, 419 +650, 114 +1 +1 +795, 419 +650, 114 +1 +1 +794, 419 +650, 114 +1 +1 +793, 419 +650, 114 +1 +1 +650, 114 +1 +791, 419 +1 +790, 419 +650, 114 +1 +1 +789, 419 +650, 114 +1 +1 +788, 419 +650, 114 +1 +1 +787, 419 +650, 114 +1 +1 +785, 419 +650, 114 +1 +1 +650, 114 +1 +783, 419 +650, 114 +1 +1 +782, 419 +650, 114 +1 +1 +781, 419 +650, 114 +1 +1 +780, 419 +650, 114 +1 +1 +779, 419 +650, 114 +1 +1 +778, 419 +650, 114 +1 +1 +777, 419 +650, 114 +1 +1 +776, 419 +650, 114 +1 +1 +775, 419 +650, 114 +1 +1 +774, 419 +650, 114 +1 +1 +773, 419 +650, 114 +1 +1 +772, 419 +650, 114 +1 +1 +771, 419 +1 +770, 419 +650, 114 +1 +1 +650, 114 +1 +768, 419 +650, 114 +1 +1 +767, 419 +650, 114 +1 +1 +766, 419 +650, 114 +1 +1 +765, 419 +650, 114 +1 +1 +764, 419 +650, 114 +1 +1 +763, 419 +650, 114 +1 +1 +762, 419 +1 +761, 419 +1 +760, 419 +650, 114 +1 +1 +759, 419 +650, 114 +1 +1 +758, 419 +650, 114 +1 +1 +757, 419 +650, 114 +1 +1 +756, 419 +650, 114 +1 +1 +755, 419 +650, 114 +1 +1 +754, 419 +650, 114 +1 +1 +753, 419 +650, 114 +1 +1 +752, 419 +1 +751, 419 +650, 114 +1 +1 +750, 419 +650, 114 +1 +1 +749, 419 +650, 114 +1 +1 +748, 419 +650, 114 +1 +1 +747, 419 +650, 114 +1 +1 +746, 419 +650, 114 +1 +1 +745, 419 +650, 114 +1 +1 +744, 419 +650, 114 +1 +1 +742, 419 +650, 114 +1 +1 +650, 114 +1 +740, 419 +650, 114 +1 +1 +739, 419 +1 +738, 419 +650, 114 +1 +1 +737, 419 +650, 114 +1 +1 +650, 114 +1 +735, 419 +1 +734, 419 +650, 114 +1 +1 +733, 419 +650, 114 +1 +1 +732, 419 +650, 114 +1 +1 +731, 419 +650, 114 +1 +1 +650, 114 +1 +729, 419 +650, 114 +1 +1 diff --git a/allegro_wrapper_functions-main/Colour.cpp b/allegro_wrapper_functions-main/Colour.cpp new file mode 100644 index 00000000..7a5ef3d1 --- /dev/null +++ b/allegro_wrapper_functions-main/Colour.cpp @@ -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() +{ + +} \ No newline at end of file diff --git a/allegro_wrapper_functions-main/Colour.h b/allegro_wrapper_functions-main/Colour.h new file mode 100644 index 00000000..216b028c --- /dev/null +++ b/allegro_wrapper_functions-main/Colour.h @@ -0,0 +1,43 @@ +#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; }; +}; diff --git a/allegro_wrapper_functions-main/GraphicsLibrary.cpp b/allegro_wrapper_functions-main/GraphicsLibrary.cpp new file mode 100644 index 00000000..a821e87c --- /dev/null +++ b/allegro_wrapper_functions-main/GraphicsLibrary.cpp @@ -0,0 +1,130 @@ +/* +Allegro Wrapper Functions +Written by Adel Talhouk in FA21 +GraphicsLibrary.cpp +*/ + +#include "GraphicsLibrary.h" +#include "RoboCatPCH.h" + +#include +#include + +GraphicsLibrary::GraphicsLibrary() +{ +} + +//Constructor +GraphicsLibrary::GraphicsLibrary(float screenSizeX, float screenSizeY) +{ + //Setup data - screen size + mScreenSizeX = screenSizeX; + mScreenSizeY = screenSizeY; + + //Allegro display + mpDisplay = nullptr; +} + +//Destructor +GraphicsLibrary::~GraphicsLibrary() +{ + //Delete bitmaps + std::vector>::iterator iterator; + for (iterator = mBitmapPointersVector.begin(); iterator != mBitmapPointersVector.end(); ++iterator) + { + al_destroy_bitmap(iterator->second); + } + mBitmapPointersVector.clear(); + + //Clean up display + al_destroy_display(mpDisplay); + mpDisplay = nullptr; +} + +bool GraphicsLibrary::init(std::string backgroundFilePath) +{ + //Init allegro + if (!al_init()) + { + std::cout << "error initting Allegro\n"; + system("pause"); + return false; + } + + //Init image addon + if (!al_init_image_addon()) + { + std::cout << "error initting image add-on\n"; + system("pause"); + return false; + } + + //Init font add on + if (!al_init_font_addon()) + { + std::cout << "error initting font add-on\n"; + system("pause"); + return false; + } + + //Init ttf add on + if (!al_init_ttf_addon()) + { + std::cout << "error initting ttf add-on\n"; + system("pause"); + return false; + } + + //Setup display + mpDisplay = al_create_display(mScreenSizeX, mScreenSizeY); + + if (mpDisplay == nullptr) + { + return false; + } + + return true; +} + +void GraphicsLibrary::render() +{ + //Flip display buffers + al_flip_display(); +} + +void GraphicsLibrary::loadImage(std::string imageFilePath, std::string imageIdentifier) +{ + //Add the name of the image and the loaded bitmap to the vector of pairs + mBitmapPointersVector.push_back(std::make_pair(imageIdentifier, al_load_bitmap(imageFilePath.c_str()))); +} + +void GraphicsLibrary::drawImage(std::string imageIdentifier, float posX, float posY) +{ + //Find the image and draw if it exists + std::vector>::iterator iterator; + + for (iterator = mBitmapPointersVector.begin(); iterator != mBitmapPointersVector.end(); ++iterator) + { + if (iterator->first == imageIdentifier) + { + al_draw_bitmap(iterator->second, posX, posY, 0); + } + } +} + +void GraphicsLibrary::drawTintedImage(std::string imageIdentifier, float posX, float posY, Colour col) +{ + //Find the image and draw if it exists + std::vector>::iterator iterator; + + //Set colour + ALLEGRO_COLOR colour = al_map_rgba(col.getR(), col.getG(), col.getB(), col.getA()); + + for (iterator = mBitmapPointersVector.begin(); iterator != mBitmapPointersVector.end(); ++iterator) + { + if (iterator->first == imageIdentifier) + { + al_draw_tinted_bitmap(iterator->second, colour, posX, posY, 0); + } + } +} \ No newline at end of file diff --git a/allegro_wrapper_functions-main/GraphicsLibrary.h b/allegro_wrapper_functions-main/GraphicsLibrary.h new file mode 100644 index 00000000..0af35805 --- /dev/null +++ b/allegro_wrapper_functions-main/GraphicsLibrary.h @@ -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 +#include +#include +#include +#include +#include +#include +#include + +#include "Colour.h" + +//https://github.com/liballeg/allegro_wiki/wiki/Allegro-in-Visual-Studio#using-nuget-within-visual-studio + +class GraphicsLibrary +{ + //-------------------------Private data------------------------- + + //Screen data + float mScreenSizeX; + float mScreenSizeY; + + //Allegro display + ALLEGRO_DISPLAY* mpDisplay; + + //Other images to draw + std::vector> mBitmapPointersVector; + + friend class InputSystem; + + //-------------------------Public data------------------------- +public: + + //Constructor(s) + GraphicsLibrary(); + 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); +}; \ No newline at end of file diff --git a/allegro_wrapper_functions-main/InputSystem.cpp b/allegro_wrapper_functions-main/InputSystem.cpp new file mode 100644 index 00000000..bb262445 --- /dev/null +++ b/allegro_wrapper_functions-main/InputSystem.cpp @@ -0,0 +1,159 @@ +/* +Allegro Wrapper Functions +Written by Adel Talhouk in FA21 +InputSystem.cpp +*/ + +#include "InputSystem.h" +#include "RoboCatPCH.h" + +#include + +//Constructor +InputSystem::InputSystem() +{ + //Create an event queue + mpEventQueue = al_create_event_queue(); +} + +//Destructor +InputSystem::~InputSystem() +{ + //Cleanup event queue + al_destroy_event_queue(mpEventQueue); + mpEventQueue = nullptr; +} + +float InputSystem::getMouseX() +{ + //Update mouse state + ALLEGRO_MOUSE_STATE mouseState; + al_get_mouse_state(&mouseState); + + return mouseState.x; +} + +float InputSystem::getMouseY() +{ + //Update mouse state + ALLEGRO_MOUSE_STATE mouseState; + al_get_mouse_state(&mouseState); + + return mouseState.y; +} + +std::pair InputSystem::getMousePosition() +{ + //Update mouse state + ALLEGRO_MOUSE_STATE mouseState; + al_get_mouse_state(&mouseState); + + return std::make_pair(mouseState.x, mouseState.y); +} + +//Init +bool InputSystem::init(GraphicsLibrary* pGraphicsLib) +{ + //Init keyboard + if (!al_install_keyboard()) + { + std::cout << "error installing Allegro keyboard plugin\n"; + system("pause"); + return false; + } + + //Init mouse + if (!al_install_mouse()) + { + std::cout << "error installing Allegro mouse plugin\n"; + system("pause"); + return false; + } + + //Register screen event source + al_register_event_source(mpEventQueue, al_get_display_event_source(pGraphicsLib->mpDisplay)); + + //Register keyboard event source + al_register_event_source(mpEventQueue, al_get_keyboard_event_source()); + + //Register mouse event source + al_register_event_source(mpEventQueue, al_get_mouse_event_source()); + + return true; +} + +MouseButton InputSystem::getMouseInput() +{ + //If there is an event + al_get_next_event(mpEventQueue, &mEvent); + + if (mEvent.type == InputMode::MouseDown) + { + //Update mouse state + ALLEGRO_MOUSE_STATE mouseState; + al_get_mouse_state(&mouseState); + + //Check the button pressed + if (mouseState.buttons & 1) //Left mouse held + { + return MouseButton::LeftMouse; + } + else if (mouseState.buttons & 2) //Right mouse held + { + return MouseButton::RightMouse; + } + else if (mouseState.buttons & 4) //Middle mouse held + { + return MouseButton::MiddleMouse; + } + } +} + +KeyCode InputSystem::getKeyboardInput() +{ + //If there is an event + al_get_next_event(mpEventQueue, &mEvent); + + if (mEvent.type == InputMode::KeyPressed) + { + //Check the type + switch (mEvent.keyboard.keycode) + { + case KeyCode::KeyEscape: + return KeyCode::KeyEscape; + break; + + case KeyCode::R: + return KeyCode::R; + break; + case KeyCode::P1_Down: + return KeyCode::P1_Down; + break; + case KeyCode::P1_Left: + return KeyCode::P1_Left; + break; + case KeyCode::P1_Right: + return KeyCode::P1_Right; + break; + case KeyCode::P1_Up: + return KeyCode::P1_Up; + break; + case KeyCode::P2_Down: + return KeyCode::P2_Down; + break; + case KeyCode::P2_Left: + return KeyCode::P2_Left; + break; + case KeyCode::P2_Right: + return KeyCode::P2_Right; + break; + case KeyCode::P2_Up: + return KeyCode::P2_Up; + break; + default: + /*return KeyCode::NONE*/; + } + } + + //return KeyCode::NONE; +} \ No newline at end of file diff --git a/allegro_wrapper_functions-main/InputSystem.h b/allegro_wrapper_functions-main/InputSystem.h new file mode 100644 index 00000000..f46e8f3c --- /dev/null +++ b/allegro_wrapper_functions-main/InputSystem.h @@ -0,0 +1,76 @@ +#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 + +enum KeyCode +{ + KeyEscape = ALLEGRO_KEY_ESCAPE, + R = ALLEGRO_KEY_R, + P1_Left = ALLEGRO_KEY_A, + P2_Left = ALLEGRO_KEY_J, + P1_Down = ALLEGRO_KEY_S, + P2_Down = ALLEGRO_KEY_K, + P1_Up = ALLEGRO_KEY_W, + P2_Up = ALLEGRO_KEY_I, + P1_Right = ALLEGRO_KEY_D, + P2_Right = ALLEGRO_KEY_L +}; + +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 getMousePosition(); + + //Functions + bool init(GraphicsLibrary* pGraphicsLib); + MouseButton getMouseInput(); + KeyCode getKeyboardInput(); +}; \ No newline at end of file diff --git a/allegro_wrapper_functions-main/LICENSE b/allegro_wrapper_functions-main/LICENSE new file mode 100644 index 00000000..52e8a5fb --- /dev/null +++ b/allegro_wrapper_functions-main/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Adel Talhouk + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/allegro_wrapper_functions-main/README.md b/allegro_wrapper_functions-main/README.md new file mode 100644 index 00000000..e8462238 --- /dev/null +++ b/allegro_wrapper_functions-main/README.md @@ -0,0 +1,43 @@ +# allegro_wrapper_functions +Some Allegro 5 wrapper functions for C++ + +I wrote some code for my Computer Architecture final project in FA21 that allowed me to use abstracted Allegro 5 functions. Feel free to use this code, but please keep the block comment in each file :) + +EXAMPLE INIT FUNCTION IN MAIN.CPP: + +```cpp +//-------------------------Graphics Data------------------------- +GraphicsLibrary* pGraphics; +float screenSizeX = 1600.0; +float screenSizeY = 900.0; + +//-------------------------Input Data------------------------- +InputSystem* pInput; + +//-------------------------Assets------------------------- +const std::string ASSET_PATH = "..\\Assets\\"; +const std::string BACKGROUND_IMAGE_FILE = "Background_Image.jpg"; + +//-------------------------Asset Identifiers------------------------- +const std::string backgroundImageSprite = "background_image_image"; + +bool init() +{ + bool bSuccessfulInit = false; + + //Setup the graphical window + pGraphics = new GraphicsLibrary(screenSizeX, screenSizeY); + bSuccessfulInit = pGraphics->init(ASSET_PATH + BACKGROUND_IMAGE_FILE); + + //Add images to the graphcis library + pGraphics->loadImage(ASSET_PATH + BACKGROUND_IMAGE_FILE, backgroundImageSprite); + + //Setup the input system + pInput = new InputSystem(); + if (bSuccessfulInit) + bSuccessfulInit = pInput->init(pGraphics); + + //Init and return if it succeeded or not + return bSuccessfulInit; +} +``` diff --git a/coin.png b/coin.png new file mode 100644 index 00000000..b8da8e41 Binary files /dev/null and b/coin.png differ diff --git a/homie.png b/homie.png new file mode 100644 index 00000000..0e682bcd Binary files /dev/null and b/homie.png differ diff --git a/tomato.png b/tomato.png new file mode 100644 index 00000000..1f944836 Binary files /dev/null and b/tomato.png differ