PogoBijoux/Base.h

91 lines
4.0 KiB
C++

/*
Base.h
-------------------------------
Copyright (c) 2020-2023 MCL Software
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.
*/
#ifndef BASE_H
#define BASE_H
#ifdef _WIN32
#include <irrlicht.h>
#else
#include <irrlicht/irrlicht.h>
#endif
#include "EventReceiver.h"
class PogoBijoux
{
public:
EventReceiver er;
bool enableBump = true;
bool enableShadows = true;
bool showWaterOverlay = false;
bool showLoadingOverlay = false;
bool showNextLevelOverlay = false;
bool showPosition = false;
int speed = 400;
int screenWidth = 1024;
int screenHeight = 768;
irr::scene::ISceneNode* rootNode;
irr::IrrlichtDevice* device;
float verticalCamRot = 50;
irr::scene::ISceneNode* player;
irr::scene::ICameraSceneNode* camera;
irr::video::IVideoDriver* driver;
irr::scene::ISceneManager* scnmgr;
irr::gui::IGUIEnvironment* guiEnv;
irr::gui::IGUISkin* guiSkin;
float mouseSensitivity = 0.2F;
bool isPlayerCollidingWithAABB(irr::core::aabbox3d<irr::f32> aabb)
{
irr::core::aabbox3d<irr::f32> playerAABB = player -> getTransformedBoundingBox();
return playerAABB.intersectsWithBox(aabb);
}
void drawIngameHUD()
{
if(showWaterOverlay)
{
driver -> draw2DRectangle(irr::video::SColor(119, 5, 107, 200), irr::core::rect<irr::s32>(0, 0, screenWidth, screenHeight));
}
if(showLoadingOverlay)
{
guiEnv -> addImage(driver -> getTexture("img/gui/loading.png"), irr::core::position2d<irr::s32>(screenWidth / 2 - 600 / 2, screenHeight / 2 - 200 / 2));
}
if(showNextLevelOverlay)
{
driver -> draw2DRectangle(irr::video::SColor(255, 255, 255, 255), irr::core::rect<irr::s32>(0, screenHeight / 2 + 600 / 2, screenWidth, screenHeight));
guiEnv -> addStaticText(L"Would like to go through the door (and go to the next level)? (ENTER/LEFT CLICK = YES)", irr::core::rect<irr::s32>(0, screenHeight / 2 + 600 / 2, screenWidth, screenHeight));
}
if(showPosition)
{
std::wstring positionString = L"X: " + std::to_wstring((int)player -> getAbsolutePosition().X) + L" Y: " + std::to_wstring((int)player -> getAbsolutePosition().Y) + L" Z: " + std::to_wstring((int)player -> getAbsolutePosition().Z);
guiEnv -> addStaticText(positionString.c_str(), irr::core::rect<irr::s32>(0, screenHeight / 2 - 400 / 2, screenWidth, screenHeight));
}
driver -> draw2DRectangle(irr::video::SColor(155, 15, 255, 255), irr::core::rect<irr::s32>(0, 0, screenWidth, screenHeight / 2 - 600 / 2));
guiEnv -> addStaticText(levelText.c_str(), irr::core::rect<irr::s32>(0, 0, screenWidth, screenHeight));
}
void setLevelText(std::wstring newText)
{
levelText = newText;
}
private:
std::wstring levelText = L"Title Menu";
};
#endif