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

Pages: [1] 2
1
General / inheritance problem
« on: February 10, 2010, 06:55:31 pm »
I tried to implent your ideas into my code but i think im losing it completly. Im not lazy.. Im on this problem now for hours and days. But im really screwed. I asked 3 different programmers, one of them with a C++ background, to solve the problem but unfortunalty they could not help me.

Could you be so kind and write the code for me?  Me and other people could use that code as an example for any future classes that inheritate from a SFML-class.

2
General / inheritance problem
« on: February 09, 2010, 05:40:12 pm »
Thanks for your help to this point, but im still stuck with using the sf::Shape class in a selfmade class. I think i understood the fundemantals of using classes and inheritance but somehow im trying for two days now and still cant solve my problem. So help would be very much appreciated

Here is the code:

Asteroid.hpp
Code: [Select]

// Creation of an Asteroid

#ifndef _ASTEROID_HPP
#define _ASTEROID_HPP
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>


class Asteroid : public sf::Shape {

private:
    float X;
    float Y;
    float Radius;
    const sf::Color& Col;
    float Outline;
    const sf::Color& OutlineCol;

public:

    Asteroid(float X, float Y, float Radius, const Color& Col, float Outline = 0.f, const Color& OutlineCol = sf::Color(0, 0, 0))     <---- LINE 22
            : sf::Shape::Circle(X, Y, Radius, Col, Outline, OutlineCol)   {}    <---- LINE 23

    Asteroid(const Asteroid& orig);
    virtual ~Asteroid();


};

#endif // _ASTEROID_HPP


Asteroid.cpp
Code: [Select]

#include "Asteroid.hpp"
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics/Drawable.hpp>


Asteroid::Asteroid(float X, float Y, float Radius, const sf::Color& Col, float Outline, const sf::Color& OutlineCol)
{
   sf::Shape::Circle(X, Y, Radius, Col, Outline, OutlineCol);
}

Asteroid::Asteroid(const Asteroid& orig) {
   
}

Asteroid::~Asteroid() {
}


Here is what the compiler has to say:
In file included from main.cpp:9:
Asteroid.hpp:22: error: expected `,' or `...' before '&' token
Asteroid.hpp:23: error: ISO C++ forbids declaration of `Color' with no type
Asteroid.hpp: In constructor `Asteroid::Asteroid(float, float, float, int)':
Asteroid.hpp:23: error: expected class-name before '(' token
Asteroid.hpp:23: error: uninitialized reference member `Asteroid::Col'
Asteroid.hpp:23: error: uninitialized reference member `Asteroid::OutlineCol'
main.cpp: In function `int main(int, char**)':
main.cpp:131: error: no matching function for call to `Asteroid::Asteroid(float, float, float, sf::Color, float, sf::Color)'
Asteroid.hpp:25: note: candidates are: Asteroid::Asteroid(const Asteroid&)
Asteroid.hpp:23: note:                 Asteroid::Asteroid(float, float, float, int)
[/code]

3
General / inheritance problem
« on: February 05, 2010, 06:00:39 pm »
PLEASE LOOK AT MY NEXT POST. THIS POST IS NOT UP TO DATE.

Sorry Guys. This is more like a C++ beginners question but maybe you could help me out. Im trying to build a class with inheritance. I read a few online tutorials about it but i dont get the point.
I tried to draw a circle with the class sf::Shape but my compiler keeps screaming "undefined reference to `Asteroid::Asteroid()'"

So here is the code:
Code: [Select]

#ifndef _ASTEROID_H
#define _ASTEROID_H
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

class Asteroid : public sf::Shape {
private:

public:
    Asteroid();
   
    Asteroid(const Asteroid& orig);
    virtual ~Asteroid();


};

#endif /* _ASTEROID_H */

Code: [Select]
#include "Asteroid.h"
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>


double radiAsteroid = 50;

Asteroid::Asteroid() {
    sf::Shape::Circle(400, 400, radiAsteroid, sf::Color(255, 255, 255));

}

Asteroid::Asteroid(const Asteroid& orig) {
   
}

Asteroid::~Asteroid() {
}


main.cpp
Code: [Select]
Asteroid asteroidclass;
Game.Draw(asteroidclass);

4
General / Deleting Sprites
« on: February 03, 2010, 04:31:45 pm »
mhhh sure. I only need a bool trigger to draw it or not. Just too easy. Didnt thought about it  :lol:

5
General / Deleting Sprites
« on: February 03, 2010, 03:49:35 pm »
Now i created a sprite with sf::Sprite which is not saved in a vector. How can i delete it or remove it from the screen?

6
General / Cant find Librarys when compiling release executable
« on: February 02, 2010, 05:37:44 pm »
Hello guys.

I started my programm often in the debugging mode and there wasnt even one compiler error. But now i wanted to compile a release executable but the compiler keeps claiming that he cant find the sfml librarys.

main.cpp:3:29: warning: SFML/Graphics.hpp: No such file or directory
main.cpp:4:27: warning: SFML/System.hpp: No such file or directory
main.cpp:5:27: warning: SFML/Window.hpp: No such file or directory

Does anybody know about that?

7
Graphics / Drawing int or double with sf::String
« on: February 02, 2010, 05:32:44 pm »
My easy to use solution now is:
Code: [Select]
std::ostringstream StrP2;
StrP2 << scoreP2;
std::string scoreP2(StrP2.str());

8
Graphics / Drawing int or double with sf::String
« on: February 02, 2010, 03:42:10 pm »
Thanks. Didnt thought about just casting it.

9
Graphics / Drawing int or double with sf::String
« on: February 02, 2010, 03:34:55 pm »
Hello

I would like to draw changing numbers (type int or double) with sf::String.
Is there a way to do so?
I would like to display a changing highscore.

10
General / Parallel Keyinput
« on: February 02, 2010, 12:07:42 am »
Thanks Laurent. You have been right.
I changed the Keys i have to press on the keyboard and now everything works just fine. Weird problem.

11
General / Parallel Keyinput
« on: February 01, 2010, 06:52:48 pm »
Yes exactly. And it always depends on the order im pressing the keys. When i first press accelerate (and keep it pressed) then steer i cannot shot. When i first hold steer, then shoot i cannot accelerate.

here is some code:
Code: [Select]

        if (Game.GetInput().IsKeyDown(sf::Key::Right))
            direction -= rotateSpeed;
        if (Game.GetInput().IsKeyDown(sf::Key::Left))
            direction += rotateSpeed;

        if (Game.GetInput().IsKeyDown(sf::Key::M)) {
            inertiaX += -speedRocket * sin(direction * radian);
            inertiaY += -speedRocket * cos(direction * radian);
        }
        if (Game.GetInput().IsKeyDown(sf::Key::N) && shotTimer > 10)
            shot = true;

12
General / Parallel Keyinput
« on: February 01, 2010, 06:37:33 pm »
Hello Guys its me again.

I wonder if it is possible to have more then 2 parallel Keyboard-Inputs at once.
I tried Eventlistener triggering bool variables and i also tried the (Game.GetInput().IsKeyDown(sf::Key::M)) option. But somehow SFML is only reading two pressed keys at once.
For example when im accelerating and steering i cant shoot at the same time or when im shooting and accelerating im not able to steer anylonger.

13
General / Deleting Sprites
« on: February 01, 2010, 04:56:13 pm »
Thank you chipman and merci beacoup Laurent.
It works.

14
General / Deleting Sprites
« on: February 01, 2010, 04:46:41 pm »
The sprites are saved in a vector but it seems that i cant use vectormethods to delete elements. it seems that i can only use spritemethods.

main.cpp:169: error: 'class sf::Sprite' has no member named 'erase'

Code: [Select]
       int j = 0;
        for (j = 0; j < shotVector.size(); j++) {
            shotVector[j].Move(-speedShot * sin(directionVector[j] * radian), -speedShot * cos(directionVector[j] * radian));
            if(shotVector[j].GetPosition().x < -50 || shotVector[j].GetPosition().x > width
                    || shotVector[j].GetPosition().y < 100 || shotVector[j].GetPosition().y > height) {
                shotVector[j].erase(shotVector.begin()+j);    //  <----- LINE 169
            }
        }

15
General / Deleting Sprites
« on: February 01, 2010, 04:43:02 pm »
Hello!

Does anybody know how to delete sprites? Id like to delete shots after they left the screen.
I looked into the documentation but couldnt find a sprite-method to delete them.

The sprites are saved in a vector but it seems that i cant use vectormethods to delete elements. it seems that i can only use spritemethods.

Pages: [1] 2
anything