- Clone this repo.
- Add #include "GameEngine.h" in your file.
Return type: Bool. Function: Return True if an SFML Rectangle Shape is clicked on. Example: if (Engine.MouseClick(shape, event.mouseButton)) { std::cout << "clicked"; }
=> Always pass event.mouseButton as the second argument.
Return type: Bool. Function: Return True if an SFML Rectangle Shape is clicked on. Example: if (Engine.MouseClick(shape, event.mouseButton)) { std::cout << "clicked"; }
=> Always pass event.mouseButton as the second argument.
CollisionSide is a struct with four boolean variables. It is already defined in the GameEngine. Just use CollisionSide (name); to make an instance.
Return type: CollisionSide. Function: CollisionSide is a struct that has four booleans. The booleans are set to true if a rectangle shape(passed as the first argument) is touching with any of the four sides of the rectangle shape referencePoint(passed as the second argument). Example: CollisionSide collisions = Engine.areColliding(shape1, shape2); if(collisions.left) std::cout<<” Shape1 is touching the left side of the shape2”; if(collisions.right) std::cout<<” Shape1 is touching the right side of the shape2”; if(collisions.top) std::cout<<” Shape1 is touching the top side of the shape2”; if(collisions.bottom) std::cout<<” Shape1 is touching the bottom side of the shape2”;
Return type: CollisionSide. Function: CollisionSide is a struct that has four booleans. The booleans are set to true if a circle shape(passed as the first argument) is touching with any of the four sides of the rectangle shape referencePoint(passed as the second argument). Example: CollisionSide collisions = Engine.areColliding(shape1, shape2); if(collisions.left) std::cout<<” Shape1 is touching the left side of the shape2”; if(collisions.right) std::cout<<” Shape1 is touching the right side of the shape2”; if(collisions.top) std::cout<<” Shape1 is touching the top side of the shape2”; if(collisions.bottom) std::cout<<” Shape1 is touching the bottom side of the shape2”;
Return type: Void. Function: Apply Gravity to a rectangle shape. base is used as ground. When the fallingobject touches the base it will stop falling. Example: Engine.Gravity(shape1, base);
Return type: Void. Function: Apply Gravity to a circle shape. base is used as ground. When the fallingobject touches the base it will stop falling. Example: Engine.Gravity(shape1, base);
collision Side cs = Engine.areColliding(shape1, base); Engine.Gravity(shape1, cs);
Return type: Void. Function: Apply Gravity to a circle shape. baseCollisionObject can be obtained by using the areColliding(shapeToApplyGravityTo, Ground); This function works best if you have more than one surface you want to make ground. Example:
collision Side cs = Engine.areColliding(shape1, base); Engine.Gravity(shape1, cs);
Return type: Void. Function: Apply movement to a Rectangle Shape Example: Engine.enableMovement(shape1); => The speed is by default set to 1px per key pressed, you can change it in the code.
Return type: Void. Function: Apply movement to a Circle Shape Example: Engine.enableMovement(shape1); => The speed is by default set to 1px per key pressed, you can change it in the code.
Return type: Void. Function: Change textures of a shape with respect to the movement. Example: Engine.animation(shape1, &leftTexture, &rightTexture, &upTexture, &DownTexture);
Return type: Void. Function: Draw endless shapes as a shape moves. Consider something like pacman, where there are endless poles generated, this function works similar to that. shapeInFocus is the shape with respect to which ShapeToRepeat will be generated. Screen is the object you use to create a window in SFML, pass that here. StartingPos tells from which height the shapes will start drawing. DistanceBetweenShape is how much distance you want in the shapes.