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

Pages: [1] 2
1
Graphics / Inherit from sf::String
« on: May 25, 2010, 12:57:40 pm »
Quote from: "Nexus"
It is possible, but not meaningful in your situation. You should prefer containment/aggregation to inheritance where possible. How is your class related to sf::String?

By the way, you shouldn't implement the destructor unless the copy constructor and assignment operator are implemented, too, or hidden (Rule of the Big Three). If the destructor is empty, just don't declare it.


Hello,

Thank you very much for your input!

2
Graphics / Inherit from sf::String
« on: May 25, 2010, 11:58:37 am »
Hello,

Is it possible to inherit from sf::String? I am currently trying to write a Score class to make my life easier, but it doesn't quite work.

Here is how I inherit from sf::String, the constructor of sf::String gets called in my constructor, btw.

Code: [Select]
#ifndef SCORE_H_INCLUDED
#define SCORE_H_INCLUDED

#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

namespace readOnly {

class Score : public sf::String {
    public:
        Score(float PosX = 0, float PosY = 0);
        ~Score();

        void SetScore(int score);
        void Add(int addScore = 1);

        const int& GetScore() const;

        void Update();
    private:
        int m_score;

};

}

#endif // SCORE_H_INCLUDED

3
Window / Windows not opening correctly?
« on: February 06, 2010, 08:05:13 pm »
[/img]

It stays like that untill I press a Key, click or move the window...

4
Window / Windows not opening correctly?
« on: February 06, 2010, 07:40:56 pm »
Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/Network.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>

using namespace std;

int main() {
    sf::RenderWindow theWindow(sf::VideoMode(352, 352, 32), "HEllo World", sf::Style::Close);

    theWindow.Display();

    sf::Event Event;
    while (theWindow.IsOpened()) {
        while (theWindow.GetEvent(Event)) { // Get all the Events (User Input) and handle them
            if (Event.Type == sf::Event::Closed)
                theWindow.Close();
        }

        Sleep(1); // To reduce CPU-Usage
    }

    return 0;
}


I'm using CodeBlocks

5
Window / Windows not opening correctly?
« on: February 06, 2010, 06:56:07 pm »
I'm using SFML 1.5 and both:

- Windows 7 64 Bit
- Windows XP 32 Bit

6
Window / Windows not opening correctly?
« on: February 06, 2010, 05:28:00 pm »
Hello,

When I create an sf::RenderWindow, the window itself opens all fine, but at the taskbar it doesn't show correctly untill I move/resize it or do any Events on it.

Is there a way to solve this? Because it is very ugly :D

7
System / Using sf::Thread to display Animations?
« on: February 06, 2010, 02:10:19 pm »
Quote from: "Nexus"
Quote from: "Samyboy"
What if I do this with 50 other Animations? Won't it get too messy? :S
No. Just don't do it manually for each of those 50 sprites. Write code that automatically takes care of that functionality. If you store the 50 sprites in a container, you can just iterate over the whole range and apply a function to each element.

And by the way: How do you imagine a thread to become less messy? Don't underestimate the problems related to multithreading.


You're totally right, thanks :D

8
General / What now ?
« on: February 06, 2010, 02:08:05 pm »
Hello,

So the collision detection is working pretty fine, thanks for your help!

I bumped into another question tho:

How would you go on and save/move all the projectiles? I currently save them all into a vector and move them in the game loop every frame. Is that a good way of doing it? Are there better ways?

9
System / Using sf::Thread to display Animations?
« on: February 03, 2010, 08:26:18 pm »
Quote from: "Laurent"
I don't think so. Graphics should be updated in the main loop -- keep threads for stuff that can benefit from not being synchronized with it, like physics or background loading.


Okay.

So what do you suggest? When I want to show an Animation of, let's say 50 sprites with a delay of 0.05 beetween each sprite, should I use an sf::Clock and do the checks in the main loop?

What if I do this with 50 other Animations? Won't it get too messy? :S

10
General discussions / SFML 1.6 released soon
« on: February 03, 2010, 08:14:54 pm »
Quote from: "Laurent"
Nop, sorry.


What about some kind of "WaitEvent()" that blocks untill an Eventis added to the Loop?

11
System / Using sf::Thread to display Animations?
« on: February 03, 2010, 08:09:53 pm »
Hello,

Does using a Thread to display an animation -> showing one sprite, waiting for some time, showing the next one, etc. sound reasonable?

Should Threads be used for smaller stuffs? Or is using a Thread not good for performance?


Thanks

12
Graphics / Smooth Movement
« on: February 02, 2010, 04:42:32 pm »
Quote from: "Luinechor"
This works perfect for me:
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
sf::Shape Rectangle = sf::Shape::Rectangle(150, 150, 300, 300, sf::Color::Blue, 1.0f, sf::Color::White);

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // A key has been pressed
            if (Event.Type == sf::Event::KeyPressed)
            {
                // Escape key : exit
                if (Event.Key.Code == sf::Key::Escape)
                    App.Close();
            }
        }

        // Clear the screen
        App.Clear(sf::Color(0, 0, 0));

if (App.GetInput().IsKeyDown(sf::Key::Left))  {
Rectangle.Move(150 * App.GetFrameTime() * -1, 0);
} else if (App.GetInput().IsKeyDown(sf::Key::Right)) {
Rectangle.Move(150 * App.GetFrameTime(), 0);
}

App.Draw(Rectangle);

        // Display window contents on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


Don't know what you really mean with 'Smooth', but it is.


Thank you very much!

13
Graphics / Smooth Movement
« on: February 02, 2010, 03:55:34 pm »
Still not working correctly -.-

Could someone please write me a simple program with a smooth moving rectangle, that the user can move?


Would be really appreciated...

14
Graphics / Smooth Movement
« on: February 02, 2010, 08:47:43 am »
Thanks for you fast answers!

I've tried to implement velocity with an acceleration of 0.3, but it still doesn't work as I want it to:

- The player is still somewhat not smooth when velocity reaches 6
- The player is not smooth when changing his direction to move (like from right to left)

Code: [Select]
// MOVEMENT
if (theWindow.GetInput().IsKeyDown(sf::Key::Left)) {
    if (velocity > -6)
        velocity -= acceleration;
     player.Move(velocity, 0);
}

if (theWindow.GetInput().IsKeyDown(sf::Key::Right)) {
    if (velocity < 6)
        velocity += acceleration;
    player.Move(velocity, 0);
}


I really appreciate your help!

15
General / What now ?
« on: February 02, 2010, 08:06:10 am »
Quote from: "gsaurus"
I have done several space games before with lots of projectiles and checking every pair of objects worked perfectly.

But you can still spatialize the objects by areas if really needed, and check the collisions between objects that are in the same area.
For example imagine you have a matrix representing the screen. Each time an object is created or it's position changes, you test what cells of the matrix the object is overlapping, and inform these sells that this object is there.
Doing this you have separated all objects by areas.
Then, every frame, for each object, you check collisions only for the objects that intersects the same cells as the one you're testing. That reduces substantially the number of collision checks. Don't do a too thin matrix or you'll have tons of cells to check :wink:

I would say: go with an easier collision test first, If you notice that it's compromising the gameplay, improve collisions by implementing a more complex method  :wink:


Hello,

Thanks for your advice, will google for the circle formula.

So basically I'll treat every object as a circle? That's cool!

Pages: [1] 2