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

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

22
.gitattributes vendored
View file

@ -1,22 +0,0 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

269
.gitignore vendored
View file

@ -1,215 +1,66 @@
################# # Ignore generated files
## Eclipse # ...
#################
*.pydevproject # Ignore compiled binaries
.project src/core.o
.metadata src/shapes.o
bin/ src/textures.o
tmp/ src/text.o
*.tmp src/models.o
*.bak src/audio.o
*.swp src/vector3.o
*~.nib src/stb_image.o
local.properties src/*.exe
.classpath examples/*.o
.settings/ examples/*.exe
.loadpath
# External tool builders # Ignore thumbnails created by windows
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db Thumbs.db
ehthumbs.db
# Folder config file # Ignore files build by Visual Studio
Desktop.ini *.obj
*.exe
*.pdb
*.aps
*.vcproj.*.user
*.vcxproj*
*.sln
*.vspscc
*_i.c
*.i
*.icf
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug/
[Dd]ebug.win32/
*.sbr
*.sdf
obj/
[Rr]elease/
[Rr]elease.win32/
_ReSharper*/
[Tt]est[Rr]esult*
ipch/
*.opensdf
# Recycle Bin used on file shares # Ignore files build by xcode
$RECYCLE.BIN/ *.mode*v*
*.pbxuser
# Mac crap *.xcbkptlist
*.xcscheme
*.xcworkspacedata
*.xcuserstate
*.xccheckout
xcschememanagement.plist
.DS_Store .DS_Store
._.*
xcuserdata/
############# DerivedData/
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

17
CHANGELOG Normal file
View file

@ -0,0 +1,17 @@
changelog
---------
Current: raylib 1.0 (November 2013)
-------------------------------------------
Release: raylib 1.0.0 (18 November 2013)
-------------------------------------------
* Initial version
* 6 Modules provided:
- core: basic window/context creation functions, input management, timming functions
- shapes: basic shapes drawing functions
- textures: image data loading and conversion to OpenGL textures
- text: text drawing, sprite fonts loading, default font loading
- models: basic 3d shapes drawing, OBJ models loading and drawing
- audio: audio device initialization, WAV files loading and playing

39
HELPME Normal file
View file

@ -0,0 +1,39 @@
help me!
========
I’m working hard on raylib but my resources are quite limited. If you enjoy raylib and want to help / contribute in some way,
please, [let me know][raysan5].
The following help is highly appreciated:
- C programming - Can you write / review / test / improve the code?
- Translators / Localizators - Can you translate raylib to another language?
- Documentation / Tutorials / Example writters - Can you write some tutorial / example?
- Web Development (I need a lot of help with this...) - Can you help with the web?
- Porting to Linux and OSX - Can you compile and test raylib on another OS?
- Testers of current features and multiple systems - Can you find some bug on raylib?
If you can not help on any of the above points but you still want to contribute in some way... please, consider helping
with a small donation (just some euros...). It will really motivate to continue improving this project (and pay some bills… or some coffee).
[Donation Page] (www.raylib.com/helpme.htm)
raylib philosophy
------------------
* raylib is a tool to LEARN videogames programming, every single function in raylib should be a tutorial on itself.
* raylib is SIMPLE and EASY-TO-USE, I tried to keep it compact with a small set of functions, if a function is too complex or
has not a clear usefulness, better not to include it.
* raylib is open source and free; educators and institutions can use this tool to TEACH videogames programming completely by free.
* raylib is, hopefully, collaborative; contribution of tutorials / code-examples / bugs-solving / code-comments are highly appreciated.
* raylib's license (and its external libs respective licenses) allow using it for commercial products.
contact
-------
* Webpage: [http://www.raylib.com](http://www.raylib.com)
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"

30
LICENSE Normal file
View file

@ -0,0 +1,30 @@
license
=======
source code
-----------
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software:
Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
This software is provided "as-is", without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you
wrote the original software. If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented
as being the original software.
3. This notice may not be removed or altered from any source distribution.
fonts
------
...soon...

115
README
View file

@ -1,2 +1,115 @@
It's empy here... <img src="http://www.raylib.com/favicon.ico" width=256>
raylib
=======
about
-----
raylib is a simple and easy-to-use library to learn C videogames programming.
raylib is highly inspired by Borland BGI graphics lib (more specifically WinBGI) and by XNA framework.
Allegro and SDL have also been analyzed for reference.
Want to see how easy is making games with raylib? Jump to [code examples!] (http://www.raylib.com/examples.htm)
history
-------
I've developed videogames for some years and last year I had to taught videogames development
to young people with artistic profile, most of them had never written a single line of code.
I started with C language basis and, after searching for the most simple and easy-to-use library to teach
videogames programming, I found WinBGI; it was great and it worked very well with students, in just a
couple of weeks that people that had never written a single line of code were able to program (and understand)
a simple PONG and some of them even a BREAKOUT!
But WinBGI was not the clearer and most organized lib. There were a lot of things I found useless and
confusing and some function names were not clear enough for most of the students; not to mention points
like no transparencies support or no hardware acceleration.
So, I decided to create my own lib, hardware accelerated, clear function names, quite organized, well structured,
plain C coding and, the most important, primarily intended to LEARN videogames programming.
I've coded quite a lot in C# and XNA and I really love it (in fact, my students learn C# with XNA after C),
so, I decided to use C# language notation and XNA naming conventions. That way, students can jump from
raylib to XNA (or MonoGame) extremely easily.
raylib started as a weekend project and after three months of hard work, here it is the first version.
Enjoy it.
features
--------
* Written in plain C code (C99)
* Uses C# PascalCase/camelCase notation
* Hardware accelerated using OpenGL 1.1
* Transparencies support (RGBA Colors)
* Custom color palette for better use on white background
* Basic 3D Support (camera, basic models, OBJ models, etc)
* Powerful Text module with SpriteFonts support
raylib uses on its core module the outstanding [GLFW3] (http://glfw.org/) library. The best option by far I found for
window/context and input management (clean, focused, great license, well documented, modern, ...).
raylib is licensed under a zlib/libpng license like GLFW3. View [LICENSE] (link to license file).
tool requirements
------------------
raylib has been developed using exclusively two tools:
* Notepad++ (text editor) - [http://notepad-plus-plus.org/](http://notepad-plus-plus.org/)
* MinGW (GCC compiler) - [http://www.mingw.org/](http://www.mingw.org/)
Those are the tools I recommended to develop with raylib, actually, my students develop using this tools.
I believe those are the best tools to train spartan-programmers.
Someone could argue about debugging. raylib is a library intended for learning and I think C it's a clear enough language
to allow writing small-mid size programs with a printf-based debugging. All raylib examples have also been written this way.
building
--------
raylib could be build with the following command lines (Using GCC compiler):
cd raylib/src
gcc -c core.c -std=c99 -Wall
gcc -c shapes.c -std=c99 -Wall
gcc -c textures.c -std=c99 -Wall
gcc -c stb_image.c -std=c99 -Wall
gcc -c text.c -std=c99 -Wall
gcc -c models.c -std=c99 -Wall
gcc -c vector3.c -std=c99 -Wall
gcc -c audio.c -std=c99 -Wall
ar rcs raylib.a core.o shapes.o textures.o stb_image.o text.o models.o vector3.o audio.o
To compile examples, make sure raylib.h is placed in include path and libraries raylib (libraylib.a) and glfw3 (libglfw3.a)
are placed in the libraries path. It's also recommended to link with file icon.o for fancy raylib icon usage.
cd raylib/src/examples
gcc -o test_code.exe test_code.c icon.o -lraylib -lglfw3 -lopengl32 -lgdi32 -std=c99 -Wl,--subsystem,windows
contact
-------
* Webpage: [http://www.raylib.com](http://www.raylib.com)
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
If you are using raylib and you enjoy it, please, [let me know][raysan5].
If you feel you can help, then, [helpme!] (http://www.raylib.com/helpme.htm)
acknowledgments
---------------
The following people have contributed in some way to make raylib project a reality. Big thanks to them!
- Zopokx
- Elendow
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"

22
ROADMAP Normal file
View file

@ -0,0 +1,22 @@
roadmap
=======
First version of raylib is quite complete and functional but there is still a lot of things I would like to improve.
Here it is a list of features I would like to add and functions to improve.
Around the source code there are some TODO points with pending revisions/bugs and ere it is a list of features I would like to add.
raylib v1.x
- Review Billboard Drawing functions
- Review Heightmap Loading and Drawing functions
- Lighting support (only 3d mode) - CreateLight()
- Simple Collision Detection functions - CheckCollisionRects(), CheckCollisionCircles()
- Default scene Camera controls (zoom, pan, rotate)
- Basic Procedural Texture / Image generation (Gradient, Checked, Spot, Noise, Cellular)
- Software mipmapping generation and POT conversion (custom implementation)
- Comments / Functions translation (?)
Any feature missing? Do you have a request? [Let me know!][raysan5]
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"

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

Some files were not shown because too many files have changed in this diff Show more