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

Pages: [1] 2
1
General / Re: Scaling
« on: December 04, 2019, 06:05:06 pm »
Good point. What about this:
void Player::setViewSize(sf::Vector2u NewSize)
{
    const sf::Vector2u defaultSize{960, 540};
    unsigned int scaleFactor = 1;
    while(NewSize.x / scaleFactor > defaultSize.x || NewSize.y / scaleFactor > defaultSize.y)
        scaleFactor++;
    PlayerView.setSize(static_cast<float>(NewSize.x / scaleFactor), static_cast<float>(NewSize.y / scaleFactor));
}

2
General / Static linking Linux
« on: December 04, 2019, 05:59:51 pm »
I want to do a static link for a project that I'm working on and I wrote this example:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow AppWindow;
    sf::Event AppEvent;
    AppWindow.create(sf::VideoMode(800, 600), "app");
    AppWindow.setVerticalSyncEnabled(true);
    while(AppWindow.isOpen())
    {
        while(AppWindow.pollEvent(AppEvent))
        {
            if(AppEvent.type == sf::Event::Closed)
                AppWindow.close();
        }
        AppWindow.clear();
        AppWindow.display();
    }
    return 0;
}
And then compile it with:
g++ main.cpp -static -o test -lsfml-graphics -lsfml-window -lsfml-system
After this message showed up:
/usr/bin/ld: cannot find -lsfml-graphics
/usr/bin/ld: cannot find -lsfml-window
/usr/bin/ld: cannot find -lsfml-system
collect2: error: ld returned 1 exit status
SFML is installed from the official Manjaro repo.

3
General / Scaling
« on: November 21, 2019, 06:42:49 pm »
I'm developing a game, and I want to support different resolutions, so I need to make a scaling algorithm. This is what i came up with:
void Player::setViewSize(sf::Vector2f ViewSize)
{
    const sf::Vector2f defaultSize{960, 540}; // A size constant. I came up with it because it is a quarter of 1080p
    float scaleFactor = 1;
    while(ViewSize.x / scaleFactor > defaultSize.x || ViewSize.y / scaleFactor > defaultSize.y)
        scaleFactor++;
    PlayerView.setSize(ViewSize.x / scaleFactor, ViewSize.y / scaleFactor);
}
 

Are there better scaling algorithms? If so? Can you recommend one?
*edit: Please Remove the other 2 posts

4
General / Threading
« on: September 28, 2019, 03:46:34 pm »
I want to use multi-thread for a level editor with test levels feature, now i want to test multi-thread on this piece of code:
#include <TGUI/TGUI.hpp>
#include <SFML/System.hpp>

sf::View Canvas_view;

// Move canvas view
void Move()
{
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
                Canvas_view.move(0, -0.2f);
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
                Canvas_view.move(0, 0.2f);
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
                Canvas_view.move(-0.2f, 0);
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
                Canvas_view.move(-0.2f, 0);
}

sf::Texture texture;
sf::Sprite sprite;

// Test thread
void test(tgui::Canvas::Ptr canvas)
{
        Move();
        canvas->clear();
        canvas->draw(sprite);// Draw sprites
        canvas->setView(Canvas_view);// Set view
        canvas->display();
}

int main()
{
    sf::RenderWindow Window;
        Window.create(sf::VideoMode(800, 400), "app", sf::Style::Default);
        tgui::Gui App;
    App.setTarget(Window);
    sf::View view = Window.getDefaultView();
        // Canvas creaton
        tgui::Canvas::Ptr canvas = tgui::Canvas::create();
        canvas->setPosition(100, 100);
        canvas->setSize(200, 200);
        canvas->clear();
        App.add(canvas, "Canvas");
        texture.loadFromFile("test.png");
        sprite.setTexture(texture);
        sf::Event event;
        while (Window.isOpen())
        {
                while (Window.pollEvent(event))
                {
                        // General stuff
                        if(event.type == sf::Event::Closed)
                                Window.close();
                        if(event.type == sf::Event::Resized)
            {
                view.reset(sf::FloatRect(0 , 0, Window.getSize().x, Window.getSize().y));
                App.setView(view);
            }  
                        App.handleEvent(event);
                }
                Window.clear();
                App.draw();
                Window.setView(view);
                Window.display();
        }
        return 0;
}
And i don't know how to do it properly without crashing the whole program or the computer

5
General / Re: Gnome autoscaling
« on: September 22, 2019, 05:00:49 pm »
Version 2.5.1-1

6
General / Re: Gnome autoscaling
« on: September 22, 2019, 09:35:08 am »
No, I don't use any tiling software

7
General / Re: Gnome autoscaling
« on: September 21, 2019, 05:53:50 pm »
Just the 'client' part.

8
General / Gnome autoscaling
« on: September 21, 2019, 01:35:06 pm »
I'm creating a game, but when i open it Gnome sets the resolution of the window to 1280x963 when it need to be 1280x768.
Source code: https://github.com/CatalinNic1/The-Spell-Remake

9
General / Re: Texture position
« on: August 24, 2019, 01:18:37 pm »
about that, i gave up on that

10
General / Texture position
« on: August 24, 2019, 09:47:19 am »
Hello, I have a huge image to load (5320x2880) and i want to load only the tiles and I don't know how set texture position, weirdly i read that OpenGL is capable to do that, how I can do that without touching OpenGL's functions? For more clarity this is what I have now:
#include "Big_rect.hpp"
#include <memory.h>

bool Big_rect::Load_from_file(const std::string& File_name)
{
    sf::Image Image;
    Image.loadFromFile(File_name);
    sf::Vector2u Texture_size = Image.getSize();
    for(uint i = 0; i < Texture_size.y; i += 32)
        for (uint j = 0; j < Texture_size.x; j += 32)
        {
            /* code */
            // When the texturing will happen
        }
}

sf::Texture* Big_rect::Acquire_big_texture(sf::Image Big_image, sf::IntRect Big_texture_int_rect)
{
    sf::Texture* tex;
    tex->loadFromImage(Big_image, Big_texture_int_rect);
    for(Big_texture_iter = Big_texture.begin(); Big_texture_iter != Big_texture.end(); Big_texture_iter++)
        if(memcmp(*Big_texture_iter, tex, sizeof(sf::Texture)) == 0)
            return *Big_texture_iter;
    return tex;
}
 

and the header:
struct Big_rect: sf::RectangleShape
{
    bool Load_from_file(const std::string& File_name);
    std::vector< sf::Texture* > Big_texture;
    std::vector< sf::Texture* >::iterator Big_texture_iter;
private:
    sf::Texture* Acquire_big_texture(sf::Image Big_image, sf::IntRect Big_texture_int_rect);
};
 

11
General / Re: View colissions
« on: August 11, 2019, 05:44:55 pm »
Thanks, a lot

12
General / View colissions
« on: August 11, 2019, 12:28:20 pm »
I want to reduce the number of draw calls by verifying if the view is colliding with "Some object" sprite. Eg. I have 50 enemies and i want to draw only who are colliding with the camera.and I don't know how.

13
General / Re: Moving View
« on: July 24, 2019, 09:52:18 pm »
But I don't know why it acts normally when the value is 4, 5, 6, etc.

14
General / Re: Moving View
« on: July 24, 2019, 12:55:45 pm »
The problem:
When I change the "Movement_speed" value to some float like 4.75 the function bounces the view up and down or left to right.

15
General / Moving View
« on: July 24, 2019, 10:42:19 am »
Hi I try to move view that changes his position to be indentical (in some instances) with position of the player but in some key specific cases to lock the movement for some directons
void Ai::Move_view()
{
    if(Player1.Rect1.getPosition().y > Map_view.getCenter().y && Map_view.getCenter().y + 360 < Map_margin_y)
        Map_view.move(0, Player1.Movement_speed);
    else if(Player1.Rect1.getPosition().y < Map_view.getCenter().y && Map_view.getCenter().y - 360 > 0)
        Map_view.move(0, -Player1.Movement_speed);
    else if(Player1.Rect1.getPosition().x > Map_view.getCenter().x && Map_view.getCenter().x + 640 < Map_margin_x)
        Map_view.move(Player1.Movement_speed, 0);
    else if(Player1.Rect1.getPosition().x < Map_view.getCenter().x && Map_view.getCenter().x - 640 > 0)
        Map_view.move(-Player1.Movement_speed, 0);
}
 

Pages: [1] 2