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

Pages: 1 [2] 3 4 ... 25
16
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 05:07:21 pm »
your code is getting to the point it returns 0. i cant be sure in the video, but didn't you typed
while (window.isOpen())}
instead of
while (window.isOpen()){
?
EDIT: NVM, its right. the video quality was confusing me about it.


try changing libsfml-graphics-d for sfml-graphics-d (and also do it for window, audio, and system) in linker settings.

17
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 01:06:21 pm »
doesn't seems to be a big deal. take some printscreens to help finding the problem:
1- your folder containing the lib files
2- in project Build Options, print of "compiler settings", "linker settings", and "search directories"

18
General / Re: Jittery movement
« on: February 26, 2023, 12:57:06 pm »
this is due to your keyboard default delay time between keypresses. if you open any text editor and hold a letter like W, you'll notice it behaves exactly the same.

so, for this type of movement, you don't want to use keyboard events. you can use the keyboard global state. instead of
if (this->ev.key.code == sf::Keyboard::W)
use
if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))

also, your switch statement is a bit messy. why don't you use simply 'if' for now until you get the hang of things?

19
it seems to be removed from Packt for some reason. maybe you can still find some printed copies around...

20
SFML website / Re: signature is confused about smileys
« on: January 30, 2023, 02:18:47 pm »
oops, I forgot the .html extension. thanks!

21
SFML website / signature is confused about smileys
« on: January 30, 2023, 01:47:22 pm »
Its says you can use smileys in the signature. Then it says you can't  :P






22
General / Re: Moving springs separately
« on: January 24, 2023, 03:31:05 pm »
I'm still unable to test your code, its incomplete

EDIT: put
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
                                god.sprite.move(-2.f, 0.f);

and such outside of this loop
while (window.pollEvent(event))

23
General / Re: Moving springs separately
« on: January 24, 2023, 01:24:28 pm »
sorry, your example is still not complete nor working. I don't know what is inside App class, and what class godzilla, dino, etc belongs to.

check this example, it does what you want to. maybe you can use it in your code.

#include <SFML/Graphics.hpp>

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

    sf::CircleShape circle1(50.f);
    sf::CircleShape circle2(50.f);

    circle1.setFillColor(sf::Color::Blue);
    circle2.setFillColor(sf::Color::Red);

    circle1.setPosition(100, 100);
    circle2.setPosition(400, 400);

    while (window.isOpen()){
        sf::Event event;
        while (window.pollEvent(event)){
            if (event.type == sf::Event::Closed){
                window.close();
            }
        }

        //Moving Circle 1
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
            circle1.move(-1.f, 0.f);
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
            circle1.move(1.f, 0.f);
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)){
            circle1.move(0.f, -1.f);
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
            circle1.move(0.f, +1.f);
        }

        //Moving Circle 2
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)){
            circle2.move(-1.f, 0.f);
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)){
            circle2.move(1.f, 0.f);
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)){
            circle2.move(0.f, -1.f);
        }
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)){
            circle2.move(0.f, +1.f);
        }

        window.clear(sf::Color::White);
        window.draw(circle1);
        window.draw(circle2);
        window.display();
        sf::sleep(sf::milliseconds(10));
    }
}

24
General / Re: Moving springs separately
« on: January 24, 2023, 11:49:59 am »
look, we can't really understand what is happening ir this small piece of code. you'll need to provide a minimal working example.

we don't know what this does. maybe you could try simply removing it?
if (app.isKeyReleased())
         {
            dino.processEvents(app.e.key.code, false);
            player.procesEvents(app.e.key.code, false);
         }

25
General / Re: Moving springs separately
« on: January 21, 2023, 06:43:01 pm »
not really...  :-\
can you post some more code? ir a minimal working example?

26
General / Re: Textures aren't showing
« on: January 21, 2023, 06:41:17 pm »
you are creating the 'Texture grass_tex;' inside the function 'init_grass()', but as soon as the function ends, the texture (and all other local variables) are lost
you need to declare this Texture somewhere. next to the declaration of 'grass' (rectangleshape) should work

27
General / Re: Moving springs separately
« on: January 19, 2023, 02:42:58 pm »
well, its unclear what you mean...
you can move each sprite using
sprite_var.setPosition(x, y)
//or
sprite_var.move(x, y)

28
Graphics / Re: RenderTexture Canvas Touch Offset Problem
« on: January 12, 2023, 12:03:43 pm »
if the canvas is just a RenderTexture, it doesn't have a position, only the sprite does. are you trying to paint only part of the screen? or all of it is part of the painting area? just to know how we could adjust the positions.

29
i don't know if I understand what you are trying to do
but you could use a sf::vector2f instead. and the way you're doing its not inefficient at all, its simply conditionals

sf::vector2f mcoords(10, 20); //you can acces individual values with mcoords.x or mcoords.y
if (mcoords != sf::Mouse::getPosition(MaWind){
//code
}
 

30
so afterall it WAS being drawn offscreen  ;D
good thing you fixed it

Pages: 1 [2] 3 4 ... 25
anything