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.


Topics - ka0s420

Pages: [1]
1
General / Choppy Movement With DeltaTime
« on: April 04, 2017, 01:31:48 am »
Hi everyone,

I'm struggling to get smooth movement in a game I'm working on. I was originally using a fixed timestep loop for handling the game logic, but I noticed that the movement was choppy, so I changed it (at least for now) to use delta time instead, but the choppy movement still persists.

Here is a minimal example of the code :

#include <SFML\Graphics.hpp>

int main()
{
       
        sf::RenderWindow win;
        win.create(sf::VideoMode(640, 512), "");
        win.setVerticalSyncEnabled(true);
        sf::Sprite p;
        sf::Texture t;
        t.loadFromFile("graphics/player.png");
        p.setTexture(t);
        p.setPosition(100, 100);
        sf::Clock clock;
        sf::Time dt;
        while (win.isOpen()) {
                dt = clock.restart();
                sf::Event event;
               
                while (win.pollEvent(event)) {

                        if (event.type == sf::Event::Closed) {
                                win.close();
                        }

                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {
                p.move(0, -32 * dt.asSeconds());
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
                p.move(-32 * dt.asSeconds(), 0);
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
                p.move(0, 32 * dt.asSeconds());
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
                p.move(32 * dt.asSeconds(), 0);
                }

                win.clear();
                win.draw(p);
                win.display();
        }
        return 0;
}
 

As I say this results in choppy movement. By that, I mean that roughly once or twice a second the player stutters and the movement is not completely smooth or continuous. I've looked at a lot of questions regarding this same problem already, but most were caused by problems not present in my code, and otherwise I couldn't find a solution.

Any help would be appreciated thanks.

2
Window / hiding or destroying events
« on: February 26, 2017, 10:37:04 pm »
Hello,

Just wondering if there is a way to destroy or hide an event. The reason being that I have my gui and actual game checking for click events and at the minute if i click a gui button, then the click also registers in the actual game layer.

I know that I could separate the gui and the game by making the game view smaller so it is a window within the bounds of the gui and only check for game related clicks if they are within the the game's viewport, but this seems like extra work when it could be possible (as far as i know) to say, check for the click in the gui and if it hits a button, do something then kill the event so it doesn't get passed to the game event loop.

So does anyone know if there is a way to remove an event from the event queue?

3
General / Problems capturing full screen mode for video
« on: January 12, 2017, 03:59:23 pm »
Hi, I'm just wondering if anyone else has had this problem? I wanted to make a video of my game to show the progress so far on youtube. I'm using Apowersoft free screen recorder. When i enter the game which is set to fullscreen, the software just records a black screen without any of the stuff that's going on in the game. Figured this is to do with sfml rather than the screen capture, as I don't think ptrscreen works either. Is there a fix for this?

4
Graphics / rotating sprite without using transform.rotate
« on: January 11, 2017, 10:27:32 pm »
Okay, so my game uses a grid, pathfinding etc, i.e agents are stuck down to definite integer coordinates and can't just roam freely. To cut down on having to make a ton of artwork (and because the game is orthogonal/top down)  I decided it would be easier to use pure top down sprites and simply rotate them, effectively making it so I only needed to make artwork for one walk cycle, idle, attack etc.

However sadly I can't get rotation to work because of changing the origin. Now I've seen much discussion stating that if you want to keep the origin in the top left I would need to use a transform object and apply rotation to that and use it as a renderstate, however I couldn't get that to work. The main reason being that the transform only has transform.rotate, whereas the formula i use to work out rotation outputs an angle which is only good for sprite.setRotation as it sets the absolute rotation as opposed to the relative one.

So what I decided to try and do was to try various means of changing the the sprite's origin, set the rotation and then set the origin back to the left top corner, however this still produces undesirable outcomes. Here's my latest attempt at that. I used the hardcoded number 16 for ease of use and my sprites are 32x32, so it's their centre point:

void Entity::handleRotation(Tile * target)
{
        setOrigin(16, 16);
        setPosition(getPosition().x + 16, getPosition().y + 16);
        float angle = atan2(target->getPosition().y - getPosition().y, target->getPosition().x - getPosition().x);
        angle = ((angle * 180) / 3.14159265) + 90;
        {
                angle = 360 - (-angle);
        }
        setRotation(angle);
        setOrigin(0, 0);
        setPosition(getPosition().x - 16, getPosition().y - 16);
}


Again, this hasn't done as expected and I've tried many variants to no effect  :-\ Any suggestions, explanations or examples would be extremely helpful. Thanks in advance ;)

*note setOrigin, setPosition, getPosition,  setRotation are usable because the entity class publicly inherits from sprite.

5
Audio / open AL unexpected message
« on: May 15, 2016, 08:34:31 pm »
Hello,

I've recently come back to my project after about a month long break. Since then, i've started to recieve an error message in the console  - AL lib:: (EE) MMDevApiMsgProc: Unexpected message: 49385

However, the application still runs, but then after about 3-4 mins or so, the app crashes with "no symbol file loaded for openal32.dll" error.

At this point, the app is only streaming music, the dll is in the folder with the game, and as stated runs fine for about 5mins. The crash happens both when running through visual studio, and when running the compiled app.

in vs, it also says: Exception thrown at 0x00EA448D (openal32.dll) in Wetware.exe: 0xC0000005: Access violation writing location 0x0000BAC2. which to me looks like a null pointer error, but again, this doesnt make sense, as the music and dlls etc don't move and everything stays in scope.

game crashes even when there is no music playback.

6
General / isometric grid problems
« on: April 12, 2016, 05:25:42 am »
hi, just as an aside to what i'm developing at the moment, I decided to try out using isometric perspective. Now to achieve this i made a minimal example:


sf::RenderWindow window;
        window.create(sf::VideoMode(800, 800), "test");
        window.setFramerateLimit(60);
        sf::View view;
        view.setCenter(100, 100);
        view.setSize(800, 800);
        resourceHolder res;
        std::vector<std::vector<std::unique_ptr<sf::Sprite>>> sprites;
        for (int i = 0; i < 10; i++)
        {
                std::vector<std::unique_ptr<sf::Sprite>> b;
                sprites.push_back(std::move(b));
                for (int j = 0; j < 10; j++)
                {
                        auto a = std::unique_ptr<sf::Sprite>(new sf::Sprite);
                        a->setTexture(res.getTexture("graphics/isoGrass.png"));
                        sf::Vector2f vec(i * 32, j * 32);
                        sf::Vector2f vec2(0, 0);
                        vec2.x = vec.x - vec.y;
                        vec2.y = (vec.y + vec.x) / 2;
                        a->setPosition(vec2);
                        sprites[i].push_back(std::move(a));
                }
        }
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                        {
                                window.close();
                        }
                }
                window.setView(view);
                window.clear(sf::Color::Black);
                for (int i = 0; i < sprites.size(); i++)
                {
                        for (int j = 0; j < sprites[i].size(); j++)
                        {
                                window.draw(*sprites[i][j]);
                        }
                }
                window.display();
        }

the code above gimes me https://www.dropbox.com/s/rmp168f094v5ug1/isoGrid.jpg?dl=0 which is a diamond shaped grid as one would hope and expect. However, you'll notice that the 'cubes' are spaced out and so the grid is full of holes. Here is the png of the 'cube' https://www.dropbox.com/s/z8v5y1vcdl48l1g/isoGrass.png?dl=0

The only thing I can think is that there is something wrong with the dimensions of my 'cubes', all the tutorials i've seen simply use the formular in the above code to convert the cartesian coordinates into isometric ones, and this is working, hence the diamond shaped grid.

Any help would be greatly appreciated - thanks for your time.

7
General / performance modulo versus nested for loop
« on: April 12, 2016, 12:19:47 am »
Hi there, this is more of a general c++ question, but figured someone on here might have the experience to advise me.

Right, so i have a 2d vector of int tile ids. The vector contains 4,225 ints. In my map editor, I originally used a nested for loop to check through them and change them if a mouse click collided with the space they represent. Here's an example:


bool foundTarg = false;
for (int i = 0; i < tileset.size(); i++)
{
        for (int j = 0; j < tileset[i].size(); j++)
        {
                if (sf::FloatRect(i * 32, j * 32, 32, 32).contains(mouse))
                {
                        tileset[i][j] = tileId;
                        foundTarg = true;
                        break;
                }

        }
        if (foundTarg)
                break;
}

However, I had the following idea, and that was that, at least when the click was deep into the array, that using modulo would save performance by cutting out the nested for loop. So here is an example of the function i used instead:

int x = static_cast<int>(pos.x);
int y = static_cast<int>(pos.y);
int remainderX = x % 32;
int remainderY = y % 32;
sf::Vector2f newPos((x - remainderX) / 32, (y - remainderY) / 32);
return newPos;
 

any thoughts on which would be more performant? Like I said, it seems obvious to me that the modulo method would be faster if the vector element was further in. But I'm sure its making my fps drop more than iterating through the vectors, which doesn't make sense to me.

Thanks for your time and patience  ;)

8
General / alpha being drawn to render texture as black
« on: April 10, 2016, 08:53:50 am »
Hello, I'm having issues at the moment, because I am trying to get layers working in my map editor. So basically I have a layer for the next height level and one for the ground, these are basically just vectors of tile numbers. These then get drawn to their own render texture allowing me to split the rendering so that i can render characters and other objects in between. i.e so a character is in a doorway rather than on top of it, etc.

however for some reason the alpha from my top layer is being rendered as black and is hiding the ground layer. I don't have these issues when using one render texture, but i would like them split up for the above reasons as well as for versatility. Here is a minimal example that produces the annomally:

sf::RenderWindow window;
        window.create(sf::VideoMode(400, 400), "test");
        window.setFramerateLimit(60);
        //initialise and load texture of tilesheet
        sf::Texture tileset;
        tileset.loadFromFile("graphics/tileSheet.png");

        //create sprite that uses the tilesheet as its texture
        sf::Sprite tileSprite(tileset);

        //create 2 render textures to act as layers, one for the ground, one for a higher level
        sf::RenderTexture tempTexture1;
        sf::RenderTexture tempTexture2;
        tempTexture1.create(400, 400);
        tempTexture2.create(400, 400);

        //create 2 sprites refering to the render textures
        sf::Sprite tempSprite1(tempTexture1.getTexture());
        sf::Sprite tempSprite2(tempTexture2.getTexture());
        //set texture rects so that one is positioned where tiles are in the tilesheet
        //the second is positioned where empty alpha tiles are for test purposes
        tempSprite1.setTextureRect(sf::IntRect(0, 0, 400, 400));
        tempSprite2.setTextureRect(sf::IntRect(0, 200, 400, 400));
        //set sprites location so the drawn layers will overlap
        tempSprite1.setPosition(0, 0);
        tempSprite2.setPosition(0, 0);
        //draw the sections of the tilesheet to the two different render textures
        tempTexture1.clear();
        tempTexture1.draw(tileSprite);
        tempTexture1.display();
        tempTexture2.clear();
        tempTexture2.draw(tileSprite);
        tempTexture2.display();
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if(event.type == sf::Event::Closed)
                                window.close();
                }
                //draw the bottom layer and then the top
                window.clear();
                window.draw(tempSprite1);
                window.draw(tempSprite2);
                window.display();
        }
 

just to clarify, the tilesheet is only half full of tiles, so the second render texture has blank transparent tiles rendered to it.

Any help would be appreciated, pulling hair out etc etc :/

9
General / shaders texture sample lookup
« on: March 18, 2016, 04:42:29 pm »
Hi, I've been trying for some time to get a dynamic amount of lights into my light shader instead of using a fixed array.  I tried setting the arrays to a max length and then sending a uniform int at runtime to say where the last used indices was but it just wont work due to it not being a constant.

So after much looking around and a comment on here that i saw by Nexus, I found out about using texture sampling instead of an array. So i've been trying that without much luck.

example of how i make the texture and the shader logic:

mdataTexture.create(10, 1);

for (int i = 0; i < 10; i++)
        {
                sf::RectangleShape r;
                r.setSize(sf::Vector2f(1, 1));
                r.setPosition(i, 0);
                sf::Vector2f vec2 = static_cast<sf::Vector2f>(mWindow.mapCoordsToPixel(vec[i], mCam));
                vec2.y = mWindow.getSize().y - vec2.y + 8;
                vec2.x += 8;
                r.setFillColor(sf::Color(vec2.x, vec2.y, 0, 255));
                mdataTexture.draw(r);
 

shader:
for(int i = 0; i <  10; i++)
        {
                vec4 pixel = texture2D(uData, vec2(float(i)/10.0, 0.0));
                distances[i] = distance(vec2(pixel.x , pixel.y), vec2(gl_FragCoord.x,  gl_FragCoord.y));
               
        }
 

when this is run, the data returned (pixel.x, pixel.y) always equal zero. and I just can't understand why  :(

When instead of trying to use the color data as coordinates for my lights, I instead use the color data to set the fragColor, it works.  So the texture is definitely, there, loaded and functioning to the extent that i can take colours from it, but when i try and take the color as floats to use as coordinates it just gives me zero.

Such a weird problem, any help would be appreciated.

thanks for your time.

EDIT:

I have changed the fragment shader to use texelFetch instead of texture2d. This is easier for me because it doesn't use normalised values, so i can be sure im accessing the right pixel when using a for loop index.

this changes screen color as i'd expect:
vec4 pixel = texelFetch(uData, ivec2(5, 0), 0);
gl_FragColor = pixel;
 
so does this:

gl_FragColor.r = pixel.r;
gl_FragColor.g = pixel.g;
gl_FragColor.b = pixel.b;
gl_FragColor.a = pixel.a;
 
however, this doesn't work and seems to always be zero (even though it works as a color)
vec4 pixel = texelFetch(uData, ivec2(5, 0), 0);
float dist = distance(vec2(pixel.x, pixel.y), gl_FragCoord.xy);
modColor.r +=  vColor.r * uColor.r / dist;
modColor.g += vColor.g * uColor.g / dist;
modColor.b += vColor.b * uColor.b / dist;
modColor.a += vColor.a * uColor.a / dist;
       
gl_FragColor = texture2D(uTexture, vTexCoord) * modColor ;
 

10
General / gl_FragCoords.y
« on: March 15, 2016, 06:45:04 pm »
hello, I'm writing a simple fragment shader that multiplies the rgba of a fragment based on it's distance from my mouse position.

varying vec4 vColor;
varying vec2 vTexCoord;

uniform sampler2D uTexture;
uniform vec2 uLightPosition;


void main(){
       
        float  pixelDistFromLight = distance(uLightPosition, vec2(gl_FragCoord.x,  gl_FragCoord.y));
        vec4 modColor = vec4(vColor.r + -pixelDistFromLight/100.0, vColor.g + -pixelDistFromLight/100.0,
        vColor.b + -pixelDistFromLight/100.0, vColor.a );
        gl_FragColor = texture2D(uTexture, vTexCoord) * modColor ;
}
 

the 'light' follows the mouse from left to right, but it's movement is inverted on the y axis. I understand that this is because glsl uses the bottom left as it's origin, and have tried to invert it in various ways including  1.0 - gl_FragCoord.y, and although that makes the light move in the righ direction, the light is still not situated at the mouse positions. i.e it moves up when i move the mouse up, but is positioned at the bottom of the screen.

any idea what operation i could perform on gl_FragCoord.y to get it to match the y coordinate of my mouse?

thanks for your time.

11
General / issues with random point inside a floatRect
« on: March 08, 2016, 08:00:47 am »
Hello everyone, I'm currently working on a finite state machine for my enemy ai. One of the states i want to implement is a patrolling state. I want this to be the default state when the enemy spawns, so they patrol the given spawn area which is passed as a floatRect.

Now to do this, I figured i would make a randomly positioned floatrect, which is fine, but to get a random point inside the floatrect at which to spawn the enemy sprite i used the following method:

spawn = the name of the floatrect in question...


sf::Vector2f(float(rand() % (int(spawn.left) + int(spawn.width)) + int(spawn.left)),
                float(rand() % (int(spawn.top) + int(spawn.height)) + int(spawn.top)));

 
Now i've tried various versions of casting to int and not casting to int, without any noticeable change. they need to be ints for rand() to work, and each number needs to also be cast back into a float to work with vector2f. i add the left to the width to get the global position of the far side of the rect, and then add the left side to the formula to make it so that rand() starts its range at the beginning of the rect and not at 0.

Either way, none of this is working and the sprites appear seemingly wherever they like.

can include more code if needs be, but for testing purposes all im doing is drawing them to the screen in the initial position contained in the above vector2f.

Thanks for your time.

12
General / SFML book, chapter 2 issue
« on: February 20, 2016, 08:33:17 am »
Hello, I am currently working through the SFML Game Development book. I am on chapter 2 at the part where we first declare the namespace called Textures. I have declared the namespace, created the enum in my main.cpp, and when I start to make a header file for the TextureHolder class, the book says to add this map declaration:

private:
 std::map<Textures::ID,
 std::unique_ptr<sf::Texture>> mTextureMap;

The code doesn't work for me, I get error '::' must be followed by a namespace or class name. I do not know how to access the namespace from the main.cpp in this header. The book doesn't show how, and neither does the github code, partially, I think because the github code is what it could/should look like at the end of the chapter. I have seen that it is possible to declare a namespace in a header file and include that into TextureHolder.h, but in the book it is declared in main.

Any advice on how to achieve this step in the book would be appreciated.

13
General / game crashing on draw. Possibly because of pointers.
« on: February 13, 2016, 05:01:44 am »
Hello all, this is probably a fairly length bit of code for a forum post, so I do aplogise, but if anyone could help me figure out why this is crashing, I'd be very appreciative  ;)

okay, player headder file and cpp:
#pragma once
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <vector>
#include "laserBeam.h"

class Player
{
public:
        int x;
        int y;
        sf::CircleShape shape;
        sf::Texture frame1;
        sf::Texture frame2;
        sf::Texture frame3;
        sf::Sprite sprite;
        sf::SoundBuffer buffer;
        sf::Sound sound;
        std::vector <Laser*> shots;
        int count;
        void move();
        void getAngle(sf::Vector2f mouse);
        Player(int xI, int yI, sf::CircleShape iconI);
        Player() {};
        ~Player();
       
};

#include <SFML/Graphics.hpp>
#include "Player.h"

void Player::move()
{
        float x = this->sprite.getPosition().x;
        float y = this->sprite.getPosition().y;
        float xR = sin((this->sprite.getRotation()*3.14159265 / 180)) * 3;
        float yR = cos((this->sprite.getRotation()*3.14159265 / 180))* -3;
        this->sprite.setPosition(x + xR, y + yR);
        switch(this->count){
                case 0:
                        this->sprite.setTexture(this->frame1);
                        this->sound.play();
                        break;
                case 6:
                        this->sprite.setTexture(this->frame2);
                        this->sound.play();
                        break;
                case 12:
                        this->sprite.setTexture(this->frame3);
                        this->sound.play();
                        break;
        }
        this->count++;
        if (this->count == 19) {
                this->count = 0;
        }
}

void Player::getAngle(sf::Vector2f mouse)
{
       
        float angle = atan2(mouse.y - this->sprite.getPosition().y, mouse.x - this->sprite.getPosition().x);
        angle = ((angle * 180) / 3.14159265) + 90;
        {
                angle = 360 - (-angle);
        }
       
        this->sprite.setRotation(angle);
       


}

Player::Player(int xI, int yI, sf::CircleShape iconI)
{
        this->shape = iconI;
        this->x = xI;
        this->y = yI;
        this->count = 0;
        this->frame1.loadFromFile("playerU.png");
        this->frame2.loadFromFile("playerU1.png");
        this->frame3.loadFromFile("playerU2.png");
        this->buffer.loadFromFile("conStep.wav");
        this->sprite.setTexture(this->frame1);
        this->sound.setBuffer(buffer);
        this->sprite.setOrigin(this->sprite.getGlobalBounds().width / 2, this->sprite.getGlobalBounds().height / 2);




}
Player::~Player()
{
}

okay so that's the player class etc, here is the laser class header and cpp:
#pragma once
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

class Laser
{
public:
        sf::Texture texture;
        sf::Sprite sprite;
        int speed;
        sf::Vector2i startPoint;
        sf::SoundBuffer buffer;
        sf::Sound sound;
        void move(std::vector <Laser*> shots);
        bool operator == (const Laser& rh)const;
        Laser(float rot, int spd, sf::Vector2i pos);
        Laser() {};
        ~Laser();
};

#include "laserBeam.h"
#include <iostream>
#include <algorithm>

void Laser::move(std::vector <Laser*> shots)
{
        float x = this->sprite.getPosition().x;
        float y = this->sprite.getPosition().y;
        float xR = sin((this->sprite.getRotation()*3.14159265 / 180)) * this->speed;
        float yR = cos((this->sprite.getRotation()*3.14159265 / 180))* -this->speed;
        this->sprite.setPosition(x + xR, y + yR);
       
        float dX = this->sprite.getPosition().x - this->startPoint.x;
        float dY = this->sprite.getPosition().y - this->startPoint.y;
        float dist = hypotf(dX, dY);
        if (dist > 32) {
                int index = -1;
                for (int i = 0; i < shots.size(); i++) {
                        std::cout << this << " " << &shots[i] << std::endl;
                        if (*this == *shots[i]) {
                                std::cout << "found match" << std::endl;
                                index = i;
                                break;
                        }
                }
                if (index >= 0) {
                        shots.erase(shots.begin() + index);
                }
               
               
        }
       
}

bool Laser::operator==(const Laser&  rh) const
{
        return (this == &rh);
}

Laser::Laser(float rot, int spd, sf::Vector2i pos)
{
        this->texture.loadFromFile("laser.png");
        this->sprite.setTexture(this->texture);
        this->sprite.setOrigin(this->sprite.getGlobalBounds().width/2, this->sprite.getGlobalBounds().height/2);
        this->sprite.setRotation(rot);
        this->sprite.setPosition(pos.x, pos.y);
        this->startPoint = pos;
        this->speed = spd;
        this->buffer.loadFromFile("target.wav");
        this->sound.setBuffer(buffer);
        this->sound.play();
       

}

Laser::~Laser()
{

}
 
and now the main cpp:
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include "Player.h"
#include "builder.h"
#include "laserBeam.h"
#include <iostream>
#include <string>
#include <vector>

int main()
{
        sf::RenderWindow window(sf::VideoMode(1024, 768), "SFML works!");
        sf::CircleShape shape;
        Player p(100, 100, shape);
        Builder w(32, 640, 640);
        p.shape.setFillColor(sf::Color(75, 0, 130));
        p.shape.setRadius(20.f);
        p.shape.setPosition(sf::Vector2f(p.x, p.y));
        sf::Font font;
        font.loadFromFile("arial.ttf");
        sf::Text words;
        words.setFont(font);
        words.setString(sf::String("some words n shit"));
        words.setPosition(sf::Vector2f(100, 100));
        words.setColor(sf::Color(255,255,255));
        window.setFramerateLimit(60);
        sf::View view1(sf::FloatRect(p.x, p.y, 600, 600));
       
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed) {
                                window.close();
                        }
                        else if (event.type == sf::Event::MouseButtonReleased) {
                                if (event.mouseButton.button == sf::Mouse::Left) {
                                        std::cout << "mouse click" << std::endl;
                                        float rot = p.sprite.getRotation();
                                        int spd = 6;
                                        sf::Vector2i pos;
                                        pos = sf::Vector2i(p.sprite.getPosition());
                                        Laser l(rot, spd, pos);
                                        Laser * ptr;
                                        ptr = &l;
                                        p.shots.push_back(ptr);
                                }
                        }
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {
                        p.move();
                }
                if (!sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {
                        p.sprite.setTexture(p.frame1);
                        p.count = 0;
                }

                view1.setCenter(p.sprite.getPosition().x, p.sprite.getPosition().y);
                window.setView(view1);
                sf::Vector2i mouse = sf::Mouse::getPosition(window);
                sf::Vector2f worldPos = window.mapPixelToCoords(mouse);
                p.getAngle(worldPos);
                for (int i = 0; i < p.shots.size(); i++) {
                        (*p.shots[i]).move(p.shots);
                }
                window.clear();
                window.draw(w.floorSprite);
                for (int i = 0; i < p.shots.size(); i++) {
                        (*p.shots[i]).sprite.setTexture((*p.shots[i]).texture);
                        window.draw((*p.shots[i]).sprite);
                }
                window.draw(p.sprite);
                window.draw(words);
                window.display();
        }

        return 0;
}

So yeah, I just included what I thought was relevant. There is another class, but that's for building the map and has worked fine from the start. The problem is when i try and draw a laser from the 'p.shots' vector. It is a dereferenced pointer, and everything else works when i comment out the draw call. again, any help would be appreciated. Thanks for your time!

Pages: [1]