Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800
const screenHeight = 450
r.InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing")
r.InitAudioDevice() // Initialize audio device
const fxWav = r.LoadSound(__dirname + "/resources/sound.wav") // Load WAV audio file
const fxOgg = r.LoadSound(__dirname + "/resources/tanatana.ogg") // Load OGG audio file
r.SetTargetFPS(60) // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!r.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (r.IsKeyPressed(r.KEY_SPACE)) r.PlaySound(fxWav) // Play WAV sound
if (r.IsKeyPressed(r.KEY_ENTER)) r.PlaySound(fxOgg) // Play OGG sound
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
const screenHeight = 450;
r.InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free")
// Define the camera to look into our 3d world
const camera = r.Camera(
r.Vector3(10, 10, 10),
r.Vector3(0, 0, 0),
r.Vector3(0, 1, 0),
45,
r.CAMERA_PERSPECTIVE
)
const cubePosition = r.Vector3()
let cubeScreenPosition = r.Vector2()
r.SetCameraMode(camera, r.CAMERA_FREE); // Set a free camera mode
r.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
const screenHeight = 450;
r.InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
const image = r.LoadImage(__dirname + "/resources/raylib_logo.png"); // Loaded in CPU memory (RAM)
// TODO: Fix thrown exception
// INFO: [/home/rob/Documents/node-raylib/examples/textures/resources/raylib_logo.png] Image loaded successfully (256x256)
// terminate called after throwing an instance of 'char const*'
// [1] 26364 abort (core dumped) bin/node-raylib examples/textures/textures_image_loading.js
const texture = r.LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM)
r.UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
//---------------------------------------------------------------------------------------
// Main game loop
while (!r.WindowShouldClose()) // Detect window close button or ESC key
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800
const screenHeight = 450
r.InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards")
// Define the camera to look into our 3d world
const camera = r.Camera()
camera.position = r.Vector3(5.0, 4.0, 5.0)
camera.target = r.Vector3(0.0, 2.0, 0.0)
camera.up = r.Vector3(0.0, 1.0, 0.0)
camera.fovy = 45.0
camera.type = r.CAMERA_PERSPECTIVE
const bill = r.LoadTexture(__dirname + "/resources/billboard.png") // Our texture billboard
const billPosition = r.Vector3(0.0, 2.0, 0.0) // Position where draw billboard
r.SetCameraMode(camera, r.CAMERA_ORBITAL) // Set an orbital camera mode
r.SetTargetFPS(60) // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800
const screenHeight = 450
r.InitWindow(screenWidth, screenHeight, 'raylib [shapes] example - basic shapes drawing')
r.SetTargetFPS(60)
//--------------------------------------------------------------------------------------
// Main game loop
while (!r.WindowShouldClose()) {
// Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
r.BeginDrawing()
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
const MAX_COLUMNS = 20
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
const screenHeight = 450;
r.InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
// Define the camera to look into our 3d world (position, target, up vector)
const camera = r.Camera(
r.Vector3(4, 2, 4),
r.Vector3(0, 1.8, 0),
r.Vector3(0, 1, 0),
60,
r.CAMERA_PERSPECTIVE
);
// Generates some random columns
const heights = []
const positions = []
const colors = []
for (let i = 0; i < MAX_COLUMNS; i++)
*
* This game has been created using raylib (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
// Initialization (Note windowTitle is unused on Android)
//--------------------------------------------------------------------------------------
const screenWidth = 800
const screenHeight = 450
r.InitWindow(screenWidth, screenHeight, "raylib template - simple game")
var currentScreen = 'LOGO'
// TODO: Initialize all required variables and load all required data here!
var framesCounter = 0 // Useful to count frames
r.SetTargetFPS(60) // Set desired framerate (frames-per-second)
//--------------------------------------------------------------------------------------
// Main game loop
while (!r.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
switch(currentScreen)
{
// Constants
const { DISPLAY_HEIGHT, DISPLAY_WIDTH } = require('../data/constants')
const nativeKeyMap = require('../data/nativeKeyMap')
const multiplier = 10
const screenWidth = DISPLAY_WIDTH * multiplier
const screenHeight = DISPLAY_HEIGHT * multiplier
// Instantiation
const cpu = new CPU(cpuInterface)
const romBuffer = new RomBuffer(fileContents)
const cpuInterface = new NativeCpuInterface()
cpu.load(romBuffer)
r.InitWindow(screenWidth, screenHeight, 'Chip8.js')
r.SetTargetFPS(60)
r.ClearBackground(r.BLACK)
let timer = 0
while (!r.WindowShouldClose()) {
timer++
if (timer % 5 === 0) {
cpu.tick()
timer = 0
}
// Interpret key data
const rawKeyPressed = r.GetKeyPressed()
const keyIndex = nativeKeyMap.findIndex(key => rawKeyPressed === key)
*
* 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)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800
const screenHeight = 450
r.InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values")
var framesCounter = 0 // Variable used to count frames
var randValue = r.GetRandomValue(-8, 5) // Get a random integer number between -8 and 5 (both included)
r.SetTargetFPS(60) // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!r.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
framesCounter++
// Every two seconds (120 frames) a new random value is generated
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
const r = require('raylib')
const MAX_BUILDINGS = 100
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800
const screenHeight = 450
r.InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera")
const player = r.Rectangle(400, 280, 40, 40)
const buildings = []
const buildColors = []
let spacing = 0;
for (let i = 0; i < MAX_BUILDINGS; i++)
{
let height = r.GetRandomValue(100, 800)
let newBuilding = r.Rectangle(
-6000 + spacing,
screenHeight - 130 - height,
r.GetRandomValue(50, 200),
height
)