Watch
2
0
Fork
You've already forked raylib-cs
0

feat: backporting existing raylib-cs examples and new official raylib examples to WASM, adopting raylib's original code style

This commit is contained in:
tiger tiger tiger 2026-07-17 08:22:54 +02:00
commit 732b7aa346
234 changed files with 38999 additions and 10578 deletions

View file

@ -1,11 +1,15 @@
/*******************************************************************************************
*
* raylib [text] example - Text formatting
* raylib [text] example - format text
*
* This example has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* Example complexity rating: [] 1/4
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
* Example originally created with raylib 1.1, last time updated with raylib 3.0
*
* Example 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) 2014-2025 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@ -13,49 +17,72 @@ using static Raylib_cs.Raylib;
namespace Examples.Text;
public class FormatText
public partial class FormatText : IExample
{
private const int screenWidth = 800;
private const int screenHeight = 450;
public string Name => "Text / Format Text";
public string Title => "raylib [text] example - format text";
private int score;
private int hiscore;
private int lives;
public void Init()
{
score = 100020;
hiscore = 200450;
lives = 5;
}
public void Update()
{
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RayWhite);
DrawText($"Score: {score:D8}", 200, 80, 20, Color.Red);
DrawText($"HiScore: {hiscore:D8}", 200, 120, 20, Color.Green);
DrawText($"Lives: {lives:D2}", 200, 160, 40, Color.Blue);
DrawText($"Elapsed Time: {GetFrameTime() * 1000:F2} ms", 200, 220, 20, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------
}
public void Unload()
{
}
public static int Main()
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - format text");
InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting");
int score = 100020;
int hiscore = 200450;
int lives = 5;
SetTargetFPS(60);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
var game = new FormatText();
game.Init();
// Main game loop
while (!WindowShouldClose())
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RayWhite);
DrawText($"Score: {score}", 200, 80, 20, Color.Red);
DrawText($"HiScore: {hiscore}", 200, 120, 20, Color.Green);
DrawText($"Lives: {lives}", 200, 160, 40, Color.Blue);
DrawText($"Elapsed Time: {GetFrameTime() * 1000} ms", 200, 220, 20, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------
game.Update();
}
game.Unload();
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow();
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;