Skip to content
Snippets Groups Projects
Commit eaed4882 authored by KosmX's avatar KosmX
Browse files

some changes

Description
parent e98bafb5
No related branches found
No related tags found
No related merge requests found
File added
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
......@@ -146,9 +146,13 @@
<ClCompile Include="Entity.cpp" />
<ClCompile Include="game.cpp" />
<ClCompile Include="LazySprite.cpp" />
<ClCompile Include="mainGame.cpp" />
<ClCompile Include="ResourceManager.cpp" />
<ClCompile Include="SimpleSprite.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="DynamicArray.hpp" />
<ClInclude Include="mainGame.h" />
<ClInclude Include="olc.h" />
<ClInclude Include="ITexture.h" />
<ClInclude Include="Entity.h" />
......@@ -156,7 +160,9 @@
<ClInclude Include="LazySprite.h" />
<ClInclude Include="olcPGEX_TransformedView.h" />
<ClInclude Include="olcPixelGameEngine.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="ResourceManager.h" />
<ClInclude Include="SimpleSprite.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
......
......@@ -9,10 +9,6 @@
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Header Files\gameObj">
<UniqueIdentifier>{ff9a19d0-75c0-4779-86ff-f20d7446f234}</UniqueIdentifier>
</Filter>
......@@ -25,6 +21,9 @@
<Filter Include="olc::PGE">
<UniqueIdentifier>{0ebc0167-4ba6-47e4-93df-4984963d5751}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\gameObj\management">
<UniqueIdentifier>{886a9672-46a0-46f4-a068-e12dce07d024}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="game.cpp">
......@@ -39,6 +38,12 @@
<ClCompile Include="LazySprite.cpp">
<Filter>Source Files\gameObj</Filter>
</ClCompile>
<ClCompile Include="SimpleSprite.cpp">
<Filter>Source Files\gameObj</Filter>
</ClCompile>
<ClCompile Include="mainGame.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="interfaces.h">
......@@ -59,11 +64,23 @@
<ClInclude Include="olcPixelGameEngine.h">
<Filter>olc::PGE</Filter>
</ClInclude>
<ClInclude Include="olc.h">
<Filter>olc::PGE</Filter>
</ClInclude>
<ClInclude Include="ITexture.h">
<Filter>Header Files\gameObj\render</Filter>
</ClInclude>
<ClInclude Include="SimpleSprite.h">
<Filter>Header Files\gameObj\render</Filter>
</ClInclude>
<ClInclude Include="mainGame.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="olc.h">
<Filter>olc::PGE</Filter>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DynamicArray.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
#pragma once
#include <list>
#include <vector>
//I won't be able to do an enhanced (Range-based) for with this...
//Dynamic data type, set (not ordered), I'll use arrays for entry pointers, I will leave nullptr in the list.
//I don't want to waste time with resizing this, I'll allocate more memory and if I delete from this, I'll do it in
template<typename T>
class DynamicArray
{
private:
std::vector<T> entries;
std::list<T> newEntries;
public:
auto begin()
{
return entries.begin();
}
};
......@@ -5,6 +5,14 @@ namespace entities {
:pos(pos), texture(texture)
{
}
olc::vf2d Entity::getPos() const
{
return this->pos;
}
void Entity::render(olc::TransformedView& scene) const
{
this->texture.render(scene, *this);
}
Entity::~Entity()
{
......
......@@ -9,14 +9,14 @@ namespace entities {
{
protected:
olc::vf2d pos; //I can store these safely directly
render::ITexture& texture;
virtual render::ITexture& getTexture() = 0;
public:
Entity(render::ITexture& texture, const olc::vf2d& pos);
virtual olc::vf2d getPos() const;
virtual void tick(float deltaT);
virtual void tick(float deltaT){}
//this shouldn't change it's state
virtual void render(olc::TransformedView& scene) const;
......
......@@ -11,11 +11,11 @@ namespace render {
return this->sprite;
}
LazySprite::LazySprite(int u, int v, int sizeU, int sizeV)
: LazySprite(olc::vi2d(u, v), olc::vi2d(sizeU, sizeV))
LazySprite::LazySprite(const std::string& resName, int u, int v, int sizeU, int sizeV)
: LazySprite(resName, olc::vi2d(u, v), olc::vi2d(sizeU, sizeV))
{}
LazySprite::LazySprite(olc::vi2d pos, olc::vi2d size)
: uv(pos), size(size)
LazySprite::LazySprite(const std::string& resName, olc::vi2d pos, olc::vi2d size)
: resourceName(resName), uv(pos), size(size)
{
sprite = nullptr;
}
......
......@@ -25,14 +25,14 @@ namespace render {
* u, v the texture coordinates on the image,
* sizeU, V are the size of that sprite
*/
LazySprite(int u, int v, int sizeU = 16, int sizeV = 16);
LazySprite(const std::string& resName, int u, int v, int sizeU = 16, int sizeV = 16);
LazySprite(olc::vi2d pos, olc::vi2d size = olc::vi2d(16, 16));
LazySprite(const std::string& resName, olc::vi2d pos, olc::vi2d size = olc::vi2d(16, 16));
/**
* Render the sprite in world-space
*/
void render(olc::TransformedView& scene, olc::vf2d, olc::vf2d scale);
void render(olc::TransformedView& scene, olc::vf2d, olc::vf2d scale = olc::vf2d(1, 1));
void renderCentered(olc::TransformedView& scene, olc::vf2d, olc::vf2d scale);
......
#include "SimpleSprite.h"
render::SimpleSprite::SimpleSprite(const std::string name, olc::vi2d pos)
: sprite(name, pos)
{
}
void render::SimpleSprite::render(olc::TransformedView& scene, entities::Entity& entity)
{
this->sprite.render(scene, entity.getPos());
}
#pragma once
#include "ITexture.h"
#include <string>
#include "LazySprite.h"
namespace render {
class SimpleSprite :
public ITexture
{
private:
LazySprite sprite;
public:
SimpleSprite(const std::string name, olc::vi2d pos);
void render(olc::TransformedView& scene, entities::Entity& entity) override;
};
}
#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"
#include "mainGame.h"
#include <iostream>
#include <string>
......@@ -9,4 +10,29 @@ using namespace std;
int main(int argc, char* argv[])
{
cout << argv[0] << endl;
bool invalidArg = false;
for(int i = 0; i < argc; i++){
std::string tmp(argv[i]);
if(tmp == "-r" || tmp == "--resource"){
if(i + 1 < argc){
cout << "O.K. I'll read it, but //TODO" << endl;
//TODO
}
else{
invalidArg = true;
}
}
}
if(invalidArg){
cout << "Invalid arguments" << endl;
//TODO write something meaningful
}
GameClient client;
if(client.Construct(256, 240, 4, 4)){
client.Start();
}
return 0;
}
#include "mainGame.h"
#include "ResourceManager.h"
GameClient::GameClient()
{
this->sAppName = "KosmX's game";
}
bool GameClient::OnUserCreate()
{
//Set resource parent!
render::ResourceManager::createInstance();
return true;
}
bool GameClient::OnUserUpdate(float fElapsedTime)
{
//return false if it want to exit.
return true;
}
GameClient::~GameClient()
{
//TODO free anything
}
#pragma once
#include "olcPixelGameEngine.h"
#include "DynamicArray.hpp"
#include <memory>
#include "Entity.h"
class GameClient :
public olc::PixelGameEngine
{
private:
DynamicArray<std::shared_ptr<entities::Entity>> basicEntities;
public:
GameClient();
bool OnUserCreate() override;
bool OnUserUpdate(float fElapsedTime) override;
~GameClient();
//for some reason, probably I won't need it
//bool OnUserDestroy() override;
};
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by 2d-game.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment