Reviewed examples
This commit is contained in:
parent
d47d7c0001
commit
c20df9aa47
6 changed files with 166 additions and 156 deletions
|
@ -15,7 +15,7 @@
|
|||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
|
||||
#define MAX_POINTS 11 // 10 points and back to the start
|
||||
#define MAX_POINTS 11 // 10 points and back to the start
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
@ -23,7 +23,10 @@ int main(void)
|
|||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [textures] example - textured polygon");
|
||||
|
||||
// Define texture coordinates to map our texture to poly
|
||||
Vector2 texcoords[MAX_POINTS] = {
|
||||
(Vector2){ 0.75f, 0.0f },
|
||||
(Vector2){ 0.25f, 0.0f },
|
||||
|
@ -38,22 +41,24 @@ int main(void)
|
|||
(Vector2){ 0.75f, 0.0f} // Close the poly
|
||||
};
|
||||
|
||||
// Define the base poly vertices from the UV's
|
||||
// NOTE: They can be specified in any other way
|
||||
Vector2 points[MAX_POINTS] = { 0 };
|
||||
|
||||
// Create the poly coords from the UV's
|
||||
// you don't have to do this you can specify
|
||||
// them however you want
|
||||
for (int i = 0; i < MAX_POINTS; i++)
|
||||
{
|
||||
points[i].x = (texcoords[i].x - 0.5f)*256.0f;
|
||||
points[i].y = (texcoords[i].y - 0.5f)*256.0f;
|
||||
}
|
||||
|
||||
// Define the vertices drawing position
|
||||
// NOTE: Initially same as points but updated every frame
|
||||
Vector2 positions[MAX_POINTS] = { 0 };
|
||||
for (int i = 0; i < MAX_POINTS; i++) positions[i] = points[i];
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [textures] example - textured polygon");
|
||||
|
||||
// Load texture to be mapped to poly
|
||||
Texture texture = LoadTexture("resources/cat.png");
|
||||
|
||||
float angle = 0.0f;
|
||||
float angle = 0.0f; // Rotation angle (in degrees)
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -63,10 +68,9 @@ int main(void)
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Update points rotation with an angle transform
|
||||
// NOTE: Base points position are not modified
|
||||
angle++;
|
||||
|
||||
Vector2 positions[MAX_POINTS] = { 0 };
|
||||
|
||||
for (int i = 0; i < MAX_POINTS; i++) positions[i] = Vector2Rotate(points[i], angle*DEG2RAD);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
Loading…
Add table
Add a link
Reference in a new issue