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

Pages: [1]
1
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);

2
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?

3
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.

4
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.

5
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.

6
General / Loading sprites into a vector
« on: February 01, 2010, 01:48:30 pm »
Hello everyone!

Right now im programming on a little spaceshooter. Every time the player shoots a sprite should be generated from the same image. But my compiler keeps telling me that: main.cpp:166: error: expected primary-expression before "Shot"

Here is part of the code:
Code: [Select]

    sf::Image IShot;
    if (!IShot.LoadFromFile("Shot.png")) {
        // Error...
    }
std::vector<sf::Sprite> ShotVector;

Gameloop:
        // SHOOTING
       
        shotTimer++;
        if (Game.GetInput().IsKeyDown(sf::Key::N) && shotTimer > 60) {
            shotTimer = 0;
            shot = true;
        }
        if (shot) {
            shot = false;
            sf::Sprite Shot;
            Shot.SetImage(IRocketP1);
            Shot.SetColor(sf::Color(255, 255, 255, 255));
            Shot.SetPosition(350.f, 600.f);
            Shot.SetCenter(Shot.GetSize().x / 2, Shot.GetSize().y / 2);
            ShotVector.push_back(Shot);        <--- LINE 166
        }
        int i = 0;
        for (i = 0; i < ShotVector.size(); i++) {
            Game.Draw(ShotVector[i]);
        }

7
General / Radial Controls
« on: January 24, 2010, 12:20:55 pm »
Hello Guys

Right now im coding on a rocket game. The player is supposed to rotate the rocket and press space to accelerate in the chosen direction. Right now the rocket seems to randomly go into random directions. Does anybody know how i can control the rocket?

Here ist the code, interesting lines start at line 42.

The other problem is that the rocket does not fly in smooth curves but when i accelerate and at the same time rotate it starts to stutter and wont move.

Code: [Select]

#include <stdlib.h>
#include <iostream.h>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>


int main(int argc, char** argv) {
    sf::RenderWindow Game(sf::VideoMode(800, 600, 0), "Gravitation");
    sf::WindowSettings::WindowSettings(24, 8, 4);
    sf::Blend::Alpha;


    sf::Image IRocketP1;
    if (!IRocketP1.LoadFromFile("wrocket.png")) {
        // Error...
    }
    sf::Sprite rocketP1;
    rocketP1.SetImage(IRocketP1);
    rocketP1.SetColor(sf::Color(255, 255, 255, 255));
    rocketP1.SetX(0.f);
    rocketP1.SetY(0.f);
    rocketP1.SetPosition(350.f, 500.f);
    rocketP1.SetRotation(0.f);
    rocketP1.SetCenter(rocketP1.GetSize().x / 2 + 20, rocketP1.GetSize().y / 2 + 20);

    double speedR = 100;
    double widthR = rocketP1.GetSize().x;
    double heightR = rocketP1.GetSize().y;
    double speedRocket = 3;
    double direction = 0;
    double speedRotate = 2;
    int resX = 1280;
    int resY = 800;

    while (Game.IsOpened()) {
        Game.UseVerticalSync(true);

        // CONTROL
        float ElapsedTime = Game.GetFrameTime();
        if (Game.GetInput().IsKeyDown(sf::Key::Left) && rocketP1.GetPosition().x > 0)
            direction += speedRotate;
        if (Game.GetInput().IsKeyDown(sf::Key::Right) && rocketP1.GetPosition().x + widthR < resX)
            direction -= speedRotate;
        rocketP1.SetRotation(direction);
        if (Game.GetInput().IsKeyDown(sf::Key::Space)) {
            rocketP1.Move(speedRocket * sin(direction), speedRocket * cos(direction));
        }
        cout << direction;
       


        sf::Event Close;
        while (Game.GetEvent(Close)) {

            if (Close.Type == sf::Event::Closed)
                Game.Close();
            if ((Close.Type == sf::Event::KeyPressed) && (Close.Key.Code == sf::Key::Escape))
                Game.Close();
        }

        Game.Draw(rocketP1);
        Game.Display();
        Game.Clear();

    }
    return (EXIT_SUCCESS);
}

[/quote][/code]

8
General / Using more than one Event in the main function
« on: December 05, 2009, 09:21:13 pm »
Hallo

I try to use 2 Events in the main function. The Event for closing down the window does not work when the control event is in front of it. When i disable the control event the closing event works...
Is there a way to have more than one event in the main function?

Code: [Select]

        sf::Event Control;
        while (App.GetEvent(Control)) {
            if ((Control.Type == sf::Event::KeyPressed) && (Control.Key.Code == sf::Key::Left))
                bool left = true;
            if ((Control.Type == sf::Event::KeyReleased) && (Control.Key.Code == sf::Key::Left))
                bool left = false;
            if ((Control.Type == sf::Event::KeyPressed) && (Control.Key.Code == sf::Key::Right))
                bool right = true;
            if ((Control.Type == sf::Event::KeyReleased) && (Control.Key.Code == sf::Key::Right))
                bool right = false;
            if ((Control.Type == sf::Event::KeyPressed) && (Control.Key.Code == sf::Key::Up))
                bool up = true;
            if ((Control.Type == sf::Event::KeyReleased) && (Control.Key.Code == sf::Key::Up))
                bool up = false;
            if ((Control.Type == sf::Event::KeyPressed) && (Control.Key.Code == sf::Key::Down))
                bool down = true;
            if ((Control.Type == sf::Event::KeyReleased) && (Control.Key.Code == sf::Key::Down))
                bool down = false;
        }

        sf::Event Event;
        while (App.GetEvent(Event)) {
            if (Event.Type == sf::Event::Closed)
                App.Close();
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
        }

9
General / SFML in Eclipse
« on: November 16, 2009, 05:33:30 pm »
Hello everybody.

There is a nice tutorial for including SFML into Code-Blocks.
But i would prefer to use Eclipse but dont know how to implent SFML. Does anybody know about a tutorial explaining Eclipse implentation or does he or she can explain it?

Pages: [1]
anything