Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Kyoukan97

Pages: [1]
1
SFML projects / Re: Isometric tile map
« on: July 15, 2018, 12:29:44 pm »
Good job, man.
It looks really good, perhaps you can use it for some kind of game.

Thanks ! Yea I'd like to, but I am really busy with university right now  :-\

Here are some screenshots with some noisier noise  :D
Small map:
https://imgur.com/GjD3YLE

And a big map aswell:
https://imgur.com/b7HLvTQ

Oddly satisfying to play around with noise maps ;D

2
SFML projects / Re: Isometric tile map
« on: July 14, 2018, 02:08:42 pm »
Hiho,
I put a little more effort into this project again, so I rewrote the entire code and now the map supports slopes !  :) It's still not fully fledged out but you're welcome to check the code out.

Here's a quick image of what it looks like now:
https://imgur.com/0TEOeyb

And here's the code:
https://onlinegdb.com/By3YPvPX7

3
SFML projects / Isometric tile map
« on: June 22, 2018, 04:21:43 pm »
Hi :)
I am working on a small project for which I need an isometric map, that's being procedurally generated.
For the procedural generation I am using a simplex noise class, provided on this repository ( not mine )
https://github.com/SRombauts/SimplexNoise

Here is the code (no GitHub, I know x) )
https://www.onlinegdb.com/rkeg7K5WQ

Known bugs/things to point out:
- Scrolling direction doesn't adjust to map orientation
- Adding the map orientation onto the look-up index into the height map, has no effect yet, because all the vertices of a tile have the same height( for now )

And here is what it looks like so far :)
https://imgur.com/gQLId42

Simply copy&paste the code + the SimplexNoise.h and SimplexNoise.cpp files
You can scroll the map with WASD and rotate it with R

Feel free to use this code in your projects or simply to mess around

4
SFML wiki / Object Properties
« on: August 23, 2015, 10:49:58 pm »
Hi,
i was looking through the SFML-Wiki and I found this article about object property management :
https://github.com/SFML/SFML/wiki/Tutorial%3A-Object-Properties

Can someone explain, how he is able to call "getValue()" & "setValue()" in the member functions get/set of the PropertyManager ? The member variable mList stores an object of type IProperty* , and those functions are no members of that class? I don't get how he does that ^^

P.s My english isnt the best, dont judge  :D

5
SFML projects / Re: TETRIS Clone
« on: August 10, 2015, 10:17:56 pm »
I finally had some time to work on my project and I started from scratch, because i didn't like my layout ;D
Here how far i got, using some of your suggestions  :) ( kind of messy at the moment :D ):
#include <iostream>
#include <memory>
#include <vector>

#include <SFML\Graphics.hpp>

enum class TetrominoType : sf::Uint16 { IBrick, JBrick, LBrick, OBrick, SBrick, TBrick, ZBrick };

struct TetrominoCode
{
        using tCode = std::vector<std::vector < sf::Uint16 >>;

        tCode I = tCode{ { 1, 1, 1, 1 }, { 0, 0, 0, 0 } };
        tCode J = tCode{ { 1, 0, 0, 0 }, { 1, 1, 1, 0 } };
        tCode L = tCode{ { 0, 0, 1, 0 }, { 1, 1, 1, 0 } };
        tCode O = tCode{ { 1, 1, 0, 0 }, { 1, 1, 0, 0 } };
        tCode S = tCode{ { 0, 1, 1, 0 }, { 1, 1, 0, 0 } };
        tCode T = tCode{ { 0, 1, 0, 0 }, { 1, 1, 1, 0 } };
        tCode Z = tCode{ { 1, 1, 0, 0 }, { 0, 1, 1, 0 } };
};

struct TetrominoColor
{
        using tColor = sf::Color;

        tColor I = tColor(152, 245, 255);
        tColor J = tColor(0, 0, 255);
        tColor L = tColor(255, 165, 79);
        tColor O = tColor(255, 255, 0);
        tColor S = tColor(0, 255, 0);
        tColor T = tColor(160, 32, 240);
        tColor Z = tColor(255, 0, 0);
};

struct Tetromino
{
        Tetromino(TetrominoType type, sf::Vector2f size = sf::Vector2f(16.f, 16.f))
        {
                for (sf::Uint16 i = 0; i < 4; i++) m_squares.emplace_back(std::unique_ptr<sf::RectangleShape>(new sf::RectangleShape(size)));

                TetrominoCode  tetrominoCode;
                TetrominoColor tetrominoColor;

                switch (type)
                {
                case TetrominoType::IBrick:
                        create(tetrominoCode.I, tetrominoColor.I); break;
                case TetrominoType::JBrick:
                        create(tetrominoCode.J, tetrominoColor.J); break;
                case TetrominoType::LBrick:
                        create(tetrominoCode.L, tetrominoColor.L); break;
                case TetrominoType::OBrick:
                        create(tetrominoCode.O, tetrominoColor.O); break;
                case TetrominoType::SBrick:
                        create(tetrominoCode.S, tetrominoColor.S); break;
                case TetrominoType::TBrick:
                        create(tetrominoCode.T, tetrominoColor.T); break;
                case TetrominoType::ZBrick:
                        create(tetrominoCode.Z, tetrominoColor.Z); break;
                }
        }

        void create(TetrominoCode::tCode code, TetrominoColor::tColor color)
        {
                for (auto& i : m_squares) i->setFillColor(color);

                sf::Uint16 counter = 0;

                for (sf::Uint16 row = 0; row < 2; row++)
                        for (sf::Uint16 column = 0; column < 4; column++)
                        {
                                if (code[row][column] == 1)
                                {
                                        m_squares[counter]->setPosition(m_squares[counter]->getSize().x * column, m_squares[counter]->getSize().y * row);
                                        counter++;
                                }
                        }
       
        }

        void draw(sf::RenderWindow* window)
        {
                for (auto& i : m_squares) { window->draw(*i); };
        }

        std::vector<std::unique_ptr<sf::RectangleShape>> m_squares;
};

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "TETRIS");

        Tetromino iBrick(TetrominoType::IBrick);

        while (window.isOpen())
        {
                sf::Event ev;
                while (window.pollEvent(ev))
                {
                        if (ev.type == sf::Event::Closed)
                                window.close();
                }
                window.clear();
                iBrick.draw(&window);
                window.display();
        }

        return EXIT_SUCCESS;
}
 

6
SFML projects / TETRIS Clone
« on: July 31, 2015, 05:03:35 pm »
Hi ^.^
I am new to this forum and i currently working on my first game , Tetris *yay*

I just wanted to share my Tetromino class and get some opinions on how i can improve it :) ( i tried messing around with C++11 a bit )
This is the header file :
#ifndef TETROMINO_HPP
#define TETROMINO_HPP

#include <array>

#include <SFML\Graphics.hpp>

enum typeTetrominoID { IBrick, JBrick, LBrick, OBrick, SBrick, TBrick, ZBrick };

struct TetrominoCodes
{
        using TetrominoCode = std::array < std::array<sf::Uint32, 4>, 2 >;

        TetrominoCode I;
        TetrominoCode J;
        TetrominoCode L;
        TetrominoCode O;
        TetrominoCode S;
        TetrominoCode T;
        TetrominoCode Z;

        TetrominoCodes()
                : I(TetrominoCode{ { { 1, 1, 1, 1 }, { 0, 0, 0, 0 } } }),
                  J(TetrominoCode{ { { 1, 0, 0, 0 }, { 1, 1, 1, 0 } } }),
                  L(TetrominoCode{ { { 0, 0, 1, 0 }, { 1, 1, 1, 0 } } }),
                  O(TetrominoCode{ { { 1, 1, 0, 0 }, { 1, 1, 0, 0 } } }),
                  S(TetrominoCode{ { { 0, 1, 1, 0 }, { 1, 1, 0, 0 } } }),
                  T(TetrominoCode{ { { 0, 1, 0, 0 }, { 1, 1, 1, 0 } } }),
                  Z(TetrominoCode{ { { 1, 1, 0, 0 }, { 0, 1, 1, 0 } } })
        {};
};

struct TetrominoColors
{
        using TetrominoColor = sf::Color;

        TetrominoColor I = TetrominoColor(152, 245, 255);
        TetrominoColor J = TetrominoColor(0, 0, 255);
        TetrominoColor L = TetrominoColor(255, 165, 79);
        TetrominoColor O = TetrominoColor(255, 255, 0);
        TetrominoColor S = TetrominoColor(0, 255, 0);
        TetrominoColor T = TetrominoColor(160, 32, 240);
        TetrominoColor Z = TetrominoColor(255, 0, 0);
};

class Tetromino : public sf::Drawable, public sf::Transformable
{
private:
        typeTetrominoID   m_typeID;

        sf::Texture     m_texture;
        sf::Vector2u    m_brickSize;
        sf::VertexArray m_vertices;

        void create(TetrominoCodes::TetrominoCode code, TetrominoColors::TetrominoColor color);

        virtual void draw(sf::RenderTarget& renderTarget, sf::RenderStates renderStates) const;

public:
        Tetromino();
        Tetromino(typeTetrominoID typeID);

        void updateFixed(void);
        void updateVariable(sf::Time dt);
};

#endif // TETROMINO_HPP
 

And this is the .cpp file :
#include <iostream>

#include <SFML\Graphics.hpp>

#include "Tetromino.hpp"

Tetromino::Tetromino()
{}

Tetromino::Tetromino(typeTetrominoID typeID)
        : m_typeID(typeID), m_brickSize(sf::Vector2u(16, 16))
{
        TetrominoCodes  tetrominoCodes;
        TetrominoColors tetrominoColors;

        std::cout << "m_typeID: " << m_typeID << std::endl;

        switch (m_typeID)
        {
        case IBrick:
                create(tetrominoCodes.I, tetrominoColors.I); break;
        case JBrick:
                create(tetrominoCodes.J, tetrominoColors.J); break;
        case LBrick:
                create(tetrominoCodes.L, tetrominoColors.L); break;
        case OBrick:
                create(tetrominoCodes.O, tetrominoColors.O); break;
        case SBrick:
                create(tetrominoCodes.S, tetrominoColors.S); break;
        case TBrick:
                create(tetrominoCodes.T, tetrominoColors.T); break;
        case ZBrick:
                create(tetrominoCodes.Z, tetrominoColors.Z); break;
        }
}

void Tetromino::updateFixed(void)
{
        sf::Vector2f pos = this->getPosition();
        pos.y += m_brickSize.y;

        this->setPosition(pos);
}

void Tetromino::updateVariable(sf::Time dt)
{}

void Tetromino::create(TetrominoCodes::TetrominoCode code, TetrominoColors::TetrominoColor color)
{
        m_vertices.setPrimitiveType(sf::Quads);
        m_vertices.resize(16);

        std::array<std::array<sf::Vertex, 4>, 4> quads;

        sf::Uint16 vertexCounter = 0;

        for (sf::Uint16 i = 0; i < 2; i++)
        {
                for (sf::Uint16 j = 0; j < 4; j++)
                {
                        std::cout << "code[" << i << "][" << j << "]: " << code[i][j] << std::endl;

                        if (code[i][j] == 1)
                        {
                                quads[vertexCounter][0].color = color;
                                quads[vertexCounter][1].color = color;
                                quads[vertexCounter][2].color = color;
                                quads[vertexCounter][3].color = color;

                                quads[vertexCounter][0].position = sf::Vector2f(i * m_brickSize.x, j* m_brickSize.y);
                                quads[vertexCounter][1].position = sf::Vector2f((i + 1) * m_brickSize.x, j * m_brickSize.y);
                                quads[vertexCounter][2].position = sf::Vector2f((i + 1) * m_brickSize.x, (j + 1) * m_brickSize.y);
                                quads[vertexCounter][3].position = sf::Vector2f(i * m_brickSize.x, (j + 1) * m_brickSize.y);

                                for (auto i : quads[vertexCounter])
                                {
                                        m_vertices.append(i);

                                        std::cout << "position: " << i.position.x << ", " << i.position.y << std::endl;
                                }
                                vertexCounter++;
                        }
                }
        }
}

void Tetromino::draw(sf::RenderTarget& renderTarget, sf::RenderStates renderStates) const
{
        renderStates.transform *= getTransform();
        renderStates.texture = &m_texture;

        renderTarget.draw(m_vertices, renderStates);
}
 

P.s my english isn't always on point ... so yea  :D

Pages: [1]
anything