GDevelop C++ Platform
Platform for developing native games based on OpenGL and SFML with GDevelop
 All Classes Namespaces Files Functions Variables Modules Pages
Modules | Classes | Enumerations | Functions
Game engine

Modules

 Sound engine
 
 Resources management
 

Classes

class  BehaviorsRuntimeSharedData
 Base class for defining behaviors shared datas used at runtime. More...
 
class  Force
 Represents a force to be applied on an object. More...
 
class  ManualTimer
 Manual timer, updated using ManualTimer::UpdateTime member function. More...
 
class  ObjInstancesHolder
 Contains lists of objects classified by the name of the objects. More...
 
struct  CollisionResult
 Contains the result of PolygonCollisionTest. More...
 
class  RuntimeGame
 Represents a game being played. More...
 
class  RuntimeCamera
 A camera which is displayed on a part of a window ( see Viewport related methods ) rendering an area of the scene. More...
 
class  RuntimeLayer
 A layer of a layout, used to display objects using RuntimeCamera. More...
 
class  RuntimeObject
 A RuntimeObject is something displayed on the scene. More...
 
class  RuntimeScene
 Represents a scene being played. More...
 
struct  RuntimeScene::SceneChange
 
class  RuntimeVariablesContainer
 Container for gd::Variable used at by games at runtime. More...
 
class  ShaderManager
 Still work in progress class to manage shaders. More...
 
class  TimeManager
 Manage the timers and times elapsed during last frame, since the beginning of the scene and other time related values. More...
 

Enumerations

enum  Change {
  CONTINUE = 0, PUSH_SCENE, POP_SCENE, REPLACE_SCENE,
  CLEAR_SCENES, STOP_GAME
}
 

Functions

CollisionResult GD_API PolygonCollisionTest (Polygon2d &p1, Polygon2d &p2, bool ignoreTouchingEdges=false)
 
RaycastResult GD_API PolygonRaycastTest (Polygon2d &poly, float startX, float startY, float endX, float endY)
 
bool GD_API IsPointInsidePolygon (Polygon2d &poly, float x, float y)
 
void GD_API PickOnly (RuntimeObjectsLists &pickedObjectsLists, RuntimeObject *thisOne)
 Keep only the specified object in the lists of picked objects. More...
 
template<typename Pred >
bool PickObjectsIf (const RuntimeObjectsLists &pickedObjectsLists, bool negatePredicate, Pred predicate)
 Filter objects to keep only the one that fullfil the predicate. More...
 
template<typename Pred >
bool TwoObjectListsTest (RuntimeObjectsLists objectsLists1, RuntimeObjectsLists objectsLists2, bool negatePredicate, Pred predicate)
 Picks objects that fullfil the predicate with at least another object. More...
 

Detailed Description

Function Documentation

bool GD_API IsPointInsidePolygon ( Polygon2d &  poly,
float  x,
float  y 
)

Check if a point is inside a polygon.

Uses PNPOLY by W. Randolph Franklin (https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html)

Returns
true if the point is inside the polygon
template<typename Pred >
bool PickObjectsIf ( const RuntimeObjectsLists &  pickedObjectsLists,
bool  negatePredicate,
Pred  predicate 
)

Filter objects to keep only the one that fullfil the predicate.

Objects that do not fullfil the predicate are removed from objects lists.

Parameters
objectsListsThe lists of objects to trim
negatePredicateIf set to true, the result of the predicate is negated.
predicateThe function applied to each object: must return true if the object fulfill the predicate.
Returns
true if at least one object fulfill the predicate.
void GD_API PickOnly ( RuntimeObjectsLists &  pickedObjectsLists,
RuntimeObject thisOne 
)

Keep only the specified object in the lists of picked objects.

Parameters
objectsListsThe lists of objects to trim
thisOneThe object to keep in the lists
CollisionResult GD_API PolygonCollisionTest ( Polygon2d &  p1,
Polygon2d &  p2,
bool  ignoreTouchingEdges = false 
)

Do a collision test between the two polygons.

Warning
Polygons must convexes.

Uses Separating Axis Theorem ( http://en.wikipedia.org/wiki/Hyperplane_separation_theorem ) Based on http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection and http://stackoverflow.com/questions/5742329/problem-with-collision-response-sat

Parameters
p1The first polygon
p2The second polygon
ignoreTouchingEdgesIf true, then edges that are touching each other, without the polygons actually overlapping, won't be considered in collision.
Returns
true if polygons are overlapping
RaycastResult GD_API PolygonRaycastTest ( Polygon2d &  poly,
float  startX,
float  startY,
float  endX,
float  endY 
)

Do a raycast test.

Warning
Polygon must be convex. For some theory check "Find the Intersection Point of Two Line Segments" (https://www.codeproject.com/Tips/862988/Find-the-Intersection-Point-of-Two-Line-Segments)
Returns
A raycast result with the contact points and distances
template<typename Pred >
bool TwoObjectListsTest ( RuntimeObjectsLists  objectsLists1,
RuntimeObjectsLists  objectsLists2,
bool  negatePredicate,
Pred  predicate 
)

Picks objects that fullfil the predicate with at least another object.

This function picks from objectsLists1 and objectsLists2 only pairs of objects for which the test is true. If inverted == true, only the objects of the first table are filtered.

Note that the predicate is not called stricly for each pair: When considering a pair of objects, if these objects have already been marked as picked, the predicate won't be called again.

objectsLists1 and objectsLists2 may contains one or more identical pointers to some lists (See This is important comment at the end of the algorithm, when trimming the list).

Cost (Worst case, predicate being always false): Cost(Creating tables with a total of NbObjList1+NbObjList2 booleans)

  • Cost(predicate)*NbObjList1*NbObjList2
  • Cost(Testing NbObjList1+NbObjList2 booleans)
  • Cost(Removing NbObjList1+NbObjList2 objects from all the lists)

Cost (Best case, predicate being always true): Cost(Creating tables with a total of NbObjList1+NbObjList2 booleans)

  • Cost(predicate)*(NbObjList1+NbObjList2)
  • Cost(Testing NbObjList1+NbObjList2 booleans)