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 - paul.mihaita

Pages: [1]
1
SFML projects / sfml space invaders type of game
« on: November 10, 2014, 04:09:48 pm »
What do you think?:D it's a game in progress.
You move by arrows, shoot by space.Sometimes bonuses apear on the screen, if you run into them you shoot faster.
Start by pressing 's'

https://www.dropbox.com/s/ei22332b9gyp2kr/pacpacjoc.rar?dl=0

some screenshots:

http://i.imgur.com/YgrgXYY.png?1  game design
http://i.imgur.com/UAFmkLg.png?1 yeah , that is an bullet :D
http://i.imgur.com/bHflEuB.png?1  bonus with timer

in order to win, you have to score around 700 points, and you loose if you go below 0;for each monster that exit the screen you loose 30;

2
Graphics / i guess it's about textures (loading circle problem)
« on: November 07, 2014, 07:53:07 pm »
Hey guys. I am making an Space invaders type of game, and i want to make some power-ups.I want to make an animation for that, like an loading circle so that user can know how much time left he has to take the power-up.I know how to do that by sprites(5-6 sprites with 1/5-1/6 of circle and just display the images after a time) but i want to do it smoothly, and by that i mean to calculate the % of circle to fill based on the time i want.I guess it can be done with texture updating...but i don't know

3
Graphics / Sprite setScale problem
« on: March 19, 2013, 02:16:14 pm »
Quote
sf::Event event;
    sf::Texture texture_patrat;
    sf::Texture texture_background;
    texture_patrat.loadFromFile("Patrat.png");
    texture_background.loadFromFile("Background.png");
    sf::Sprite patrat;
    sf::Sprite background;
    patrat.setTexture(texture_patrat);
    background.setTexture(texture_background);
    sf::VideoMode screen=sf::VideoMode::getDesktopMode();
    sf::RenderWindow window(sf::VideoMode(800,600), "SFML window",sf::Style::Fullscreen);
    window.setFramerateLimit(30);
    sf::Vector2f dimensiuni;
    float newsizea,newsizeb;
    newsizea=screen.width/1680;
    newsizeb=screen.height/1050;
    sf::Vector2f x,y;
    x=patrat.getScale();
    y=background.getScale();
    background.setScale(x.x*newsizea,x.y*newsizeb);
    patrat.setScale(y.x*newsizea,y.y*newsizeb);
    dimensiuni=patrat.getPosition();
    while(window.isOpen())
    {
        while(window.pollEvent(event))
        {
            if(event.type == sf::Event::KeyPressed)
            {
                if(event.key.code==sf::Keyboard::Escape)
                {
                    window.close();
                }
                if(event.key.code==sf::Keyboard::Up&&dimensiuni.y-20>=0)
                {
                    dimensiuni.y-=20;
                    patrat.setPosition(dimensiuni.x,dimensiuni.y);
                }
                if(event.key.code==sf::Keyboard::Up&&dimensiuni.y-20<0)
                {
                    dimensiuni.y=0;
                    patrat.setPosition(dimensiuni.x,dimensiuni.y);
                }
                if(event.key.code==sf::Keyboard::Down&&dimensiuni.y+20<=screen.height-200)
                {
                    dimensiuni.y+=20;
                    patrat.setPosition(dimensiuni.x,dimensiuni.y);
                }
                if(event.key.code==sf::Keyboard::Down&&dimensiuni.y+20>screen.height-200)
                {
                    dimensiuni.y=screen.height-200;
                    patrat.setPosition(dimensiuni.x,dimensiuni.y);
                }
                if(event.key.code==sf::Keyboard::Right&&dimensiuni.x+20<=screen.width-200)
                {
                    dimensiuni.x+=20;
                    patrat.setPosition(dimensiuni.x,dimensiuni.y);
                }
                if(event.key.code==sf::Keyboard::Right&&dimensiuni.x+20>screen.width-200)
                {
                    dimensiuni.x=screen.width-200;
                    patrat.setPosition(dimensiuni.x,dimensiuni.y);
                }
                if(event.key.code==sf::Keyboard::Left&&dimensiuni.x-20>=0)
                {
                    dimensiuni.x-=20;
                    patrat.setPosition(dimensiuni.x,dimensiuni.y);
                }
                if(event.key.code==sf::Keyboard::Left&&dimensiuni.x-20<0)
                {
                    dimensiuni.x=0;
                    patrat.setPosition(dimensiuni.x,dimensiuni.y);
                }
            }
        }
        window.draw(background);
        window.draw(patrat);
        window.display();
    }
    return 0;
}

My problem is that if i use sprite.setScale(0.5,0.5) it works but if i use sprite.setScale(newsezia,newsizeb) it doesn't work.I don't know why the setScale doesn't work if i use variables but with numbers it works.

4
Graphics / Error, window.draw
« on: March 14, 2013, 05:15:09 pm »
Hey guys, i'm new at sfml. I want to draw 2 images but i get 2 errors:
25|error: 'desenbackground' was not declared in this scope|
26|error: 'desenpatrat' was not declared in this scope|

here is the code

#include <SFML/Graphics.hpp>
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    while (window.isOpen())
    {
         sf::Texture texture;
         if (!texture.loadFromFile("Background.png"))
            return EXIT_FAILURE;
         sf::Sprite desenbackground(texture);
         if (!texture.loadFromFile("Patrat.png"))
            return EXIT_FAILURE;
         sf::Sprite desenpatrat(texture);
    }
    while (window.isOpen())
     {
         sf::Event event;
         while (window.pollEvent(event))
         {
             if (event.type == sf::Event::Closed)
                 window.close();
         }

         window.clear();
         window.draw(desenbackground);
         window.draw(desenpatrat);
         window.display();
     }

     return EXIT_SUCCESS;
 }

Pages: [1]