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

Pages: [1]
1
General / Re: Can't figure out how to enable click and move
« on: September 18, 2013, 12:34:56 pm »
Something like that?


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

int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480, 32), "TEST");

    sf::RectangleShape shape(sf::Vector2f(30.0f, 30.0f));
    shape.setFillColor(sf::Color::Red);
    shape.setPosition(sf::Vector2f(100.0f, 200.0f));
    shape.setOrigin(15, 15);

    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::Closed:
                    window.close();
                    break;

                case sf::Event::KeyPressed:
                    if(event.key.code == sf::Keyboard::Escape)
                        window.close();
                    break;

                default:
                    break;

            }
        }

        if(sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
            sf::Vector2f pos = (sf::Vector2f)sf::Mouse::getPosition(window);
            if(shape.getGlobalBounds().contains(pos)) {
                shape.setPosition(pos);
            }
        }

        window.clear();

        window.draw(shape);

        window.display();
    }

    return 0;
}
 

2
Oh gad, im famous now  8)

Gonna tell my mom...

3
SFML projects / Re: memoria
« on: September 17, 2013, 11:50:45 pm »
I really like the concept of your game, but I did find a crash bug (that is generally impossible to reach). I wanted to find out what happens when you reach level 100+ (since 100 numbers is the maximum for a 10x10 grid). With any level past 100 the game will instant crash when trying to generate the numbers in the grid, so you might want to put a check in for that.

If anyone cares, I used CheatEngine to reach level 100+  8)

Wooo, its almost impossible for humans to finish 8-9 lvl. I didn't even think about 100 lvl xD Anyway, game was made only for for fun after watching that movie. Probably i won't do anything with that bug.

4
SFML projects / Re: A very nice Pong clone using SFML - 2.1
« on: September 09, 2013, 05:14:05 pm »
Im getting error when i try to run:

"The procedure entry point __gxx_personality_v0 could not be located in the libstdc++-6.dll"

I'm not using windows in EN language, but i hope translation is good.

5
SFML projects / Re: A very nice Pong clone using SFML - 2.1
« on: September 09, 2013, 12:19:56 pm »
Hi!

Game looks really good. Only font is a bit unreadable.

But i found some bugs :( :
-i can't start a new game with AI after finishing one. Looks like you don't reset level.
-when i choose play vs human, the humancontrols screen appear and it say "press any key to continue" but when i press any key, nothing happen. Only when i press enter im back to menu. This problem appear after i finish a game with AI so it could be connected with first problem
-not a bug but: ball is not center at the start.
-not a bug again but: ball always go in same direction after start
-collisions looks weird
-when point go to 10 number overlay on middle line


After all, game looks good, i like that GUI system. But you need to work more with it. Not much, but still a bit. Good work!

6
SFML projects / memoria
« on: September 08, 2013, 01:13:08 pm »
Hi!

I just made a simple game variation inspired by film that i watch (WOW that monekys  :o):


My version is a bit different: You have 5 seconds (or you can just click space) to remember position and order of numbers. After that, numbers hide and you have to point where numbers were in right order. It adds one number after finishing level.

Screen:


Download (only windows, sorry):
https://dl.dropboxusercontent.com/u/75014753/memoria.rar


Enjoy!

P.S.
I suck in game I made by myself...

7
General / Re: Access problem / Entity Manager
« on: September 01, 2013, 11:49:51 pm »
You should use pointers in list not objects:

std::list<Entity*> mEntityList;

8
Graphics / [SOLVED]Problem with transformation in own drawable
« on: July 25, 2013, 09:35:46 pm »
Hello,

i'm trying to write my own animation class. My class derive from sf::Drawable and sf::Transformable. Problem is, when i use "setPosition" for example "setPosition(32,48)" animation is rendered at 64,96. There's some code:

void ANIMATION_BASE::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
    if(m_state!="") {
        std::map<const sf::String, ANIMATION_SET>::const_iterator it;
        it=m_animationsSet.find(m_state);
        sf::Vector2f pos;
        pos=getPosition();

        sf::VertexArray vertex_array(sf::Quads, 4);
        vertex_array[0].position=pos;
        vertex_array[1].position=pos+sf::Vector2f(it->second.frameSize.x, 0);
        vertex_array[2].position=pos+sf::Vector2f(it->second.frameSize.x, it->second.frameSize.y);
        vertex_array[3].position=pos+sf::Vector2f(0, it->second.frameSize.y);

        sf::FloatRect frame;
        if(it->second.orientation) {
            frame.left=it->second.textureRect.left+(m_frame*(it->second.frameSize.x));
            frame.top=it->second.textureRect.top;
        } else {
            frame.left=it->second.textureRect.left;
            frame.top=it->second.textureRect.top+(m_frame*(it->second.frameSize.y));
        }
        frame.width=it->second.frameSize.x;
        frame.height=it->second.frameSize.y;


        vertex_array[0].texCoords=sf::Vector2f(frame.left, frame.top);
        vertex_array[1].texCoords=sf::Vector2f(frame.left+frame.width, frame.top);
        vertex_array[2].texCoords=sf::Vector2f(frame.left+frame.width, frame.top+frame.height);
        vertex_array[3].texCoords=sf::Vector2f(frame.left, frame.top+frame.height);

        states.transform*=getTransform();
        states.texture=m_texture;
        target.draw(vertex_array,states);
    }
}

Everything is ok when i delete this line:
states.transform*=getTransform();

But if i do this, i cant rotate, scale etc.

It's my first time with Vertex so maybe i do something wrong  :-[

EDIT:
Finally i found whats wrong. Problem is here:

pos=getPosition();

I was thinking that i need to set vertices in global coords. And now i just realize that i need to set everything locally and then magically everything is rendered in right place when i do "window.draw(animation); ". This Library is awesome!

EDIT2:
Topic can be closed ;)

EDIT3:
Title changed

Pages: [1]