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 - M4c!3K

Pages: [1]
1
Graphics / Mouse input with sf::View
« on: January 02, 2015, 05:34:42 pm »
Hello,
I was designing my game menu. I wanted to add slide effect between menu "states", so i used sf::View, and moved it with move() function to show the actual menu state. So for example when you click "options" in menu the view moves until it reaches coordinates where options are drawn. It was a good idea, but then i had to use mouse input. And now mouse is like x: 400 y: 500 and button is like x: 1400 and y: 1500 and because of sf::View it looks like the mouse is over button. Is it possible to make menu like that without moving every single item? Or maybe i can just fix the sf::View thing. Here's the code:

if (this->submenustate == 0 && this->ScreenView.getCenter().x != SCREEN_WIDTH / 2)
{
        if (((SCREEN_WIDTH / 2) - this->ScreenView.getCenter().x) < 15)
                this->ScreenView.move(-((SCREEN_WIDTH / 2) - this->ScreenView.getCenter().x), 0);
        else
                this->ScreenView.move(-15, 0);
}

if (this->submenustate == 1 && this->ScreenView.getCenter().x != (SCREEN_WIDTH / 2) + SCREEN_WIDTH)
{
        if (this->ScreenView.getCenter().x > (SCREEN_WIDTH / 2 + SCREEN_WIDTH))
        {
                if (((SCREEN_WIDTH / 2 + SCREEN_WIDTH) - this->ScreenView.getCenter().x) < 15)
                        this->ScreenView.move(-(((SCREEN_WIDTH / 2) + SCREEN_WIDTH) - this->ScreenView.getCenter().x), 0);
                else
                        this->ScreenView.move(-15, 0);
        }
        else if (this->ScreenView.getCenter().x < (SCREEN_WIDTH / 2 + SCREEN_WIDTH))
        {
                if (this->ScreenView.getCenter().x + 15 >(SCREEN_WIDTH / 2 + SCREEN_WIDTH))
                        this->ScreenView.move((SCREEN_WIDTH / 2 + SCREEN_WIDTH) - this->ScreenView.getCenter().x, 0);
                else
                        this->ScreenView.move(15, 0);
        }
}
If you need more code to help me just write what part do you need. Whole code is like 1300 lines.

2
General / How do i load only enemies from file?
« on: December 09, 2014, 08:39:25 pm »
I have been writing a kind of Space Shooter game in SFML2 (really ambitiously), then i started to create level loading from files. And i have no idea how to do it. I know how to read from files, and i saw tutorials on creating tilemaps in SFML however i don't want to load whole tilemap, just general information (name) and enemies (plus it's positions). Is it possible to load them from textfile with content like...
{0,0,level};[0, 255, 255], [0,255,255]
Where things in {} are informations and things in [type, posision-x, position-y] are enemies.
I'll be really thankful for answers.

Pages: [1]
anything