Skip to content

raylib-extras/examples-c

Repository files navigation

examples-c

Examples and samples made for raylib using C

Building

The examples use premake. Each example is a project on it's own. Premake will setup the build systems for each project for you, and download any needed libraries (raylib and box2d)

For Visual Studio

Run premake-VisualStudio.bat. When it is done each example folder will have a .sln file in it that you can open and run.

For MinGW

Run premake-mingw.bat. When it is done each example folder will have a makefile that you can build, just cd into the example folder and type make.

For GCC On Linux

Run "premake5 gmake2". When it is done each example folder will have a makefile that you can build, just cd into the example folder and type make.

For GCC On MacOs

Run "premake5.osx gmake2". When it is done each example folder will have a makefile that you can build, just cd into the example folder and type make.

Circle In View 2D

Code showing how to check if a circle is inside a view cone. Shows examples of using dot products to find what side of a vector a point is on, and how to compute the nearest point on a vector to another point. circle_in_view

Texture Repeat

An example of how to do a repeating background inside a camera 2d repeat

Full 3d Billboards

An example of how to make a billboard that follows the camera in any orientation 3D_Billboards

Unsorted Billboards

An example of using shaders to discard pixels with 0 alpha to allow billboards to be drawn in any order. unsorted_billobards

Ray2d And Rect Intersection

Code to show how to quickly detect if a 2d ray intersects a rectangle intersect

Rect Circle Collisions

Example of how to get the intersection point between a rectangle and a cirlce and use that to do collision detection. This is one way to do collisions on a player in 2/2.5d against world objects. collision_rects

Camera Clamp

A simple example of how to keep a camera view on a map but still follow the player when possible. camera_clamp

Camera World Rect

A simple example of how to get the screen rectangle in world space, with pan and zoom taken into account screen_in_world_rect

Mouse Zoom

An example of how to zoom a Camera2d around the mouse cursor. mouse_zoom

Platform Motion

Example of simple platfomer motion and collision platform

rlgl_example

Example of using raw rlgl to draw geometry

lua_embed

Example of embeding lua into a game and exposting functions and data to lua scripts, using raylib

camera worldspace

Example of how to use a camera to create a nominal worldspace with any window size