chore: rebase to main with translation ports
This commit is contained in:
parent
768fa93c41
commit
8024c6ac40
134 changed files with 15456 additions and 10650 deletions
|
|
@ -20,74 +20,98 @@ using static Raylib_cs.Raylib;
|
|||
|
||||
namespace Examples.Core;
|
||||
|
||||
public class InputMultitouch
|
||||
public partial class InputMultitouch : IExample
|
||||
{
|
||||
private const int screenWidth = 800;
|
||||
private const int screenHeight = 450;
|
||||
|
||||
private const int MaxTouchPoints = 10;
|
||||
|
||||
public string Name => "Core / Input Multitouch";
|
||||
|
||||
public string Title => "raylib [core] example - input multitouch";
|
||||
|
||||
private Vector2[] touchPositions;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
touchPositions = new Vector2[MaxTouchPoints];
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Get the touch point count ( how many fingers are touching the screen )
|
||||
var tCount = GetTouchPointCount();
|
||||
|
||||
// Clamp touch points available ( set the maximum touch points allowed )
|
||||
if (tCount > MaxTouchPoints)
|
||||
{
|
||||
tCount = MaxTouchPoints;
|
||||
}
|
||||
|
||||
// Get touch points positions
|
||||
for (var i = 0; i < tCount; i++)
|
||||
{
|
||||
touchPositions[i] = GetTouchPosition(i);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
ClearBackground(Color.RayWhite);
|
||||
|
||||
for (var i = 0; i < tCount; i++)
|
||||
{
|
||||
// Make sure point is not (0, 0) as this means there is no touch for it
|
||||
if ((touchPositions[i].X > 0) && (touchPositions[i].Y > 0))
|
||||
{
|
||||
// Draw circle and touch index number
|
||||
DrawCircleV(touchPositions[i], 34, Color.Orange);
|
||||
DrawText(i.ToString(),
|
||||
(int)touchPositions[i].X - 10,
|
||||
(int)touchPositions[i].Y - 70,
|
||||
40,
|
||||
Color.Black
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DrawText("touch the screen at multiple locations to get multiple balls", 10, 10, 20, Color.DarkGray);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
}
|
||||
|
||||
public static int Main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch");
|
||||
|
||||
const int MaxTouchPoints = 10;
|
||||
Vector2[] touchPositions = new Vector2[MaxTouchPoints];
|
||||
|
||||
SetTargetFPS(60);
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
var game = new InputMultitouch();
|
||||
game.Init();
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose())
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Get the touch point count (how many fingers are touching the screen )
|
||||
int tCount = GetTouchPointCount();
|
||||
|
||||
// Clamp touch points available (set the maximum touch points allowed )
|
||||
if (tCount > MaxTouchPoints)
|
||||
{
|
||||
tCount = MaxTouchPoints;
|
||||
}
|
||||
|
||||
// Get touch points positions
|
||||
for (int i = 0; i < tCount; i++)
|
||||
{
|
||||
touchPositions[i] = GetTouchPosition(i);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
ClearBackground(Color.RayWhite);
|
||||
|
||||
for (int i = 0; i < tCount; i++)
|
||||
{
|
||||
// Make sure point is not (0, 0) as this means there is no touch for it
|
||||
if ((touchPositions[i].X > 0) && (touchPositions[i].Y > 0))
|
||||
{
|
||||
// Draw circle and touch index number
|
||||
DrawCircleV(touchPositions[i], 34, Color.Orange);
|
||||
DrawText(i.ToString(),
|
||||
(int)touchPositions[i].X - 10,
|
||||
(int)touchPositions[i].Y - 70,
|
||||
40,
|
||||
Color.Black
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DrawText("touch the screen at multiple locations to get multiple balls", 10, 10, 20, Color.DarkGray);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
game.Update();
|
||||
}
|
||||
|
||||
game.Unload();
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow();
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue