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

Pages: 1 [2] 3 4 5
16
Graphics / Re: Passing Entity Position to an If Statement
« on: May 14, 2017, 09:00:22 am »
Is this entity a sfml object? If so:

NameOfEntity.getPosition().x will give you the horizontal position.

NameOfEntity.getPosition().y will give you the vertical position.

Example:
float xSpeed = 1, ySpeed = 0.2;
entity.move(xSpeed, ySpeed);
If(entity.getPosition().x > 500) {
  xSpeed = xSpeed * -1;
  entity.move(xSpeed, 0);
}

else If(entity.getPosition().x < 10) {
  xSpeed = xSpeed * -1;
  entity.move(xSpeed, 0);
}

 

(written from my phone, so sorry for any typos)
This code will have entity move back and forward horizontally
It will also move down vertically, but I have not added any code to make it change the y direction...
Hint: it's nearly the same as the one that chanqged the x direction...

Best regards

17
General / Re: Jump height varies slightly
« on: May 13, 2017, 09:44:54 am »
Okay.
Having no way to test this, and no images , my guess is that the error is not so much how high you jump.
But where you jump from.
Eg, it looks like you don't have a way to align the jumper with the ground after they land. So they may land a few pixels into the ground... Then jumping later, they ofcourse will miss those pixels I jumping hight.

That is my guess at least....

18
General / Re: Jump height varies slightly
« on: May 13, 2017, 08:31:06 am »
I'm guessing this data is from the characters decent?
(As I see it it looks like the velocity is accelerating on the positive y axis. Thus moving the sprite faster and faster downwards.)

That's fine and all and don't really say anything about the issue.

What is your code used
: to activate the jump
: to calculate the yVelocity
: to stop the sprite on ground collision
?

Best regards

19
General / Re: VS 2017 Template errors
« on: May 13, 2017, 08:22:44 am »
Indeed, I have also posted this on stackoverflow, and will copy the answer here (if one such shows itself :) )

In this case it's my cpp and h files. It's just my basic sfml setup:
main.cpp
Window.h, Window.cpp
Game.h and Game.cpp

Of course, it also does not copy my debug and release dlls but it has never done that for me..

20
General / VS 2017 Template errors
« on: May 13, 2017, 01:24:44 am »
So..
I recently updated to VS 2017. and after some problems managed to get my setup to work with sfml 2.4.2
BUT....
I tried to export my project as a template. seemed to work fine.
making a new project also seemed to work fine... right up until i tries to open any file.. they are not there....
They are in the solution explore, but not in the actual folders, trying to open them gives the message:
"The document cannot be opened. It has been renamed, deleted or moved"
Going to the project folder i find this to be true... it is empty...
So, i have to manually copy each cpp, h and dll file into the right folders...

anyone encountered this issue before?
and if... did you solve it and how? my google-fu does not bring much light to the issue

21
General / Re: Smart Moving Problem
« on: May 12, 2017, 01:34:59 pm »
I also notes you write this line:
#include <vector> //I tried to this many times so I don't know if you need this.
 
Best way to figure that out is to just delete the line and see if anything happens, if it does, place it right back in ;)
I disagree with this advice. Something you include may include it for you but then if, in the future, you stop needing the other thing, you may still need it. It's best to explicitly include it if you need it regardless of if its already included elsewhere.

You include "<vector>" if you wish to use a vector. That is, if you have a std::vector in your code, you should include it.

I guess i did not conveyed what i meant properly.
I meant that if you do not know if the code "as is" need the inclusion. that is, if your current code uses that inclusion.
The fastes way to figure that out is to just delete the line, that will tell you if it is used.

*Also, this advice only counts for inclusions. doing the same to other inline code may not show it self as an error right away...

22
General / Re: Smart Moving Problem
« on: May 10, 2017, 05:41:03 pm »
Great work :)
Just looked it over, and it works great.

about why the ship stops when you multiply m_yVel and m_xVel with 0.99 or something:
as you know, the two Vel is the velocity, or speed of the object if you will.
if the objects xVel is 10, and you then multiply it by 0.9, it becomes 9.
next time you multiply it, it will become 8.1
then it will become 7,29, then 6,561.
the reason is that each time, you multiply vel by 0.9, its the same as removing 10% of the speed, multiplying by 0.99 is removing 1%, and multiplying by 1 is removing nothing. basically multiplying by 1 means keep 100%, 0,5 means keep 50% and 0.25 means keep 25%

I also notes you write this line:
#include <vector> //I tried to this many times so I don't know if you need this.
 
Best way to figure that out is to just delete the line and see if anything happens, if it does, place it right back in ;)

23
SFML projects / Re: A SFML Prototypes collection
« on: May 10, 2017, 05:06:40 pm »
I know that feeling...
The whole idea of putting something together fast/without optimizing on the go is intimidating.
I blame tutorials... Well, some.. A lot of tutorials teaches "to code perfectly/clean" so it feels wrong not to...

But awesome you put up a link :) I did read that game entry before, but have not tried it out... I will do :)

24
General discussions / Re: Books list and suggestions.
« on: May 10, 2017, 05:01:23 pm »
Those are all good suggestions/lists.
Thank you guys.

And SeriousITGuy, I agree, that is a great book :) and I'll look into the original sfml book then :)

25
Graphics / Re: Pixel perfect collision detection or is it needed?
« on: May 09, 2017, 03:19:30 pm »
Well, it's a long time since, but what I did when I needed pixel.perfect collision (for a lemmings like game)
Was:
1: spatial partitioning, terrain was decided in 32 by 32 boxes.
2: bounding box collision on anything shown in 1.
3: inner box collision (8 by 8 boxes inside the 32 by 32 boxes of the terrain)
4: pixel perfect collision on anything inside any 8 by 8 box that hit whatever I was testing against.

Why? Because testing 15 figures of 8 by 16 pixels and each weapon/tool effects texture against a map of > 1000 by 1000 pixels was simply to much.
This way it was just any 8 by 8 square close enough against a 8 by 16.
And that was still over 8000 tests...

Just some experience... That said... It was in Java and many years ago..

26
SFML projects / A SFML Prototypes collection
« on: May 09, 2017, 12:54:42 am »
Okay, so i guess the title says it a bit.

I felt like making a SFML game prototype, a fully functional game incorporating both keyboard, mouse, rotation, lists, iteration, hittests, vectors all that, in as small a code as i could without any needless optimization.. a game that anyone who wants, can take apart and put together as they want...

But even more, i would Love if we could make a collection of such short, fully functional games. some like this in just one file.
some using functions.
some using multiple files and headers
but all small, gritty fully functional for others to pick apart.
maybe make tutorials on them...
This is not about CORRECT code... this is about WORKING code.... the key stone to prototyping....

Why? Because that was how i learned to program back in the day... i took working games (Pacal, VB and later Flash AS2 games btw) and made changes until they did something differently so i could figure out what it was...

So... here is around an hours work.
First the full code without comments and without extra line space.

Main.cpp
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <list>
void main(int argc, char** argv[]) {
        sf::RectangleShape m_tankBody;
        m_tankBody.setFillColor(sf::Color(120, 150, 120));
        m_tankBody.setSize(sf::Vector2f(30, 20));
        m_tankBody.setOrigin(12, 10);
        m_tankBody.setPosition(400, 300);
        sf::RectangleShape m_tankGun;
        m_tankGun.setFillColor(sf::Color(30, 50, 30));
        m_tankGun.setSize(sf::Vector2f(25, 4));
        m_tankGun.setOrigin(2, 2);
        m_tankGun.setPosition(400, 300);
        float m_tankSpeed = 3;
        std::list<sf::Vector3f> m_bullets;
        sf::CircleShape m_bullet;
        m_bullet.setFillColor(sf::Color(130, 50, 30));
        m_bullet.setRadius(2);
        m_bullet.setOrigin(1, 1);
        float m_bulletSpeed = 15;
        sf::Clock m_fireTime;
        m_fireTime.restart();
        float m_fireRate = 0.5;
        sf::CircleShape m_target;
        m_target.setFillColor(sf::Color(200, 30, 30, 150));
        m_target.setRadius(15);
        m_target.setOrigin(15, 15);
        m_target.setPosition(600, 300);
        sf::Clock m_gameTime, m_frameTime;
        m_gameTime.restart();
        m_frameTime.restart();
        int m_UPS = 60, m_FPS = 30;
        static const float PI = 3.14159265359;
        sf::RenderWindow m_window(sf::VideoMode(800, 600), "SFML simple tank");
        while (m_window.isOpen()) {
                sf::Event event;
                while (m_window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed) {
                                m_window.close();
                        }
                }
                if (m_gameTime.getElapsedTime().asSeconds() > 1 / m_UPS) {
                        m_gameTime.restart();
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Right)) {
                                m_tankBody.setRotation(m_tankBody.getRotation() + 0.1);
                        }
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left)) {
                                m_tankBody.setRotation(m_tankBody.getRotation() - 0.1);
                        }
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up)) {
                                float _xPos = m_tankBody.getPosition().x + ((m_tankSpeed / m_UPS) * cos(m_tankBody.getRotation() / 180 * PI));
                                float _yPos = m_tankBody.getPosition().y + ((m_tankSpeed / m_UPS) * sin(m_tankBody.getRotation() / 180 * PI));
                                if (_xPos > m_window.getSize().x) _xPos = 0;
                                else if (_xPos < 0) _xPos = m_window.getSize().x;
                                if (_yPos > m_window.getSize().y) _yPos = 0;
                                else if (_yPos < 0) _yPos = m_window.getSize().y;
                                m_tankBody.setPosition(_xPos, _yPos);
                        }
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down)) {
                                float _xPos = m_tankBody.getPosition().x - ((m_tankSpeed / m_UPS) * cos(m_tankBody.getRotation() / 180 * PI));
                                float _yPos = m_tankBody.getPosition().y - ((m_tankSpeed / m_UPS) * sin(m_tankBody.getRotation() / 180 * PI));
                                if (_xPos > m_window.getSize().x) _xPos = 0;
                                else if (_xPos < 0) _xPos = m_window.getSize().x;
                                if (_yPos > m_window.getSize().y) _yPos = 0;
                                else if (_yPos < 0) _yPos = m_window.getSize().y;
                                m_tankBody.setPosition(_xPos, _yPos);
                        }
                        if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) && m_fireTime.getElapsedTime().asSeconds() > m_fireRate) {
                                m_fireTime.restart();
                                m_bullets.push_back(sf::Vector3f(m_tankBody.getPosition().x, m_tankBody.getPosition().y, m_tankGun.getRotation()));
                        }
                        std::list<sf::Vector3f>::iterator i = m_bullets.begin();
                        while (i != m_bullets.end())
                        {
                                bool isDead = false;

                                //we also need to know how far from the target the bullets are
                                int xDist = i->x - m_target.getPosition().x;
                                int yDist = i->y - m_target.getPosition().y;
                                float m_distance = sqrtf((xDist * xDist) + (yDist*yDist));
                                if (i->x > m_window.getSize().x || i->x < 0 || i->y > m_window.getSize().y || i->y < 0) isDead = true;
                                else if (m_distance < 15) {
                                        isDead = true;

                                        //But we also need to move the target if it is hit.
                                        float nY = rand() % (m_window.getSize().y - 100) + 50;
                                        float nX;
                                        //lets make sure it ends up on hte opposite side of the screen than the tank.
                                        if (m_tankBody.getPosition().x > (m_window.getSize().x / 2)) nX = rand() % (m_window.getSize().x / 3);
                                        else nX = rand() % (m_window.getSize().x / 3) + ((m_window.getSize().x / 3) * 2);
                                        m_target.setPosition(nX, nY);
                                }
                                if (isDead)     {
                                        m_bullets.erase(i++);
                                }
                                else
                                {
                                        i->x += ((m_bulletSpeed / m_UPS) * cos(i->z / 180 * PI));
                                        i->y += ((m_bulletSpeed / m_UPS) * sin(i->z / 180 * PI));
                                i++;
                                }
                        }
                        m_tankGun.setPosition(m_tankBody.getPosition());
                        m_tankGun.setRotation(atan2(sf::Mouse::getPosition(m_window).y - m_tankGun.getPosition().y, sf::Mouse::getPosition(m_window).x - m_tankGun.getPosition().x) * 180 / PI);
                }
                if (m_frameTime.getElapsedTime().asSeconds() > 1 / m_FPS) {
                        m_frameTime.restart();
                        //lets make a nice green field for us to drive the tank on.
                        m_window.clear(sf::Color(0, 110, 50));
                        for (sf::Vector3f it : m_bullets) {
                                m_bullet.setPosition(it.x, it.y);
                                m_window.draw(m_bullet);
                        }
                        m_window.draw(m_tankBody);
                        m_window.draw(m_tankGun);
                        m_window.draw(m_target);
                        m_window.display();
                }
        }
}
 

and of course, one with my comments. And somewhat better spacing....

Main.cpp
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <list>

void main(int argc, char** argv[]) {

        //Set up a figure to use as a tank
        sf::RectangleShape m_tankBody;
        m_tankBody.setFillColor(sf::Color(120, 150, 120));
        m_tankBody.setSize(sf::Vector2f(30, 20));
        m_tankBody.setOrigin(12, 10);
        m_tankBody.setPosition(400, 300);
       
        //Set up a box to use as the gun of the tank
        sf::RectangleShape m_tankGun;
        m_tankGun.setFillColor(sf::Color(30, 50, 30));
        m_tankGun.setSize(sf::Vector2f(25, 4));
        m_tankGun.setOrigin(2, 2);
        m_tankGun.setPosition(400, 300);

        //We need to know how fast the tank can drive
        float m_tankSpeed = 3;

        //make a list for bullets, it needs to be a 3 dimenisonel vector, tow dimensions will be used for x and y, and the last one will be used for rotation.
        //so the vectors x, and y will be x and y. its z will be rotation.
        std::list<sf::Vector3f> m_bullets;

        //Make a circle for bullets
        sf::CircleShape m_bullet;
        m_bullet.setFillColor(sf::Color(130, 50, 30));
        m_bullet.setRadius(2);
        m_bullet.setOrigin(1, 1);

        //We need to know how fast do bullets fly?
        float m_bulletSpeed = 15;

        //and a timer for fiering:
        sf::Clock m_fireTime;
        m_fireTime.restart();
        float m_fireRate = 0.5;

        //Make a circle for a target
        sf::CircleShape m_target;
        m_target.setFillColor(sf::Color(200, 30, 30, 150));
        m_target.setRadius(15);
        m_target.setOrigin(15, 15);
        m_target.setPosition(600, 300);

        //We also need a way to keep updates and frame rate stable (We could use delta time, but for now we go with the most simple solution)
        sf::Clock m_gameTime, m_frameTime;
        m_gameTime.restart();
        m_frameTime.restart();
        int m_UPS = 60,  m_FPS = 30;

        //PI is a great number, and we need it to calculate rotation and movement.
        static const float PI = 3.14159265359;

        //Set up a window to render our game in.
        sf::RenderWindow m_window(sf::VideoMode(800, 600), "SFML simple tank");

        //Update the game as long as the window is open
        while (m_window.isOpen()) {
                //This allows us to close the game window
                sf::Event event;
                while (m_window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed) {
                                m_window.close();
                        }
                }

                //if enough time has passed, update the game, remember to restart the clock.
                if (m_gameTime.getElapsedTime().asSeconds() > 1 / m_UPS) {
                        m_gameTime.restart();

                        //Rotate the tank when left or right key is pressed
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Right)) {
                                m_tankBody.setRotation(m_tankBody.getRotation() + 0.1);
                        }
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left)) {
                                m_tankBody.setRotation(m_tankBody.getRotation() - 0.1);
                        }

                        //move the tank forward based on rotation if UP is pressed
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up)) {
                                float _xPos = m_tankBody.getPosition().x + ((m_tankSpeed / m_UPS) * cos(m_tankBody.getRotation() / 180 * PI));
                                float _yPos = m_tankBody.getPosition().y + ((m_tankSpeed / m_UPS) * sin(m_tankBody.getRotation() / 180 * PI));
                                if (_xPos > m_window.getSize().x) _xPos = 0;
                                else if (_xPos < 0) _xPos = m_window.getSize().x;
                                if (_yPos > m_window.getSize().y) _yPos = 0;
                                else if (_yPos < 0) _yPos = m_window.getSize().y;
                                m_tankBody.setPosition(_xPos, _yPos);
                        }

                        //move the tank back based on rotation if DOWN is pressed
                        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down)) {
                                float _xPos = m_tankBody.getPosition().x - ((m_tankSpeed / m_UPS) * cos(m_tankBody.getRotation() / 180 * PI));
                                float _yPos = m_tankBody.getPosition().y - ((m_tankSpeed / m_UPS) * sin(m_tankBody.getRotation() / 180 * PI));
                                if (_xPos > m_window.getSize().x) _xPos = 0;
                                else if (_xPos < 0) _xPos = m_window.getSize().x;
                                if (_yPos > m_window.getSize().y) _yPos = 0;
                                else if (_yPos < 0) _yPos = m_window.getSize().y;
                                m_tankBody.setPosition(_xPos, _yPos);
                        }

                        //if the mouse button LEFT is pressed, and time enough has passed since last bullet was fired. add a bullet to the bullet list.
                        if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) && m_fireTime.getElapsedTime().asSeconds() > m_fireRate) {
                                m_fireTime.restart();
                                m_bullets.push_back(sf::Vector3f(m_tankBody.getPosition().x, m_tankBody.getPosition().y, m_tankGun.getRotation()));
                        }
                       


                        //Move, hittest and erase each bullet as needed.
                        std::list<sf::Vector3f>::iterator i = m_bullets.begin();
                        while (i != m_bullets.end())
                        {
                                //we need a bolean to see if the bullets are dead.
                                bool isDead = false;

                                //we also need to know how far from the target the bullets are
                                int xDist = i->x - m_target.getPosition().x;
                                int yDist = i->y - m_target.getPosition().y;
                                float m_distance = sqrtf((xDist * xDist) + (yDist*yDist));

                                //if the bullets are to close at or over edge of the window, they are dead.
                                if (i->x > m_window.getSize().x || i->x < 0 || i->y > m_window.getSize().y || i->y < 0) isDead = true;

                                //or if the bullet is close enough to the target that they hit it.
                                else if (m_distance < 15) {
                                        isDead = true;

                                        //But we also need to move the target if it is hit.
                                        float nY = rand() % (m_window.getSize().y - 100) + 50;
                                        float nX;
                                        //lets make sure it ends up on hte opposite side of the screen than the tank.
                                        if (m_tankBody.getPosition().x > (m_window.getSize().x / 2)) nX = rand() % (m_window.getSize().x / 3);
                                        else nX = rand() % (m_window.getSize().x / 3) + ((m_window.getSize().x / 3) * 2);
                                        m_target.setPosition(nX, nY);
                                }

                                //So if hte bullet is dead, erase it.
                                if (isDead)     {
                                        m_bullets.erase(i++);
                                }

                                //or, if hte bullet is alive, move it based on its rotation and the bullet speed.
                                else
                                {
                                        i->x += ((m_bulletSpeed / m_UPS) * cos(i->z / 180 * PI));
                                        i->y += ((m_bulletSpeed / m_UPS) * sin(i->z / 180 * PI));
                                        i++;
                                }
                        }


                        //move the gun with the tank and Make the gun point towards the mouse!
                        m_tankGun.setPosition(m_tankBody.getPosition());
                        m_tankGun.setRotation(atan2(sf::Mouse::getPosition(m_window).y - m_tankGun.getPosition().y, sf::Mouse::getPosition(m_window).x - m_tankGun.getPosition().x) * 180 / PI);
                }


                //Draw the update if the target time has gone by since last frame, restart the frame clock.
                if (m_frameTime.getElapsedTime().asSeconds() > 1 / m_FPS) {
                        m_frameTime.restart();
                        //lets make a nice green field for us to drive the tank on.
                        m_window.clear(sf::Color(0, 110, 50));

                        //draw bullets:
                        for (sf::Vector3f it : m_bullets) {
                                m_bullet.setPosition(it.x, it.y);
                                m_window.draw(m_bullet);
                        }
                        m_window.draw(m_tankBody);
                        m_window.draw(m_tankGun);
                        m_window.draw(m_target);
                        m_window.display();
                }
        }
}

This code teaches a lot of the skills i feel is necessary to make a full game prototype.
or even a full game...

but it would be awesome if others could add small game codes like this... comment or ask questions. even if someone would make a tutorial on the individual things in this code...

oh yes, and an image of the game in attachment


27
SFML projects / Re: My first SFML game: X/O
« on: May 08, 2017, 06:40:46 pm »
What Roseme said.
But that aside, is this your first project?
Awesome...
That is really well made... I was looking time before I even dared graphics, much less sound...
Good work mate :)

28
General / Re: Smart Moving Problem
« on: May 08, 2017, 05:56:43 pm »
Okay, I just tested your code, and it works as it should.

But I think i know where you get confused.

360 or 0 degrees (Start position) is horizontal facing right like this arrow -->
or said in another way, if your ship image is facing north, you should rotate it 90 degrees so it faces east in the image file.

Secondly, as mentioned in my post, this is an asteroids like movement, the longer you hold UP, the faster the ship will go.

look at this code part:


        if (m_Key.isKeyPressed(Keyboard().Up)) {
                m_xVel += (cos(SSpaceship.getRotation() / 180 * 3.1415)) * m_accel;
                m_yVel += (sin(SSpaceship.getRotation() / 180 * 3.1415)) * m_accel;
        }
        SSpaceship.setPosition(SSpaceship.getPosition().x + m_xVel, SSpaceship.getPosition().y + m_yVel);



each time the UP key is pressed, m_xVel and m_yVel is changed.
what happens from the start is this,
-the ship is standing still (m_xVel = 0 and m_yVel = 0) and is rotated 360 degrees.
- UP is pressed, and because of this, the system adds a value to m_xVel and m_yVel (that is the cos and sin code up there) for simplicitys sake, lets say they change to m_xVel = 1, and m_yVel = 0;
-Then m_xVel and m_yVel is added to the ships current position. moving the ship på 1 on the X axis.
-Each update from now on, m_xVel and m_yVel will be the same, and will be added to the ships position, moving it at 1 per update.
-IF UP is pressed again, m_xVel and m_yVel will again get a new value, this value will be added to the old value.
so if whe have not rotated, the new values will be m_xVel = 2, and m_yVel = 0;
-The ship will now be updated and moved twice as fast in the X direction (2 instead of 1)
-IF we then rotate 90 degrees clock vice (the ship facing down) and press UP again. the m_xVel and m_yVel will be changed again, but this time, it would be yVel that gets 1 added to it.
so the nev values are now m_Xvel = 2, and m_yVel = 1.
-The ship is now updated, and moves +2 X and +1 Y (or East-South-East if you will)

Things you should try to make it more easy for yourself to see.
Try to change the value of m_accel to 0.01 or even 0.1.

After the if Key pressed but before SSpaceship.setPosition
Try and add:

      m_xVel = m_xVel * 0.99;
      m_yVel = m_yVel * 0.99;

This will "Stop" the space ship after some time.
See what happens if you write * 0.5 or * 0.999 instead...

Try to rotate your image in all directions in the editor.
What you should notes is that ite does not effect the code at all, just the "looks"

After SSpaceship.setPosition
try to add:
      if (SSpaceship.getPosition().x > 800) SSpaceship.setPosition(0, SSpaceship.getPosition().y);
      else if (SSpaceship.getPosition().x < 0) SSpaceship.setPosition(800, SSpaceship.getPosition().y);
      if (SSpaceship.getPosition().y > 600) SSpaceship.setPosition(SSpaceship.getPosition().x, 0);
      else if (SSpaceship.getPosition().y < 0) SSpaceship.setPosition(SSpaceship.getPosition().x, 600);

This will keep the space ship looping inside the window.

Edit, lastly, I notes that you have two values you never use, int x and int y.
and that you have made a definition of PI.
If you look at your code, there is a place where an approximation of PI is used, if you wish, you could just as well go ahead and and exchange that approximation for your own PI, that would both be more correct mathematical, but also more easy to write in the future.

29
General / Re: Smart Moving Problem
« on: May 08, 2017, 04:42:24 pm »
Ah, you are correct, Val should be Vel..
About keyboard, that's a preference from my side, I find it faster to type over multiple usages.

Please, can you copy pace your code Here.   I'll see if I can spot the error..just tried the code myself, and it works fine :)

30
SFML projects / Re: Little Scout [LD#38 Jam]
« on: May 07, 2017, 05:07:37 pm »
I grow on the spring so it will go down.
Then I press jump and then quickly shrink, getting thrown up and over the hole... I did not regrow in size...

Pages: 1 [2] 3 4 5