Skip to content

Commit

Permalink
The isometric level subsystem has improved
Browse files Browse the repository at this point in the history
  • Loading branch information
PopovEvgeniy committed Jan 16, 2025
1 parent 4ef6dff commit 9cc6029
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 42 deletions.
24 changes: 13 additions & 11 deletions documentation/reference.htm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<li><a href="#mozTocId679493">Chapter 1. The sub-namespace</a></li>
<li><a href="#mozTocId29297">Chapter 2. Cartesian coordinates and screen coordinates</a></li>
<li><a href="#mozTocId122919">Chapter 3. Cartesian coordinates and isometric coordinates</a></li>
<li><a href="#mozTocId175651">Chapter 4. Entity</a></li>
<li><a href="#mozTocId175651">Chapter 4. Isometric level</a></li>
</ul>
</li>
<li>
Expand Down Expand Up @@ -824,17 +824,18 @@ <h2><a class="mozTocH2" name="mozTocId122919" id="mozTocId122919"></a><big>Chapt
<span style="font-style: italic;">static int Isometric::get_cartesian_x(const int x, const int y); -</span></big> <big>C</big><big>onvert the x-coordinate from</big> <big>the</big> <big>isometric system to</big> <big>the</big> <big>Cartesian system.<br>
<br>
<span style="font-style: italic;">static int Isometric::get_cartesian_y(const int x, const int y); -</span></big> <big>C</big><big>onvert the y-coordinate from</big> <big>the</big> <big>isometric system to</big> <big>the</big> <big>Cartesian system.</big></p>
<h2><a id="mozTocId175651" class="mozTocH2" name="mozTocId175651"></a><big>Chapter 4. Entity</big></h2>
<p><big>The entity subsystem is intended for work with isometric objects. The <span style="font-style: italic;">Entity</span> class provides simple access to this subsystem. Let's look at the publicly available methods.</big></p>
<p><big><span style="font-style: italic;">Entity *Entity::get_handle(); -</span> Return the handle to the entity subsystem.<br>
<h2><a id="mozTocId175651" class="mozTocH2" name="mozTocId175651"></a><big>Chapter 4. Isometric level<br></big></h2>
<p><big>The isometric level subsystem is intended to help you create an isometric level. Just use the <span style="font-style: italic;">Level</span> class to do it. Let's look at the publicly available methods.</big></p>
<p><big><span style="font-style: italic;">Level *Level::get_handle(); -</span> Return the handle to the isometric level subsystem.<br>
<br>
<span style="font-style: italic;">void Entity::initialize(const int width, const int height); -</span> Initialize the subsystem.</big></p>
<p><big><span style="font-style: italic;">int Entity::get_width() const; -</span> Return the width of the object.<br>
<span style="font-style: italic;">void Level::initialize(const int tile_width, const int tile_height); -</span> Initialize the subsystem.<br></big></p>
<p><big><span style="font-style: italic;">void Level::set_offset(const int x_offset, const int y_offset); -</span> Set the coordinates offset.<br></big></p>
<p><big><span style="font-style: italic;">int Level::get_x_offset() const; -</span> Return the x-offset.<br>
<br>
<span style="font-style: italic;">int Entiy::get_height() const; -</span> Return the height of the object.</big></p>
<p><big><span style="font-style: italic;">int Entity::get_x(const int x, const int y) const; -</span> Return the target x-coordinate.<br>
<span style="font-style: italic;">int Level::get_y_offset() const; -</span> Return the y-offset.<br></big></p>
<p><big><span style="font-style: italic;">int Level::get_x(const int row, const int column) const; -</span> Return the target x-coordinate.<br>
<br>
<span style="font-style: italic;">int Entity::get_y(const int y, const int y) const; -</span> Return the target y-coordinate.</big></p>
<span style="font-style: italic;">int Level::get_y(const int row, const int column) const; -</span> Return the target y-coordinate.</big></p>
<h1><a id="mozTocId564239" class="mozTocH1" name="mozTocId564239"></a><big>Part 5. Maps<br></big></h1>
<h2><a id="mozTocId599694" class="mozTocH2" name="mozTocId599694"></a><big>Chapter 1. The sub-namespace</big></h2><big>All classes in this section are declared in the <span style="font-style: italic;">Map</span> sub-namespace.</big><big><br></big>
<h2><a class="mozTocH2" name="mozTocId429738" id="mozTocId429738"></a><big>Chapter 1. Tile</big> <big>map</big></h2>
Expand Down Expand Up @@ -2053,7 +2054,8 @@ <h1><a class="mozTocH1" name="mozTocId670307" id="mozTocId670307"></a><big>Versi
9.2.9: The small changes.<br>
9.3: The isometric subsystem has improved.<br>
9.3.1: The new subsystem has been added.<br>
9.3.2-9.3.5:The isometric map subsystem has improved.<br>
9.3.6: The small changes.<br></big>
9.3.2-9.3.5: The isometric map subsystem has improved.<br>
9.3.6: The small changes.<br>
9.3.7-9.3.9: The isometric level subsystem has improved.<br></big>
</body>
</html>
46 changes: 27 additions & 19 deletions source/eugenegdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3854,53 +3854,61 @@ namespace EUGENEGDK
return cartesian_y;
}

Entity::Entity()
Level::Level()
{
entity_width=1;
entity_height=1;
start_x=0;
start_y=0;
halft_tile_width=0;
halft_tile_height=0;
}

Entity::~Entity()
Level::~Level()
{

}

void Entity::initialize(const int width,const int height)
Level* Level::get_handle()
{
return this;
}

void Level::initialize(const int tile_width,const int tile_height)
{
if (width>0)
if (tile_width>0)
{
entity_width=width;
halft_tile_width=tile_width/2;
}
if (height>0)
if (tile_height>0)
{
entity_height=height;
halft_tile_height=tile_height/2;
}

}

Entity* Entity::get_handle()
void Level::set_offset(const int x_offset,const int y_offset)
{
return this;
start_x=x_offset;
start_y=y_offset;
}

int Entity::get_with() const
int Level::get_x_offset() const
{
return entity_width;
return start_x;
}

int Entity::get_height() const
int Level::get_y_offset() const
{
return entity_height;
return start_y;
}

int Entity::get_x(const int x,const int y) const
int Level::get_x(const int row,const int column) const
{
return (x-y)*(entity_width/2);
return start_x+(row-column)*halft_tile_width;
}

int Entity::get_y(const int x,const int y) const
int Level::get_y(const int row,const int column) const
{
return (x+y)*(entity_height/2);
return start_y+(row+column)*halft_tile_height;
}

}
Expand Down
25 changes: 14 additions & 11 deletions source/eugenegdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -1004,20 +1004,23 @@ typedef enum
static int get_cartesian_y(const int x,const int y);
};

class Entity
class Level
{
private:
int entity_width;
int entity_height;
int start_x;
int start_y;
int halft_tile_width;
int halft_tile_height;
public:
Entity();
~Entity();
void initialize(const int width,const int height);
Entity *get_handle();
int get_with() const;
int get_height() const;
int get_x(const int x,const int y) const;
int get_y(const int x,const int y) const;
Level();
~Level();
Level *get_handle();
void initialize(const int tile_width,const int tile_height);
void set_offset(const int x_offset,const int y_offset);
int get_x_offset() const;
int get_y_offset() const;
int get_x(const int row,const int column) const;
int get_y(const int row,const int column) const;
};

}
Expand Down
2 changes: 1 addition & 1 deletion source/isometric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int main()
EUGENEGDK::Graphics::Cartoon ground;
EUGENEGDK::Graphics::Text text;
EUGENEGDK::Transformation::Coordinates cartesian;
EUGENEGDK::Transformation::Entity level;
EUGENEGDK::Transformation::Level level;
EUGENEGDK::Input::Keyboard keyboard;
keyboard.initialize();
screen.initialize();
Expand Down

0 comments on commit 9cc6029

Please sign in to comment.