贴图
主要函数:
RLAPI Texture2D LoadTexture(const char *fileName);
RLAPI Image LoadImage(const char *fileName);
RLAPI Textrue2D LoadTextureFromImage(Image image);
RLAPI void DrawTexure(Texture2D texture,int posX,int posY,Color tint);
简单贴图小代码
#include <stdio.h>
#include <raylib.h>
#include <time.h>
#include <stdlib.h>
void test_database()
{
Vector2 p;
p.x = 11;
p.y = 2;
Vector3 o;
o.x = 10;
o.y = 11;
o.z = 10;
}
int main()
{
InitWindow(200, 200, "Alaso_shuang");
Texture t = LoadTexture("C:/Users/Alaso/Desktop/little.png");
while (!WindowShouldClose())
{
BeginDrawing();
Vector2 v = { 10,10 };
DrawTexture(t, 0, 0, WHITE);
EndDrawing();
}
UnloadTexture(t);
CloseWindow();
return 0;
}
写了一个判断按键按下即可给图片换颜色的玩意
#include <stdio.h>
#include <raylib.h>
int main()
{
InitWindow(800, 600, "Alaso_shuang");
Texture2D photo = LoadTexture("C:/Users/Alaso/Desktop/little.png");
while (!WindowShouldClose())
{
static bool is_turn = false;
if (IsKeyPressed(KEY_SPACE))
{
is_turn = is_turn ? false : true;
}
BeginDrawing();
ClearBackground(Color{ 125,124,123 });
DrawTexture(photo, 300, 400, is_turn ? WHITE : ORANGE);
DrawText("Alaso_shuang is a smart woman!",500,400,25,RED);
DrawFPS(0,0);
EndDrawing();
}
CloseWindow();
return 0;
}
194

被折叠的 条评论
为什么被折叠?



