Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Rejcx/Ursa
base: 13fc8164eb
...
head fork: Rejcx/Ursa
compare: 5e77babc38
  • 4 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
10 Camera.cpp
@@ -1,5 +1,7 @@
#include "Camera.h"
+#include <SFML/Window.hpp>
+
namespace ursa
{
@@ -23,6 +25,14 @@ void Camera::Setup( const sf::Vector3f& pos )
m_position = pos;
}
+void Camera::GLUpdate()
+{
+ glTranslatef( m_position.x, m_position.y, m_position.z );
+ glRotatef( m_rotation.x, 1.0f, 0.0f, 0.0f );
+ glRotatef( m_rotation.y, 0.0f, 1.0f, 0.0f );
+ glRotatef( m_rotation.z, 0.0f, 0.0f, 1.0f );
+}
+
void Camera::MoveX( int inc )
{
m_position.x += inc * m_moveSpeed;
View
2  Camera.h
@@ -14,6 +14,8 @@ class Camera
void Setup( const sf::Vector3f& pos, const sf::Vector3f& rot );
void Setup( const sf::Vector3f& pos );
+ void GLUpdate();
+
void MoveX( int inc );
void MoveY( int inc );
void MoveZ( int inc );
View
285 Geometry.cpp
@@ -1,175 +1,278 @@
#include "Geometry.h"
+#include <iostream>
+using namespace std;
+
namespace ursa
{
Geometry::Geometry()
{
- m_position.x = m_position.y = m_position.z = 0;
- m_dimensions.x = m_dimensions.y = m_dimensions.z = 0;
}
-Geometry::Geometry( const sf::Vector3f& pos, const sf::Vector3f& dim )
+Geometry::Geometry( const sf::Vector3f& pos, const sf::Vector3f& dim, const sf::Vector3i& index )
{
- Setup( pos, dim );
+ Setup( pos, dim, index );
}
-void Geometry::Setup( const sf::Vector3f& pos, const sf::Vector3f& dim )
+void Geometry::Setup( const sf::Vector3f& pos, const sf::Vector3f& dim, const sf::Vector3i& index )
{
- m_position = pos;
- m_dimensions = dim;
+ m_cursorOn = false;
+ m_index = index;
+
+ m_lstPoints.push_back( sf::Vector3f( pos.x, pos.y, pos.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x + dim.x, pos.y, pos.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x + dim.x, pos.y + dim.y, pos.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x, pos.y + dim.y, pos.z ) );
+
+ m_lstPoints.push_back( sf::Vector3f( pos.x, pos.y, pos.z + dim.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x + dim.x, pos.y, pos.z + dim.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x + dim.x, pos.y + dim.y, pos.z + dim.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x, pos.y + dim.y, pos.z + dim.z ) );
}
-void Geometry::Draw( const GLuint& texture )
+void Geometry::Draw( const Texture& texture )
{
+ glEnable( GL_TEXTURE_2D );
glBegin( GL_QUADS );
- glBindTexture( GL_TEXTURE_2D, texture );
+ glBindTexture( GL_TEXTURE_2D, texture.m_texture );
DrawXY();
DrawXZ();
DrawYZ();
glEnd();
+ glDisable(GL_TEXTURE_2D);
+
+ DrawLines();
+}
+
+void Geometry::CheckCursor( const sf::Vector3f& cursor )
+{
+// cout << "Compare: " << endl;
+// cout << m_index.x << ", " << m_index.y << ", " << m_index.z << endl;
+// cout << cursor.x << ", " << cursor.y << ", " << cursor.z << endl;
+ if ( cursor.x == (int)(m_index.x) &&
+ cursor.y == (int)(m_index.y) &&
+ cursor.z == (int)(m_index.z) )
+ {
+ m_cursorOn = true;
+ }
+ else
+ {
+ m_cursorOn = false;
+ }
}
void Geometry::DrawXY()
{
- glColor3f( 1.0f, 1.0f, 1.0f );
+ if ( m_cursorOn )
+ {
+ glColor3f( 1.0f, 1.0f, 0.0f );
+ }
+ else
+ {
+ glColor3f( 1.0f, 1.0f, 1.0f );
+ }
+
+ glTexCoord2f(0.0f, 1.0f);
+ glVertex3f( m_lstPoints[0].x,
+ m_lstPoints[0].y,
+ m_lstPoints[0].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z );
+ glVertex3f( m_lstPoints[1].x,
+ m_lstPoints[1].y,
+ m_lstPoints[1].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[2].x,
+ m_lstPoints[2].y,
+ m_lstPoints[2].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[3].x,
+ m_lstPoints[3].y,
+ m_lstPoints[3].z );
- glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z );
+ glTexCoord2f(0.0f, 1.0f);
+ glVertex3f( m_lstPoints[4].x,
+ m_lstPoints[4].y,
+ m_lstPoints[4].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[5].x,
+ m_lstPoints[5].y,
+ m_lstPoints[5].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[6].x,
+ m_lstPoints[6].y,
+ m_lstPoints[6].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
-
- glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[7].x,
+ m_lstPoints[7].y,
+ m_lstPoints[7].z );
}
void Geometry::DrawXZ()
{
- glColor3f( 0.6f, 0.6f, 0.6f );
+ if ( m_cursorOn )
+ {
+ glColor3f( 1.0f, 1.0f, 0.0f );
+ }
+ else
+ {
+ glColor3f( 0.6f, 0.6f, 0.6f );
+ }
+
+ glTexCoord2f(0.0f, 0.0f);
+ glVertex3f( m_lstPoints[0].x,
+ m_lstPoints[0].y,
+ m_lstPoints[0].z );
glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z );
+ glVertex3f( m_lstPoints[1].x,
+ m_lstPoints[1].y,
+ m_lstPoints[1].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[5].x,
+ m_lstPoints[5].y,
+ m_lstPoints[5].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z + m_dimensions.z );
-
- glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z );
-
+ glVertex3f( m_lstPoints[4].x,
+ m_lstPoints[4].y,
+ m_lstPoints[4].z );
- glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[3].x,
+ m_lstPoints[3].y,
+ m_lstPoints[3].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[2].x,
+ m_lstPoints[2].y,
+ m_lstPoints[2].z );
glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[6].x,
+ m_lstPoints[6].y,
+ m_lstPoints[6].z );
+ glTexCoord2f(1.0f, 1.0f);
+ glVertex3f( m_lstPoints[7].x,
+ m_lstPoints[7].y,
+ m_lstPoints[7].z );
}
void Geometry::DrawYZ()
{
- glColor3f( 0.4f, 0.4f, 0.4f );
+ if ( m_cursorOn )
+ {
+ glColor3f( 1.0f, 1.0f, 0.0f );
+ }
+ else
+ {
+ glColor3f( 0.4f, 0.4f, 0.4f );
+ }
glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z );
+ glVertex3f( m_lstPoints[0].x,
+ m_lstPoints[0].y,
+ m_lstPoints[0].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[4].x,
+ m_lstPoints[4].y,
+ m_lstPoints[4].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[7].x,
+ m_lstPoints[7].y,
+ m_lstPoints[7].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[3].x,
+ m_lstPoints[3].y,
+ m_lstPoints[3].z );
glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z );
+ glVertex3f( m_lstPoints[1].x,
+ m_lstPoints[1].y,
+ m_lstPoints[1].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[5].x,
+ m_lstPoints[5].y,
+ m_lstPoints[5].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[6].x,
+ m_lstPoints[6].y,
+ m_lstPoints[6].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[2].x,
+ m_lstPoints[2].y,
+ m_lstPoints[2].z );
+}
+
+void Geometry::DrawLines()
+{
+// if ( m_cursorOn )
+// {
+// glColor3f( 1.0f, 1.0f, 0.0f );
+// }
+// else
+// {
+// glColor3f( 1.0f, 1.0f, 1.0f );
+// }
+//
+// // XZ bottom
+// glBegin( GL_LINES );
+// glVertex3f( m_lstPoints[0].x, m_lstPoints[0].y, m_lstPoints[0].z );
+// glVertex3f( m_lstPoints[1].x, m_lstPoints[1].y, m_lstPoints[1].z );
+// glVertex3f( m_lstPoints[5].x, m_lstPoints[5].y, m_lstPoints[5].z );
+// glVertex3f( m_lstPoints[4].x, m_lstPoints[4].y, m_lstPoints[4].z );
+// glVertex3f( m_lstPoints[0].x, m_lstPoints[0].y, m_lstPoints[0].z );
+// glEnd();
+//
+// // XZ top
+// glBegin( GL_LINES );
+// glVertex3f( m_lstPoints[3].x, m_lstPoints[3].y + 0.1, m_lstPoints[3].z );
+// glVertex3f( m_lstPoints[2].x, m_lstPoints[2].y + 0.1, m_lstPoints[2].z );
+// glVertex3f( m_lstPoints[6].x, m_lstPoints[6].y + 0.1, m_lstPoints[6].z );
+// glVertex3f( m_lstPoints[7].x, m_lstPoints[7].y + 0.1, m_lstPoints[7].z );
+// glVertex3f( m_lstPoints[3].x, m_lstPoints[3].y + 0.1, m_lstPoints[3].z );
+// glEnd();
+//
+// // ZY Lines
+// glBegin( GL_LINES );
+// glVertex3f( m_lstPoints[0].x, m_lstPoints[0].y, m_lstPoints[0].z );
+// glVertex3f( m_lstPoints[3].x, m_lstPoints[3].y, m_lstPoints[3].z );
+// glEnd();
+//
+// glBegin( GL_LINES );
+// glVertex3f( m_lstPoints[1].x, m_lstPoints[1].y, m_lstPoints[1].z );
+// glVertex3f( m_lstPoints[2].x, m_lstPoints[2].y, m_lstPoints[2].z );
+// glEnd();
+//
+// glBegin( GL_LINES );
+// glVertex3f( m_lstPoints[5].x, m_lstPoints[5].y, m_lstPoints[5].z );
+// glVertex3f( m_lstPoints[6].x, m_lstPoints[6].y, m_lstPoints[6].z );
+// glEnd();
+//
+// glBegin( GL_LINES );
+// glVertex3f( m_lstPoints[4].x, m_lstPoints[4].y, m_lstPoints[4].z );
+// glVertex3f( m_lstPoints[7].x, m_lstPoints[7].y, m_lstPoints[7].z );
+// glEnd();
}
}
View
17 Geometry.h
@@ -1,8 +1,12 @@
#ifndef _GEOMETRY
#define _GEOMETRY
+#include "Texture.h"
+
#include <SFML/Graphics.hpp>
+#include <vector>
+
namespace ursa
{
@@ -10,17 +14,20 @@ class Geometry
{
public:
Geometry();
- Geometry( const sf::Vector3f& pos, const sf::Vector3f& dim );
- void Setup( const sf::Vector3f& pos, const sf::Vector3f& dim );
- void Draw( const GLuint& texture );
+ Geometry( const sf::Vector3f& pos, const sf::Vector3f& dim, const sf::Vector3i& );
+ void Setup( const sf::Vector3f& pos, const sf::Vector3f& dim, const sf::Vector3i& );
+ void Draw( const Texture& texture );
+ void CheckCursor( const sf::Vector3f& cursor );
private:
- sf::Vector3f m_position;
- sf::Vector3f m_dimensions;
+ std::vector<sf::Vector3f> m_lstPoints;
+ sf::Vector3i m_index;
+ bool m_cursorOn;
void DrawXY();
void DrawXZ();
void DrawYZ();
+ void DrawLines();
};
}
View
71 Input.cpp
@@ -1,18 +1,63 @@
#include "Input.h"
#include <iostream>
+using namespace std;
namespace ursa
{
-void Input::HandleInput( const sf::Input& input, Application& app, Camera& camera )
+void Input::HandleInput( Application& app, Camera& camera, std::vector<Geometry>& lstBlocks, sf::Vector3f& cursor )
{
- /* SYSTEM KEYS */
- if ( input.IsKeyDown( sf::Key::Q ) )
+
+ sf::Event event;
+ while ( app.GetEvent( event ) )
{
- app.Quit( true );
+ const sf::Input& input = app.GetInput();
+
+ HandleAppControls( input, app );
+ HandleCameraControls( input, app, camera );
+ HandleMouseControls( input, app, lstBlocks );
+
+ if ( input.IsKeyDown( sf::Key::Numpad8 ) )
+ {
+ cursor.z -= 0.5;
+ }
+ else if ( input.IsKeyDown( sf::Key::Numpad2 ) )
+ {
+ cursor.z += 0.5;
+ }
+ if ( input.IsKeyDown( sf::Key::Numpad4 ) )
+ {
+ cursor.x -= 0.5;
+ }
+ else if ( input.IsKeyDown( sf::Key::Numpad6 ) )
+ {
+ cursor.x += 0.5;
+ }
+
+ /* DEBUG KEYS */
+ if ( input.IsKeyDown( sf::Key::F1 ) )
+ {
+ std::cout << std::endl;
+ std::cout << "Camera Coordinates:\t";
+ std::cout << camera.X() << ", " << camera.Y() << ", " << camera.Z() << std::endl;
+ std::cout << "Camera Rotation:\t";
+ std::cout << camera.RX() << ", " << camera.RY() << ", " << camera.RZ() << std::endl;
+
+ std::cout << std::endl;
+ std::cout << "Mouse Coordinates:\t" << std::endl;
+ std::cout << input.GetMouseX() << ", " << input.GetMouseY() << std::endl;
+
+ std::cout << std::endl;
+ std::cout << "Cursor:" << std::endl;
+ std::cout << cursor.x << ", " << cursor.y << ", " << cursor.z << std::endl;
+ }
+
}
+}
+void Input::HandleCameraControls( const sf::Input& input, Application& app, Camera& camera )
+{
/* MOVEMENT KEYS */
if ( input.IsKeyDown( sf::Key::A ) )
{
@@ -64,16 +109,20 @@ void Input::HandleInput( const sf::Input& input, Application& app, Camera& camer
{
camera.RotateZ( -1 );
}
+}
- /* DEBUG KEYS */
- if ( input.IsKeyDown( sf::Key::F1 ) )
+void Input::HandleAppControls( const sf::Input& input, Application& app )
+{
+ /* SYSTEM KEYS */
+ if ( input.IsKeyDown( sf::Key::Q ) )
{
- std::cout << std::endl;
- std::cout << "Camera Coordinates:\t";
- std::cout << camera.X() << ", " << camera.Y() << ", " << camera.Z() << std::endl;
- std::cout << "Camera Rotation:\t";
- std::cout << camera.RX() << ", " << camera.RY() << ", " << camera.RZ() << std::endl;
+ app.Quit( true );
}
}
+void Input::HandleMouseControls( const sf::Input& input, Application& app, std::vector<Geometry>& lstBlocks )
+{
+}
+
+
}
View
8 Input.h
@@ -3,8 +3,11 @@
#include <SFML/Window.hpp>
+#include <vector>
+
#include "Application.h"
#include "Camera.h"
+#include "Geometry.h"
namespace ursa
{
@@ -12,9 +15,12 @@ namespace ursa
class Input
{
public:
- void HandleInput( const sf::Input& input, Application& app, Camera& camera );
+ void HandleInput( Application& app, Camera& camera, std::vector<Geometry>& lstBlocks, sf::Vector3f& cursor );
private:
+ void HandleCameraControls( const sf::Input& input, Application& app, Camera& camera );
+ void HandleAppControls( const sf::Input& input, Application& app );
+ void HandleMouseControls( const sf::Input& input, Application& app, std::vector<Geometry>& lstBlocks );
};
}
View
28 Texture.cpp
@@ -0,0 +1,28 @@
+#include "Texture.h"
+
+namespace ursa
+{
+
+void Texture::Load( const std::string& filename )
+{
+ sf::Image image;
+ image.LoadFromFile( filename );
+ image.SetSmooth( false );
+
+ glGenTextures( 1, &m_texture );
+ glBindTexture( GL_TEXTURE_2D, m_texture );
+ gluBuild2DMipmaps( GL_TEXTURE_2D,
+ GL_RGBA,
+ image.GetWidth(),
+ image.GetHeight(),
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ image.GetPixelsPtr() );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
+ m_dimensions.x = image.GetWidth();
+ m_dimensions.y = image.GetHeight();
+
+}
+
+}
View
21 Texture.h
@@ -0,0 +1,21 @@
+#ifndef _TEXTURE
+#define _TEXTURE
+
+#include <SFML/Graphics.hpp>
+
+#include <string>
+
+namespace ursa
+{
+
+class Texture
+{
+ public:
+ void Load( const std::string& filename );
+ GLuint m_texture;
+ sf::Vector2f m_dimensions;
+};
+
+}
+
+#endif
View
94 main.cpp
@@ -7,57 +7,70 @@
#include "Camera.h"
#include "Input.h"
#include "Geometry.h"
+#include "Texture.h"
using namespace std;
+void LoadTextures( std::vector<ursa::Texture>& lstTextures );
+
int main()
{
ursa::Application app;
ursa::Camera camera;
- camera.Setup( sf::Vector3f( 0, 0, -50 ) );
+ camera.Setup( sf::Vector3f( -50, 30, -115 ), sf::Vector3f( 52, 0, 0 ) );
ursa::Input input;
+ std::vector<ursa::Texture> lstTextures;
+ LoadTextures( lstTextures );
+
+ const int mapWidth = 10;
+ const int mapDepth = 10;
+
vector<ursa::Geometry> lstBoxes;
- lstBoxes.push_back( ursa::Geometry( sf::Vector3f( 0, 0, 0 ), sf::Vector3f( 10, 10, 10 ) ) );
- lstBoxes.push_back( ursa::Geometry( sf::Vector3f( 10, 0, 0 ), sf::Vector3f( 10, 10, 10 ) ) );
- lstBoxes.push_back( ursa::Geometry( sf::Vector3f( 10, 10, 0 ), sf::Vector3f( 10, 10, 10 ) ) );
- lstBoxes.push_back( ursa::Geometry( sf::Vector3f( 0, 10, 0 ), sf::Vector3f( 10, 10, 10 ) ) );
- lstBoxes.push_back( ursa::Geometry( sf::Vector3f( -10, -10, 0 ), sf::Vector3f( 10, 10, 10 ) ) );
-
- sf::Image imgTxt;
- imgTxt.LoadFromFile( "assets/brick.png" );
- imgTxt.SetSmooth( false );
-
- GLuint texture;
- glGenTextures( 1, &texture );
- glBindTexture( GL_TEXTURE_2D, texture );
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
- imgTxt.GetWidth(), imgTxt.GetHeight(),
- 0, GL_RGBA, GL_UNSIGNED_BYTE, imgTxt.GetPixelsPtr() );
-
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+ for ( int z = 0; z < mapDepth; z++ )
+ {
+ for ( int x = 0; x < mapWidth; x++ )
+ {
+ lstBoxes.push_back( ursa::Geometry( sf::Vector3f( x * 10, 0, z * 10 ),
+ sf::Vector3f( 10, 10, 10 ), sf::Vector3i( x, 0, z ) ) );
+ }
+ }
+
+ sf::Vector3f cursor(0, 0, 0);
while ( !app.Quit() )
{
// Get Events
- sf::Event event;
- while ( app.GetEvent( event ) )
+ input.HandleInput( app, camera, lstBoxes, cursor );
+ if ( cursor.x >= mapWidth )
+ {
+ cursor.x = 0;
+ }
+ else if ( cursor.x < 0 )
+ {
+ cursor.x = mapWidth - 1;
+ }
+ if ( cursor.z >= mapDepth )
+ {
+ cursor.z = 0;
+ }
+ else if ( cursor.z < 0 )
{
- input.HandleInput( app.GetInput(), app, camera );
+ cursor.z = mapDepth - 1;
+ }
+
+ for ( int i = 0; i < lstBoxes.size(); i++ )
+ {
+ lstBoxes[i].CheckCursor( cursor );
}
// Render
app.PrepDraw();
-
- glTranslatef( camera.X(), camera.Y(), camera.Z() );
- glRotatef( camera.RX(), 1.0f, 0.0f, 0.0f );
- glRotatef( camera.RY(), 0.0f, 1.0f, 0.0f );
- glRotatef( camera.RZ(), 0.0f, 0.0f, 1.0f );
+ camera.GLUpdate();
for ( int i = 0; i < lstBoxes.size(); i++ )
{
- lstBoxes[i].Draw( texture );
+ lstBoxes[i].Draw( lstTextures[i%5] );
}
app.FinishDraw();
@@ -65,3 +78,26 @@ int main()
return 0;
}
+
+void LoadTextures( std::vector<ursa::Texture>& lstTextures )
+{
+ ursa::Texture txtGrass;
+ txtGrass.Load( "assets/grass.png" );
+ lstTextures.push_back( txtGrass );
+
+ ursa::Texture txtBrick;
+ txtBrick.Load( "assets/brick.png" );
+ lstTextures.push_back( txtBrick );
+
+ ursa::Texture txtWood;
+ txtWood.Load( "assets/wood.png" );
+ lstTextures.push_back( txtWood );
+
+ ursa::Texture txtSand;
+ txtSand.Load( "assets/sand.png" );
+ lstTextures.push_back( txtSand );
+
+ ursa::Texture txtWater;
+ txtWater.Load( "assets/water.png" );
+ lstTextures.push_back( txtWater );
+}

No commit comments for this range

Something went wrong with that request. Please try again.