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

Pages: [1]
1
General / Re: Vector of shapes
« on: February 26, 2018, 04:45:05 am »
Thank you so much  :D :D ... and truly speaking  this is what I like about SFML community !   ;D

2
General / Vector of shapes
« on: February 25, 2018, 03:04:52 pm »
I had been doing this in arrays and was working completely fine but when I tried to do the same thing with vector I am getting errors.

error: 'class std::vector<sf::CircleShape>' has no member named 'setRadius' and 'setFillColor'

In food.h :
class Food{
private:
     std::vector<sf::CircleShape> food[81];
public:
    Food(int rad);
};
 

In food.cpp:
#include "food.h"

Food::Food(int rad){
    for(int i=0;i<81;i++){
        food[i].setRadius(rad);
        food[i].setFillColor(sf::Color(10,200,10));
        }
}
 


3
Graphics / Invisible sprite when "move keys" continuously pressed
« on: February 23, 2018, 02:24:59 pm »
Hey Guys .. don't know what exactly happens but sprite(head) becomes invisible when I move it left and right by continuously pressing the left right keys but  it is visible while moving up and down.
 
code ::

if( sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
        if(head.getPosition().x > head.getSize().x/2){
            position.x -= speed * deltaTime;
            head.setRotation(0.f);
        }
    }

    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
        if(head.getPosition().x < window.getSize().x-head.getSize().x/2){
            position.x += speed *deltaTime;
            head.setRotation(0.f);
        }
    }

    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
        if(head.getPosition().y < window.getSize().y-head.getSize().y/2){
            position.y += speed *deltaTime;
            head.setRotation(90.f);
            if(!faceRight)
                head.setRotation(270.f);
        }
    }
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)){
        if( head.getPosition().y > head.getSize().y/2){
            position.y -= speed *deltaTime;
            head.setRotation(270.f);
            if(!faceRight)
                head.setRotation(90.f);
        }
    }

Pages: [1]