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 - ankitpaudel20

Pages: [1]
1
Isn't that for rectangle whose sides are aligned with axes?

I meant to ask if it had rotations and other transformations applied ?

2
Graphics / Easy method to check if a point is inside of a Rectangle shape
« on: February 08, 2020, 09:18:36 am »
i want to check for collision detection of rectangle but didn't find a way to check if the point is inside the rectangle so any ideas?

3
Graphics / Implementation of a 2d Destructible terrain with Sfml
« on: February 02, 2020, 09:41:50 am »
I came up with an implementation of destructible terrain idea which includes making vertex arrays for each pixel column of screen and the process of destroying it. It is computationally very slow and if there is a way to maintain the destructibility and fall of pixels after destroying the area clicked? I want to make a single vertexarray so that there is a single drawcall.

this is my github repo for project.


https://github.com/ankitpaudel20/Terrain.git

4
I wanted to write class just like sf::shape but when i try to do so by implementing virtual function draw at sf::drawable i cant what am i missing here??


#pragma once
#include<SFML/Graphics.hpp>
class terrain : sf::Drawable
{
private:
        sf::Vector2u                                    window_size;
        const sf::Texture* m_texture;
        sf::IntRect                                             m_textureRect;
        sf::Color                                               m_fillColor;
        std::vector<sf::VertexArray>    fills;
        std::map<sf::Vertex, bool>              draw;
        sf::VertexArray                                 m_vertices;
        sf::FloatRect                                   m_bounds;
        bool                                                    need_update;


        sf::Vector2f computeNormal(const sf::Vector2f& p1, const sf::Vector2f& p2);

        float dotProduct(const sf::Vector2f& p1, const sf::Vector2f& p2);

        void draw(sf::RenderTarget& target, sf::RenderStates states) const;
};

defination:

#include "terrain.h"

sf::Vector2f terrain::computeNormal(const sf::Vector2f& p1, const sf::Vector2f& p2)
{
        sf::Vector2f normal(p1.y - p2.y, p2.x - p1.x);
        float length = std::sqrt(normal.x * normal.x + normal.y * normal.y);
        if (length != 0.f)
                normal /= length;
        return normal;
}

float terrain::dotProduct(const sf::Vector2f& p1, const sf::Vector2f& p2)
{
        return p1.x * p2.x + p1.y * p2.y;
}


void terrain::draw(sf::RenderTarget &target, sf::RenderStates states) const{

        states.texture = m_texture;
        target.draw(m_vertices, states);

}


it says
Error   C2063   'terrain::draw': not a function

Error   C2365   'terrain::draw': redefinition; previous definition was 'data member'



how do i fix this?

5
Graphics / Making new shape with particle fill.
« on: January 18, 2020, 08:58:08 am »
I am very new to graphics programming and so decided to use sfml for my project. Now i am trying to generate random 2d terrain with small particle fill so that i can make the terrain  destroyable and hence be able to delete those filled particle at specific part of the game thus reshape the terrain afterward..I did not find any easy way of doing this with shapes.. any way of doing so would be very helpful.

Pages: [1]
anything