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 - EGYPTIAN CODER

Pages: [1]
1
General / relative transforms don't work
« on: June 28, 2017, 07:41:34 pm »
hello every one
I want to create class cannon which is a class to simulate a real cannon
the cannon is represented by a rectangle shape
I want this rectangle to always work in relative transforms
the owner of the cannon must pass it's sf::transformable part of it in the constructor
and in the class i keep a reference to this sf::transformable
i think this should work but it is not
here a small program that do this ((not the real one the real one is a failure )) and it's  not working as expected
void main(){
        sf::RenderWindow window (sf::VideoMode(400,400),"cannon test 1");

        sf::RectangleShape ret(sf::Vector2f(30,30));
        ret.setPosition(200,200);
        sf::CircleShape circle(30);
        circle.setOrigin(30,30);
        circle.setPosition(0,0);
        sf::Transformable &ref = ret;
        while(true)
        {
                sf::Event event;
                while(window.pollEvent(event)){}
                sf::Transform tra =sf::Transform::Identity ;
                tra.combine(ref.getTransform());
                tra.combine(circle.getTransform());
                window.clear();
                window.draw(ret);
                window.draw(circle,tra);
                window.display();
        }
}
 
here the result

2
SFML projects / Actions Reactions Engine
« on: May 07, 2017, 10:48:05 pm »
hello every one ;
my first project is done in sfml  ,and I would like everyone in this forim to see it   

the project is   
1- simple editor  : it just allow you to draw rectangle shapes and modify their position and size easily
                             and finally storing them (their attributes not rectangle shapes )

2-game engine   : in conclusion it does two things   the first is (collision detection) and second is (calling reactions) the reactions are lambda functions that have two parameters represent the colliders

3-simple game  : it uses the game engine and the editor to build a very simple game
(( a rectangle that is being controlled by the player and is jumps on rectangles))  ::) ::) ::)


and here my main  function to keep you patience ;D ;D
int main(){
        sf::RenderWindow window(sf::VideoMode(1200,700),"main");
       
        sf::View view;
        sf::Clock clock;
        sf::Time timer;

        const int level_blocks=16;

        block level[level_blocks];


       
       
        player me;
       

        engine eng;
       
        for(int w=0; w<level_blocks ; w++)
                eng.come_in_objects(level[w].let_me_in());


        eng.come_in_objects(me.let_me_in());
       
       

       
       


        while(window.isOpen()){


                timer= clock.restart();

        //here we apply the gravity
        me.default_actions( timer );
       

        //handling input
        sf::Event event;
        while(window.pollEvent(event)){
        me.input_handlig(event);

        if(event.type==sf::Event::Closed)
                window.close();
        }
         


        //updating the collision sheets
        me.update_sheet();
        for(int w=0; w<level_blocks ; w++)
                level[w].update_sheet();


        //collision detection and calling reactions
        eng.body_body_collision_checking();  //the holy event



       


       
        me.update( timer );//apply the final velocity

        window.clear();


        //applying the view
        view.setCenter(me.get_point());

        view.setSize(window.getDefaultView().getSize());


        window.setView(view);



        window.draw(me);
        for(int w=0; w<level_blocks ; w++)
                window.draw(level[w]);
       
        window.display();

        }


}
 
 

the editor


the game

the red rectangle is the player


i think that there is  a good ideas that can be applied to abigger projects  8) 8) 8)

3
General / sfml compiling in microsoft community
« on: May 03, 2017, 03:16:52 pm »
hello every one ;
I have installed microsoft visual c++ 2017 community but as you know there is no sfml package ready for it ;

step by step I have followed the tutorial about cmake
but now I am stuck in this stage


4
General / drawing cosine pixel by pixel
« on: May 03, 2017, 12:01:40 am »
hello every one ;
I want to draw cosine function or any function
and what i do is setting a rectangle shape size to 1 (to be a pixel )

but I think this is not the best way to do it or I am wrong because it was slow not much but it was slow

I draw the cosine function  for a determined range;

well, I i know that if i just did one drawing to the function and one display  things will be fine  8),but I want
to handle input that affect the function graph so one drawing and displaying is bad in this situation :(;


5
General / linking sfml again again again
« on: April 25, 2017, 07:16:45 am »
hello everyone;
in every time I have a new idea  i have to go to the new project directories and linker and put sfml directories

I am just so bored to do this for every new project;
how to make these things default ,how;

6
General / rectangle shape problem
« on: April 24, 2017, 05:26:27 pm »
hello every one ;
for the past two days I was working on a very simple project
that allow me to draw and modify rectangle shapes
the program save the vector of rectangle shape very easily but when it comes to loading them
then odd exceptions thrown  when drawing them
so what is the problem here

                std::ifstream reader(file_name.c_str(),std::ios::binary|std::ios::ate);
               

                unsigned int bytes=reader.tellg();
               
                reader.close();
                reader.open(file_name.c_str(),std::ios::binary);

               
                for(unsigned int ds=0;ds<(bytes/sizeof(sf::RectangleShape));ds++)
                        rectangles.push_back(sf::RectangleShape(sf::Vector2f(1,1)));

                reader.read((reinterpret_cast<char*> (&rectangles[0])),bytes);

               
                reader.close();
 

 

7
General / lambda can't access private members
« on: February 17, 2017, 10:56:36 am »
hello every one
I am building a game engine that separate actions from reactions(soon I will post it)
the reactions is lamba  :)  functions  and the actions are every time two drawable objects collide
but there is a problem that lambda need to access private members
and every time I find my self in this situation I made this members public :-\  but I think that this is very bad
temporary solution ;
so some help would would be great

8
General / pixels collision detection is too slow
« on: February 06, 2017, 02:25:11 am »
hi every one ;
I want to detect collision by pixels not by rectangles
I know how to do it, but in the end I find my self comparing every point of 463 points with 469 point
when I did this the shape become too slow in moving
is this because pixels collision detection or there is just another reason and if its how can I make is efficient
(it did work put toooooooooo slow )

9
General / what does combine function do
« on: December 09, 2016, 07:55:05 pm »
there is just one small problem still exist in chapt3 from SFML GAME DEVELOPMENT;
in this code
virtual void                    draw(sf::RenderTarget& target, sf::RenderStates states) const
{
        // Apply transform of current node
        states.transform *= getTransform();
       

        // Draw node and children with changed transform
        drawCurrent(target, states);
        drawChildren(target, states);
}
 
what (*=) or (combine) do in this code (I have read the documentation about this function but still cant understand what it is doing)
==========================
and just another small question  .in the above function (draw)
draw current and  draw children take the same state  ???
how this is possible. and there is three planes draw themselves in three different locations.


10
General / strange behavior in the update function
« on: December 07, 2016, 11:41:07 pm »
        void                                    update(sf::Time elapsedTime)
{
        std::cout<<"too slow right !!\n";
        mWorld.update(elapsedTime);
}
this is the function update from class(game) from SFML GAME DEVELOPMENT
I just added cout and then the game become tooooo slow 1 frame/second
I am in chapter three in the book and I have followed the instructions very well
before adding this cout and in this particular place every thing was good ???

11
General / SFML Game Development project
« on: November 26, 2016, 12:48:37 pm »
hello every one
I am now in chapter three in SFML Game Development
class SceneNode : public sf::Transformable, public sf::Drawable,
private sf::NonCopyable
{
public:
typedef std::unique_ptr<SceneNode> Ptr;
public:
SceneNode();
void attachChild(Ptr child);
Ptr detachChild(const SceneNode& node);
private:
virtual void draw(sf::RenderTarget& target,
sf::RenderStates states) const;
virtual void drawCurrent(sf::RenderTarget& target,
sf::RenderStates states) const;
private:
std::vector<Ptr> mChildren;
SceneNode* mParent;
};
 
The draw() function allows our class to be used as shown in the following
code snippet:
sf::RenderWindow window(...);
SceneNode::Ptr node(...);
window.draw(*node); // note: no node->draw(window) here!
The window class internally calls our draw() function. No other classes need access
to it, so we can make it private.
I realy can,t understand what (internally calls our draw()function mean) :o ???

Pages: [1]
anything