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