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 - sandwich hoop

Pages: [1]
1
General / Re: Problem with fonts
« on: July 25, 2024, 07:30:49 pm »
Are you storing the .ttf in the correct directory? Should be the working one with all your other stuff.

2
I wasnt using local coordinates, I am so dumb I've spent weeks on this...

3
Hi,
I'm trying to add a gun that fires in the direction of the mouse from a centre point, this code only fires accurately when my mouse is incredibly far away (but without changing the angle) and I want it to be accurate at all distances. I've been stuck on this for ages, I know my maths is probably wrong but I just don't know why it works at some distances.
Thank you, sorry if this is a repeat question

//where it starts
        int aky = akSprite.getPosition().y;
        int akx = akSprite.getPosition().x;
       
        //checks for mouse position
        int mousey1 = this->mouse.getPosition().y;
        int mousex1 = this->mouse.getPosition().x;

        //how many large or small the movement is
        const int distance = 30;

        std::cout << "\n The mouse position used is x: " << mousex1 << " y: " << mousey1 << "\n The launch position is x: " << akx << " y: " << aky;




       
       
       
        //finds the height and width of that position and lowers it to movable values
         travely = (mousey1 - aky) / distance;
         travelx = (mousex1 - akx) / distance;
         
         //global variable for bullet&#39;s position
        totalx = akx;
        totaly = aky;

       

        //the bullets position updates constantly elsewhere while this is only run when the fire key is pressed
       
        std::cout << "\n The current MOVEMENTS ARE x: " << travelx << " y: " << travely;

4
Window / Re: Two instances of game both accepting same input.
« on: July 05, 2024, 09:04:23 pm »
Exactly what I was looking for! Thanks! This is such a useful little feature I wish I knew about sooner!
:)

5
Window / Two instances of game both accepting same input.
« on: July 04, 2024, 05:03:16 pm »
Hi,
When I have two instances of my game open, and try to press A to move left (which does work) both instances of the game accept the A input. My question is, is there any way to create a window which won't overlap with other instances so that if I press A in one, it doesn't impact the other? Hope that makes sense, I can clarify things if needed, hopefully, I'm just overlooking something simple.

Edit: I can't just run it on another computer because what I'm testing is the network connection, but I want to get everything else working before I figure out how to do it between computers.

:)

6
Graphics / Can't create font face, can't load images.
« on: June 10, 2024, 10:25:21 am »
This happens even though all of the files are in the correct directories. (I've put them in every directory simultaneously to make sure it can't miss them, and it still can't find them). All of the code is correct and error free as it is copied exactly from another machine. I really do not know what else I've done wrong. I feel like there may have been something really basic that I've missed but I can't think of it. I've setup sfml about 4 times now.

Help appreciated.

7
General / Re: Jittery movement
« on: March 19, 2023, 04:41:51 pm »
 ;D

8
General / White square issue
« on: March 19, 2023, 04:40:58 pm »
Hi,
I'm sure this is asked a lot, but I've been trying for hours and can't seem to fix the white box issue with my textures.

This is the code I'm using:
(click to show/hide)
Sorry, thanks!

9
General / Re: Jittery movement
« on: March 18, 2023, 08:26:29 pm »
Nevermind, I borrowed someone else on here's code and switched the variable names and it works. Thanks for your time.

Solution:

while (this->window->pollEvent(this->ev))
        {

                if (sf::Event::Closed)
                {
                        this->window->close();
                        break;

                }

                if (this->ev.key.code == sf::Keyboard::Escape)
                {

                        this->window->close();

                }




        }

                        int i = 0;

                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {
                                this->players[i].move(0, -3);
                       
                        }
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
                                this->players[i].move(0, 3);
               
                        }
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
                                this->players[i].move(-3, 0);
               
                        }
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
                                this->players[i].move(3, 0);
               
                        }

10
General / Re: Jittery movement
« on: March 18, 2023, 08:10:55 pm »
Sorry for the late reply, I tried this and it had the same effect, I noticed a difference when moving diagonally but there I still a pause when using

if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))

sorry if I'm being dumb but I've been trying to fix this for weeks and I have no idea haha!

11
General / Jittery movement
« on: February 25, 2023, 07:37:02 pm »
Hi there, sorry if this is asked a lot, I have written some movement code for a little game, the code works, however on key press, it moves 1 tick of movement, before smoothly moving when held after about a second.

while (this->window->pollEvent(this->ev))
        {
                switch (this->ev.type)
                {
                case sf::Event::Closed:
                                this->window->close();
                                break;
                case sf::Event::KeyReleased:
                        if (this->ev.key.code == sf::Keyboard::Escape)
                        {

                                this->window->close();

                        }

                        int i = 0;

                        if (this->ev.key.code == sf::Keyboard::W)
                        {

                                this->players[i].move(0.f, -15);

                        }

                        if (this->ev.key.code == sf::Keyboard::A)
                        {

                                this->players[i].move(-15, 0.f);

                        }

                        if (this->ev.key.code == sf::Keyboard::S)
                        {

                                this->players[i].move(0.f, 15);

                        }

                        if (this->ev.key.code == sf::Keyboard::D)
                        {

                                this->players[i].move(15, 0.f);

                        }
               
                }





        }




 


My question is if there is a simple way of fixing this so that the movement is smooth immediately. Thanks :)

Pages: [1]