Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to "update"/change correctly a scene, when the player moves?  (Read 1320 times)

0 Members and 1 Guest are viewing this topic.

userunseen00

  • Newbie
  • *
  • Posts: 1
    • View Profile
How to "update"/change correctly a scene, when the player moves?
« on: September 29, 2019, 06:23:48 pm »
Good evening everyone. I am a newby in game programming, and I would like to receive some help.
So I have created a list of round shapes.  I will post just some rough lines of the code, to give you an idea.
class ShapeCircle
{
sf::CircleShape circle;
//sf::Vector2f position;
//and the other things
}

struct Node
{
ShapeOfCircle circle;
node*next;
}

class listCircles
{
private:
*node head;
public:
//the other methods
}
And until here everything is okay. Now what I would like to do is to create another list in which, each node, contains a list.

struct Node2
{
listCircles ListOfCircles;
Node2*next;
}
And same, we have this second list.

What I would like to do is to create new circles, if the player moves to the right, and if the player moves to the left should be able to see the "old screen".
Let's say I have a list of (4, 5, 3, 3);
The first time I open the screen there is the player who sees 4 circles, then the player moves to the right of the screen and (pacman effect, the player goes beyond and is back again) I should be able to see 5, then if the player moves again 3, but if the player goes backwards, I should be able to see 5.

Is there a way that I can do this? I tried to save the position of the circles in a file, and trying to read ( a complicated thing) but it didn't work, that's why I am sort of sticking with lists (I am not allowed to use any libraries)

Do you have any suggestions?

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: How to "update"/change correctly a scene, when the player moves?
« Reply #1 on: September 30, 2019, 11:16:05 am »
i think i got your idea, but i dont really understand your code  :P
you create too many classes (and structs; why do you use both, if its basically the same thing?), so its hard to keep track of whats going on in this soup of variables with similar names.

why don't you create a single class for the screens, each one containing a vector of circles? like this:
class Screen{
    std::vector<sf::CircleShape> circles;
};

then, in your code, you can just create an array of Screens, and each one will have its own number of circles:
Screen screens[4];

let me know if you have any trouble putting this in practice. or if you really need to use the code like you posted, you need to explain it a bit more.
« Last Edit: October 05, 2019, 08:46:35 pm by Stauricus »
Visit my game site (and hopefully help funding it? )
Website | IndieDB

 

anything