raylib basic folders structure and some files... ;)

This commit is contained in:
Ray 2013-11-18 23:38:44 +01:00
parent cbbf800bb8
commit 46f10b45ad
59 changed files with 18943 additions and 232 deletions

View file

@ -0,0 +1,50 @@
/*******************************************************************************************
*
* raylib example 01 - Basic Window
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
int screenWidth = 800;
int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 01a - basic window"); // Window and context initialization
//----------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//-----------------------------------------------------
// TODO: Update your variables here
//-----------------------------------------------------
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, 1, LIGHTGRAY);
EndDrawing();
//-----------------------------------------------------
}
// De-Initialization
//---------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -0,0 +1,54 @@
/*******************************************************************************************
*
* raylib example 02a - Draw raylib logo
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
int screenWidth = 800;
int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 02a - raylib logo"); // Window and context initialization
//----------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//-----------------------------------------------------
// TODO: Update your variables here
//-----------------------------------------------------
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK);
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE);
DrawText("raylib", 356, 273, 50, 1, BLACK);
DrawText("this is NOT a texture!", 350, 370, 10, 1, GRAY);
EndDrawing();
//-----------------------------------------------------
}
// De-Initialization
//---------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

73
examples/ex02b_shapes.c Normal file
View file

@ -0,0 +1,73 @@
/*******************************************************************************************
*
* raylib example 02b - Draw basic shapes 2d (rectangle, circle, line...)
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
int screenWidth = 800;
int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 02b - basic shapes drawing"); // Window and context initialization
//----------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//-----------------------------------------------------
// TODO: Update your variables here
//-----------------------------------------------------
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// TODO: draw some shapes... with names... :P
/*
void DrawPixel(int posX, int posY, Color color); // Draw a pixel
void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version)
void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line
void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version)
void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle
void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle
void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version)
void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline
void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle
void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle
void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle
void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version)
void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline
void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle
void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline
void DrawPoly(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
void DrawPolyLine(Vector2 *points, int numPoints, Color color); // Draw polygon lines
*/
DrawRectangle(screenWidth/4 - 50, screenHeight/2 - 100, 100, 100, GOLD);
DrawCircle(3*screenWidth/4, screenHeight/2 - 50, 50, MAROON);
DrawText("_____", 320, 280, 50, 1, BLACK);
EndDrawing();
//-----------------------------------------------------
}
// De-Initialization
//---------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------
return 0;
}

View file

@ -0,0 +1,95 @@
/*******************************************************************************************
*
* raylib example 02c - Draw raylib custom color palette
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
int screenWidth = 800;
int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 02c - raylib color palette"); // Window and context initialization
//----------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//-----------------------------------------------------
// TODO: Update your variables here
//-----------------------------------------------------
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("raylib color palette", 28, 42, 20, 2, BLACK);
DrawRectangle(26, 80, 100, 100, DARKGRAY);
DrawRectangle(26, 188, 100, 100, GRAY);
DrawRectangle(26, 296, 100, 100, LIGHTGRAY);
DrawRectangle(134, 80, 100, 100, MAROON);
DrawRectangle(134, 188, 100, 100, RED);
DrawRectangle(134, 296, 100, 100, PINK);
DrawRectangle(242, 80, 100, 100, ORANGE);
DrawRectangle(242, 188, 100, 100, GOLD);
DrawRectangle(242, 296, 100, 100, YELLOW);
DrawRectangle(350, 80, 100, 100, DARKGREEN);
DrawRectangle(350, 188, 100, 100, LIME);
DrawRectangle(350, 296, 100, 100, GREEN);
DrawRectangle(458, 80, 100, 100, DARKBLUE);
DrawRectangle(458, 188, 100, 100, BLUE);
DrawRectangle(458, 296, 100, 100, SKYBLUE);
DrawRectangle(566, 80, 100, 100, DARKPURPLE);
DrawRectangle(566, 188, 100, 100, VIOLET);
DrawRectangle(566, 296, 100, 100, PURPLE);
DrawRectangle(674, 80, 100, 100, DARKBROWN);
DrawRectangle(674, 188, 100, 100, BROWN);
DrawRectangle(674, 296, 100, 100, BEIGE);
DrawText("DARKGRAY", 57, 166, 10, 2, BLACK);
DrawText("GRAY", 89, 274, 10, 2, BLACK);
DrawText("LIGHTGRAY", 51, 382, 10, 2, BLACK);
DrawText("MAROON", 180, 166, 10, 2, BLACK);
DrawText("RED", 207, 274, 10, 2, BLACK);
DrawText("PINK", 200, 382, 10, 2, BLACK);
DrawText("ORANGE", 290, 166, 10, 2, BLACK);
DrawText("GOLD", 306, 274, 10, 2, BLACK);
DrawText("YELLOW", 290, 382, 10, 2, BLACK);
DrawText("DARKGREEN", 374, 166, 10, 2, BLACK);
DrawText("LIME", 417, 274, 10, 2, BLACK);
DrawText("GREEN", 407, 382, 10, 2, BLACK);
DrawText("DARKBLUE", 491, 166, 10, 2, BLACK);
DrawText("BLUE", 523, 274, 10, 2, BLACK);
DrawText("SKYBLUE", 499, 382, 10, 2, BLACK);
DrawText("DARKPURPLE", 582, 166, 10, 2, BLACK);
DrawText("VIOLET", 617, 274, 10, 2, BLACK);
DrawText("PURPLE", 615, 382, 10, 2, BLACK);
DrawText("DARKBROWN", 695, 166, 10, 2, BLACK);
DrawText("BROWN", 728, 274, 10, 2, BLACK);
DrawText("BEIGE", 733, 382, 10, 2, BLACK);
EndDrawing();
//-----------------------------------------------------
}
// De-Initialization
//---------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -0,0 +1,57 @@
/*******************************************************************************************
*
* raylib example 03a - Keyboard input
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
int screenWidth = 800;
int screenHeight = 450;
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 05 - keyboard input"); // Window and context initialization
//----------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//-----------------------------------------------------
if (IsKeyPressed(KEY_RIGHT)) ballPosition.x += 0.8;
if (IsKeyPressed(KEY_LEFT)) ballPosition.x -= 0.8;
if (IsKeyPressed(KEY_UP)) ballPosition.y -= 0.8;
if (IsKeyPressed(KEY_DOWN)) ballPosition.y += 0.8;
//-----------------------------------------------------
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("move the ball with arrow keys", 10, 10, 20, 1, DARKGRAY);
DrawCircleV(ballPosition, 50, MAROON);
EndDrawing();
//-----------------------------------------------------
}
// De-Initialization
//---------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -0,0 +1,63 @@
/*******************************************************************************************
*
* raylib example 03b - Mouse input
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
int screenWidth = 800;
int screenHeight = 450;
Vector2 ballPosition = { -100.0, -100.0 };
int counter = 0;
int mouseX, mouseY;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 06 - mouse input"); // Window and context initialization
//----------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//-----------------------------------------------------
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
mouseX = GetMouseX();
mouseY = GetMouseY();
ballPosition.x = (float)mouseX;
ballPosition.y = (float)mouseY;
}
//-----------------------------------------------------
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawCircleV(ballPosition, 40, GOLD);
DrawText("mouse click to draw the ball", 10, 10, 20, 1, DARKGRAY);
EndDrawing();
//-----------------------------------------------------
}
// De-Initialization
//---------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -0,0 +1,67 @@
/*******************************************************************************************
*
* raylib example 03c - Gamepad input
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
int screenWidth = 800;
int screenHeight = 450;
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
Vector2 gamepadMove = { 0, 0 };
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input"); // Window and context initialization
//----------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//-----------------------------------------------------
if (IsGamepadAvailable(GAMEPAD_PLAYER1))
{
gamepadMove = GetGamepadMovement(GAMEPAD_PLAYER1);
ballPosition.x += gamepadMove.x;
ballPosition.y -= gamepadMove.y;
if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A))
{
ballPosition.x = screenWidth/2;
ballPosition.y = screenHeight/2;
}
}
//-----------------------------------------------------
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("move the ball with gamepad", 10, 10, 20, 1, DARKGRAY);
DrawCircleV(ballPosition, 50, MAROON);
EndDrawing();
//-----------------------------------------------------
}
// De-Initialization
//---------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

57
examples/ex04a_textures.c Normal file
View file

@ -0,0 +1,57 @@
/*******************************************************************************************
*
* raylib example 04a - Texture loading and drawing
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
#include "raylib.h"
int main()
{
int screenWidth = 800;
int screenHeight = 450;
// Initialization
//---------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib example 04a - texture loading and drawing"); // Window and context initialization
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
//----------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//-----------------------------------------------------
// TODO: Update your variables here
//-----------------------------------------------------
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
DrawText("this IS a texture!", 360, 370, 10, 1, GRAY);
EndDrawing();
//-----------------------------------------------------
}
// De-Initialization
//---------------------------------------------------------
UnloadTexture(texture); // Texture unloading
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------
return 0;
}

BIN
examples/ex04a_textures.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

BIN
examples/resources/coin.wav Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.