Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
r.GetKeyPressed()
console.log(r.IsKeyDown(r.KEY_ONE))
// console.log(r.GetKeyPressed())
r.DrawText('some basic shapes available on raylib', 20, 20, 20, r.DARKGRAY)
var position = {
x: 100,
y: 100,
}
var size = {
x: 200,
y: 150,
}
r.DrawRectangleV(position, size, r.DARKBLUE)
r.DrawRectangleRec(
{
x: 50,
y: 50,
width: 50,
height: 50,
},
r.PINK
)
/*
DrawCircle(screenWidth/4, 120, 35, DARKBLUE);
DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines
DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
r.DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, r.DARKGREEN)
} break
case 'GAMEPLAY':
{
// TODO: Draw GAMEPLAY screen here!
r.DrawRectangle(0, 0, screenWidth, screenHeight, r.PURPLE)
r.DrawText("GAMEPLAY SCREEN", 20, 20, 40, r.MAROON)
r.DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, r.MAROON)
} break
case 'ENDING':
{
// TODO: Draw ENDING screen here!
r.DrawRectangle(0, 0, screenWidth, screenHeight, r.BLUE);
r.DrawText("ENDING SCREEN", 20, 20, 40, r.DARKBLUE);
r.DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, r.DARKBLUE);
} break
}
r.EndDrawing()
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
// TODO: Unload all loaded data (textures, fonts, audio) here!
r.CloseWindow() // Close window and OpenGL context
//--------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
r.BeginDrawing();
r.ClearBackground(r.RAYWHITE);
r.DrawText("some basic shapes available on raylib", 20, 20, 20, r.DARKGRAY);
var position = {
x: 100,
y: 100
}
var size = {
x: 200,
y: 150
}
r.DrawRectangleV(position, size, r.DARKBLUE)
r.DrawRectangleRec({
x: 50,
y: 50,
width: 50,
height: 50
}, r.PINK)
/*
DrawCircle(screenWidth/4, 120, 35, DARKBLUE);
DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines
DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
DrawTriangle((Vector2){screenWidth/4*3, 80},
} break
case 'GAMEPLAY':
{
// TODO: Draw GAMEPLAY screen here!
r.DrawRectangle(0, 0, screenWidth, screenHeight, r.PURPLE)
r.DrawText("GAMEPLAY SCREEN", 20, 20, 40, r.MAROON)
r.DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, r.MAROON)
} break
case 'ENDING':
{
// TODO: Draw ENDING screen here!
r.DrawRectangle(0, 0, screenWidth, screenHeight, r.BLUE);
r.DrawText("ENDING SCREEN", 20, 20, 40, r.DARKBLUE);
r.DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, r.DARKBLUE);
} break
}
r.EndDrawing()
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
// TODO: Unload all loaded data (textures, fonts, audio) here!
r.CloseWindow() // Close window and OpenGL context
//--------------------------------------------------------------------------------------
// Main game loop
while (!r.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
ballPosition = r.GetMousePosition()
if (r.IsMouseButtonPressed(r.MOUSE_LEFT_BUTTON)) {
ballColor = r.MAROON
}
else if (r.IsMouseButtonPressed(r.MOUSE_MIDDLE_BUTTON)) {
ballColor = r.LIME
}
else if (r.IsMouseButtonPressed(r.MOUSE_RIGHT_BUTTON)) {
ballColor = r.DARKBLUE
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
r.BeginDrawing()
r.ClearBackground(r.RAYWHITE)
r.DrawCircleV(ballPosition, 40, ballColor)
r.DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, r.DARKGRAY)
r.EndDrawing()
//----------------------------------------------------------------------------------
}
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800
const screenHeight = 450
r.InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input")
var ballPosition = r.Vector2(-100, -100)
var ballColor = r.DARKBLUE
r.SetTargetFPS(60)
//---------------------------------------------------------------------------------------
// Main game loop
while (!r.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
ballPosition = r.GetMousePosition()
if (r.IsMouseButtonPressed(r.MOUSE_LEFT_BUTTON)) {
ballColor = r.MAROON
}
else if (r.IsMouseButtonPressed(r.MOUSE_MIDDLE_BUTTON)) {
ballColor = r.LIME