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

Pages: [1] 2
1
Graphics / Re: Collision not detected
« on: December 24, 2015, 01:45:20 pm »
sorry its looks like my code is correct.
i do the mess some where else.
i have to figure out on my own.
thanks

2
Graphics / Re: Collision not detected
« on: December 24, 2015, 12:53:54 pm »
is it still unclear?
please tell me whats wrong?
thanks

3
Graphics / Re: Collision not detected
« on: December 23, 2015, 05:57:11 pm »
ok more info:


this is blade and player two sprites and this is my collision detection codes:

// player death
                        FloatRect PlayerBound = sp.getGlobalBounds();
                        FloatRect BladeBound = blade_SP.getGlobalBounds();


                        if (PlayerBound.intersects(BladeBound)) {
                                u = 4;
                                death = 1;
                                cout << "detected";
                        }
                        if (death == 1) {
                                if (DieOn <= 30) {
                                        window.draw(play.dieA.DoAnimation(np));
                                        DieOn++;

                                }
                                if (DieOn == 30)
                                        state = 2;
                               
                        }
                        // player death
I try say :
when playerBound touch BladeBound initialize some variables and do the dying animation
window.draw(play.dieA.DoAnimation(np));
but i dont know why blade always pass the player and collision code will not work.  :-[
i hope i have make it clear.
thanks

4
Graphics / Collision not detected
« on: December 23, 2015, 12:00:30 pm »
Hi,
ok let me explain situation.
i have player sprite and blade.
my player position is 500,225.
blade position is 4500,250.

now i want to detect collision when blade touch the player , thats how i do it:
        FloatRect PlayerBound = sp.getGlobalBounds();
                        FloatRect BladeBound = blade_SP.getGlobalBounds();


                        if (PlayerBound.intersects(BladeBound)) {
                                u = 4;
                                death = 1;
                                cout << "detected";
                        }
i just follow the tutorial in sfml learning section why this will not work at all? what im doing wrong?
thanks

5
Graphics / calculating pixels in xy
« on: October 24, 2015, 10:17:27 pm »
Hi,
I don't know this is related to SFML or not but i want to know it.
how i must calculate to where i must put my sprite or shape? right now according to window resolution  i doing with a Approximate x-y in my mind and start program and see where is it and then i will make it accurate.
i want to know is there any formula for example that will calculate the center of window or any where of window? that i want need little help here i dont know where to start!
thanks.

6
Graphics / Re: Collision boundingbox
« on: October 15, 2015, 10:25:20 pm »
Add the size of your sprite to the coordinates of its top left corner to get the coordinates of its bottom right corner.

And I guess you should back() in a different direction.
im sorry but im very inexperienced can you tell with code? :(
thanks

7
Graphics / Re: Collision boundingbox
« on: October 15, 2015, 06:09:12 pm »
so...
is there any func that will do this or i must handle it my own?
in overall how can i do it?

8
Graphics / Collision boundingbox
« on: October 15, 2015, 05:55:06 pm »
Hi,
first let say i put a 1024*1024 pic of space and i want to put a little shuttle on it and keep this shuttle on screen (make collision around space) i notice sfml already have bounding box detection but now.........
i dont know why this will work only for left part and up of space object but down and right does not work i mean shuttle will stop on left and up but on right and down the collision will not work why? :-\
this is the code that i use :
FloatRect bound = space_s.getGlobalBounds();
Vector2f point = obj.ship_s.getPosition();
if (bound.contains(point)){
                        obj.playerMove();
                }
                else{
                        obj.playerBack();
                }
 
and player cpp:
Sprite player::playerBack(){

                        ship_s.move(1, 1);
                return ship_s;
       
}
thanks

9
General / Re: short example of sfml
« on: July 31, 2015, 06:11:57 pm »
You should use forward slashes for all paths and check the console for any errors like when it can't open a file.

thanks this has solve my problem and thank u for tip  ;D

10
General / Re: short example of sfml
« on: July 31, 2015, 06:03:12 pm »
no i write code one by one here its my code

#include <SFML\Graphics.hpp>
#include <SFML\Audio.hpp>

using namespace sf;

int main(){
        // First create main window
        RenderWindow window(VideoMode(800, 600), "SFML Window");
        //load texture
        Texture texture;
        if (!texture.loadFromFile("E:\img.jpg"));
        Sprite sprite(texture);
        return EXIT_FAILURE;
        //create graphical text
        Font font;
        if (!font.loadFromFile("E:\font.TTF"));
        return EXIT_FAILURE;
        Text text("HELLO SFML", font, 50);

        //load music
        Music music;
        if (!music.openFromFile("E:\nice_music.ogg"));
        return EXIT_FAILURE;

        //play music
        music.play();
        // Start the game loop
        while (window.isOpen())
        {
                // Process events
                Event event;
                while (window.pollEvent(event))
                {
                        // Close window: exit
                        if (event.type == Event::Closed)
                                window.close();
                }
                window.clear();
                window.draw(sprite);
                window.draw(text);
                window.display();
        }
        return EXIT_SUCCESS;

}

11
General / short example of sfml [ SOLVED ]
« on: July 31, 2015, 05:45:27 pm »
hi im trying to run this example
http://www.sfml-dev.org/documentation/2.3.1/
but when every time i want to run this the window will quickly close and i cannot see any thing!
what must i do ? :-\
thanks

12
Graphics / Re: rendering image
« on: March 03, 2015, 10:48:44 am »
hi again
after give uping for couple of days finaly i went back and reset every thing and now i dont see the errors ;)
now i got another problem i dont know is in my code or anything else!

here is my code i will be grateful to see this!

 
#include "stdafx.h"
#include <SFML\Graphics.hpp>
#include "AnimatedSprite.hpp"
#include <iostream>
using namespace sf;


int main()
{
        Vector2i vectors(800, 600);
        RenderWindow window(VideoMode(vectors.x,vectors.y),"anime");

        Texture runner;

        runner.loadFromFile("E:\\Resource\\runner.png");

        Animation run;
        run.setSpriteSheet(runner);



        Animation* current = &run;

        AnimatedSprite animatedSprite(seconds(0.2), true, false);

        animatedSprite.setPosition(sf::Vector2f(vectors / 2));

        Clock frameclock;

        float speed = 80.f;

        bool noKeyPressed=true;

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
                Time frametime= frameclock.restart();
                Vector2f movement(0.f, 0.f);

                if (Keyboard::isKeyPressed(Keyboard:: D)){  // i put little space because it will show something like this in this forum :D
                        current = &run;
                        movement.x += speed;
                        noKeyPressed = false;
                }
                animatedSprite.play(*current);
                animatedSprite.move(movement *frametime.asSeconds());
                if (noKeyPressed){
                        animatedSprite.stop();
                }
                noKeyPressed = true;

                animatedSprite.update(frametime);

                window.clear();
                window.draw(animatedSprite);
                window.display();
        }

        return 0;
}
 

and here is my screenshot of my problems
http://8pic.ir/images/7bc8kexg2llgh8groffj.png
thanks

13
Graphics / Re: rendering image
« on: February 19, 2015, 09:51:49 am »
 :-[ :-[

ok i try SFML_STATIC and still same errors also try to link them dynamicly but still same.......

 :-[ :-[ please anybody can help? :'(

14
Graphics / Re: rendering image
« on: February 19, 2015, 12:15:59 am »
yes
yes i add them one by one with  left click on project add->header or cpp in Vs 2013 express
and i copy paste the codes into it
and here this is my project configuration:
http://persianupload.com/kleeja/do.php?imgf=142430139487671.png

am  i doing wrong? :-\

thanks

15
Graphics / Re: rendering image
« on: February 18, 2015, 09:09:12 pm »
Hi again
thank u so much it help me a lot but.....
i found this page https://github.com/SFML/SFML/wiki/Source%3A-AnimatedSprite

now i add this Animation.hpp, cpp and  AnimationSprite.hpp,cpp to my project but i get huge errors  :-[
here is pic of them
http://persianupload.com/kleeja/do.php?imgf=142429067078071.png

please see this :-\
and thank u again.

Pages: [1] 2