### Build and Run Voord C++ App Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Commands to build the Voord C++ application using make and deploy it to a NumWorks calculator. It includes installing necessary dependencies like the ARM toolchain and Node.js. ```shell # Install dependencies (macOS) brew install numworks/tap/arm-none-eabi-gcc node # Build the application make # Output: target/voord.nwa # Install on connected calculator make run ``` -------------------------------- ### Build and Run Sample App (Shell) Source: https://github.com/numworks/epsilon-sample-app-cpp/blob/master/README.md Commands to build and run the sample C++ application on a NumWorks calculator. It requires the embedded ARM toolchain and Node.js. The build process uses 'make', and running the app locally is done via 'make run' after connecting the calculator via USB. ```shell brew install numworks/tap/arm-none-eabi-gcc node # Or equivalent on your OS make ``` ```shell # Now connect your NumWorks calculator to your computer using the USB cable make run ``` -------------------------------- ### Epsilon App Entry Point and Game Loop (C++) Source: https://github.com/numworks/epsilon-sample-app-cpp/blob/master/README.md The main entry point for the Epsilon application. It initializes the display by filling it with black and then enters an infinite loop to continuously check for keyboard input and update the game scene. It uses the EADK library for display and keyboard interactions. ```cpp using namespace EADK; void eadk_main() { Display::pushRectUniform( Display::Rect(0, 0, 320, 240), Display::Color(0x000000) ); while (1) { Keyboard::State kbd = Keyboard::scan(); if (kbd.keyDown(Keyboard::Key::OK)) { spaceship.createRockets(); } if (kbd.keyDown(Keyboard::Key::Up)) { spaceship.move(0, -Spaceship::k_step); } refreshScene(); } } ``` -------------------------------- ### Handle Keyboard Input with EADK::Keyboard::scan and State::keyDown (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Demonstrates capturing keyboard input using EADK::Keyboard::scan and checking individual key states with State::keyDown. This is crucial for controlling game elements like the spaceship. ```cpp #include "eadkpp.h" // Main game input loop while (1) { EADK::Keyboard::State keyboardState = EADK::Keyboard::scan(); // Check directional keys if (keyboardState.keyDown(EADK::Keyboard::Key::Up)) { spaceship.move(0, -10); // Move up } if (keyboardState.keyDown(EADK::Keyboard::Key::Down)) { spaceship.move(0, 10); // Move down } if (keyboardState.keyDown(EADK::Keyboard::Key::Left)) { spaceship.move(-10, 0); // Move left } if (keyboardState.keyDown(EADK::Keyboard::Key::Right)) { spaceship.move(10, 0); // Move right } // Fire rockets with OK button if (keyboardState.keyDown(EADK::Keyboard::Key::OK)) { spaceship.createRockets(); } EADK::Timing::msleep(20); // Frame delay } ``` -------------------------------- ### Define Application Metadata for NumWorks Loader (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Specifies the application name and API level, which are essential for the NumWorks app loader to recognize and load the application. These must be defined in `main.cpp` and placed in specific read-only data sections. ```cpp // Required in main.cpp - defines app metadata for NumWorks loader extern const char eadk_app_name[] __attribute__((section(".rodata.eadk_app_name"))) = "Voord"; extern const uint32_t eadk_api_level __attribute__((section(".rodata.eadk_api_level"))) = 0; // Main entry point int main(int argc, char * argv[]) { // Initialize display EADK::Display::pushRectUniform(EADK::Screen::Rect, EADK::Color(0x000000)); // Game initialization and main loop... return 0; } ``` -------------------------------- ### Complete C++ Game Loop for NumWorks Calculators Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt This C++ code implements a complete game loop for NumWorks calculators using the EADK. It initializes game entities like aliens and a spaceship, handles keyboard input for movement and actions, updates game elements based on timers, and manages the spawning of new aliens. The loop includes frame timing using `EADK::Timing::msleep`. ```cpp #include "alien.h" #include "display.h" #include "eadkpp.h" #include "palette.h" #include "spaceship.h" extern const char eadk_app_name[] __attribute__((section(".rodata.eadk_app_name"))) = "Voord"; extern const uint32_t eadk_api_level __attribute__((section(".rodata.eadk_api_level"))) = 0; int main(int argc, char * argv[]) { // Clear screen to black EADK::Display::pushRectUniform(EADK::Screen::Rect, Black); // Initialize game entities constexpr int k_maxNumberOfAliens = 10; Alien aliens[k_maxNumberOfAliens]; Spaceship spaceship; // Timing counters int rocketTimer = 0; int alienStepTimer = 0; int alienMaterializationTimer = 0; // Main game loop while (1) { // Handle input EADK::Keyboard::State keyboardState = EADK::Keyboard::scan(); if (keyboardState.keyDown(EADK::Keyboard::Key::OK)) { spaceship.createRockets(); } if (keyboardState.keyDown(EADK::Keyboard::Key::Up)) { spaceship.move(0, -Spaceship::k_step); } if (keyboardState.keyDown(EADK::Keyboard::Key::Down)) { spaceship.move(0, Spaceship::k_step); } // Update rockets if (rocketTimer == Rocket::k_period) { rocketTimer = 0; spaceship.rocketsAction(aliens, k_maxNumberOfAliens); } // Update aliens if (alienStepTimer == Alien::k_stepPeriod) { alienStepTimer = 0; for (int i = 0; i < k_maxNumberOfAliens; i++) { aliens[i].step(); } } // Spawn new aliens if (alienMaterializationTimer == Alien::k_materializationPeriod) { alienMaterializationTimer = 0; for (int i = 0; i < k_maxNumberOfAliens; i++) { if (aliens[i].isGhost()) { aliens[i] = Alien( Display::CommonHorizontalMargin + (float)EADK::random() / (float)0xFFFFFFFF * (EADK::Screen::Width - 2 * Display::CommonHorizontalMargin) ); break; } } } // Frame timing EADK::Timing::msleep(20); rocketTimer++; alienStepTimer++; alienMaterializationTimer++; } } ``` -------------------------------- ### Draw Uniform Rectangles with EADK::Display::pushRectUniform (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Demonstrates using EADK::Display::pushRectUniform to fill rectangular areas with a solid color. This function is used for clearing the screen, drawing background elements, and erasing game objects. ```cpp #include "eadkpp.h" // Clear the entire screen to black EADK::Display::pushRectUniform(EADK::Screen::Rect, EADK::Color(0x000000)); // Draw a yellow rectangle at position (100, 50) with width 35 and height 20 EADK::Display::pushRectUniform( EADK::Rect(100, 50, 35, 20), EADK::Color(0xF3B443) // Yellow ); // Clear a specific region (erase an entity by drawing black over it) EADK::Display::pushRectUniform( EADK::Rect(m_x - k_width/2, m_y - k_height/2, k_width, k_height), EADK::Color(0x000000) // Black ); ``` -------------------------------- ### Draw Custom Pixel Rectangles with EADK::Display::pushRect (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Illustrates using EADK::Display::pushRect to render rectangular areas with custom pixel data from an array. This is suitable for drawing sprites and complex graphical elements. ```cpp #include "eadkpp.h" // Define a 3x3 pixel sprite constexpr EADK::Color sprite[9] = { EADK::Color(0xFF0000), EADK::Color(0x00FF00), EADK::Color(0x0000FF), EADK::Color(0x00FF00), EADK::Color(0xFFFFFF), EADK::Color(0x00FF00), EADK::Color(0x0000FF), EADK::Color(0x00FF00), EADK::Color(0xFF0000) }; // Draw the sprite at position (50, 50) EADK::Display::pushRect( EADK::Rect(50, 50, 3, 3), sprite ); // Heart sprite example (11x9 pixels) from the game constexpr EADK::Color k_heart[Life::k_height * Life::k_width] = { EADK::Color(0x000000), EADK::Color(0xFC7F81), EADK::Color(0xFC7F81), // ... // Full pixel array for heart shape }; EADK::Display::pushRect( EADK::Rect(m_x - k_width/2, m_y - k_height/2, k_width, k_height), k_heart ); ``` -------------------------------- ### Spaceship Class Implementation (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Represents the player-controlled spaceship, handling its movement, firing rockets, collision detection, and life management. It can be moved, rockets can be launched, and its state can be updated based on game events. It also provides methods to access its position and check its game-over status. ```cpp #include "spaceship.h" // Initialize spaceship (starts at center-bottom of screen with 3 lives) Spaceship spaceship; // Move spaceship with bounds checking spaceship.move(-10, 0); // Move left by 10 pixels spaceship.move(0, -10); // Move up by 10 pixels // Fire rockets (launches 3 rockets from left, center, right positions) spaceship.createRockets(); // Update rockets and check collisions each frame spaceship.rocketsAction(aliens, k_maxNumberOfAliens); // Check if rockets hit any aliens (increments score on hit) spaceship.checkForRocketsAliensCollisions(aliens, k_maxNumberOfAliens); // Access spaceship position int x = spaceship.x(); // Current X coordinate int y = spaceship.y(); // Current Y coordinate // Handle spaceship being hit (flashes red, decrements lives) bool gameOver = spaceship.hit(); // Returns true if all lives lost ``` -------------------------------- ### Display Text with EADK::Display::drawString (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Shows how to render text on the screen using EADK::Display::drawString. This function supports custom positioning, font sizes, and colors for displaying game information like scores or messages. ```cpp #include "eadkpp.h" // Draw score text (large font, white on black) EADK::Display::drawString( "0042", EADK::Point(EADK::Screen::Width - 60, 40), true, // large font EADK::Color(0xFFFFFF), // text color (white) EADK::Color(0x000000) // background color (black) ); // Draw "Well done" victory message (centered) EADK::Display::drawString( "Well done", EADK::Point( (EADK::Screen::Width - 9 * 10) / 2, // center horizontally (EADK::Screen::Height - 18) / 2 // center vertically ), true, EADK::Color(0x000000), // black text EADK::Color(0xF3B443) // yellow background ); ``` -------------------------------- ### Alien Class Implementation (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Defines enemy entities that spawn at the top of the screen and move downwards. Aliens can be destroyed by rockets or damage the spaceship upon collision. The class provides methods for movement, checking status (e.g., 'isGhost'), handling damage, and accessing position. ```cpp #include "alien.h" // Create alien at specific X position (spawns at top of screen) Alien alien(160); // Center of 320-pixel wide screen // Create inactive "ghost" alien (placeholder in array) Alien ghostAlien(-1); // Move alien downward by step amount alien.step(); // Moves down by 10 pixels, becomes ghost if off-screen // Check if alien is inactive if (alien.isGhost()) { // Alien slot is available for spawning } // Check collision with spaceship if (alien.tryToHit(&spaceship)) { // Alien hit spaceship - game over if no lives left } // Kill alien (called when rocket hits) alien.killed(); // Flashes green, then becomes ghost // Access alien position int x = alien.x(); int y = alien.y(); ``` -------------------------------- ### Pause Execution with EADK::Timing::msleep (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Pauses the program's execution for a specified duration in milliseconds. Useful for controlling game loops, frame rates, and creating timed visual effects. It takes an integer representing milliseconds as input. ```cpp #include "eadkpp.h" // Main game loop with 20ms frame delay (50 FPS target) while (1) { // Process input and update game state... EADK::Timing::msleep(20); } // Flashing hit effect animation for (int i = 0; i < 5; i++) { draw(EADK::Color(0xFF0000)); // Flash red EADK::Timing::msleep(10); draw(EADK::Color(0xF3B443)); // Return to yellow EADK::Timing::msleep(10); } ``` -------------------------------- ### Rocket Class Implementation (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Represents projectiles fired by the spaceship that travel upwards to destroy aliens. Rockets are managed by the Spaceship class but have methods to set their location, move them forward, check if they are inactive ('off'), and attempt to destroy an alien. Their position can also be accessed. ```cpp #include "rocket.h" // Rockets are managed by Spaceship, but here's how they work: Rocket rocket; // Launch rocket at position rocket.setLocation(160, 200); // X=160, Y=200 // Move rocket forward (upward) rocket.forward(); // Moves up by 13 pixels // Check if rocket is inactive if (rocket.off()) { // Rocket is available for reuse } // Try to kill an alien if (rocket.tryToKill(&alien)) { // Rocket destroyed the alien // Rocket is automatically switched off } // Access position int x = rocket.x(); int y = rocket.y(); ``` -------------------------------- ### Generate Random 32-bit Unsigned Integer with EADK::random (C++) Source: https://context7.com/numworks/epsilon-sample-app-cpp/llms.txt Generates a random 32-bit unsigned integer. This function is used for introducing randomness in game mechanics, such as determining spawn positions for enemies. The output is a raw integer that can be normalized. ```cpp #include "eadkpp.h" // Spawn alien at random X position within screen bounds int marginX = 20; // CommonHorizontalMargin float randomFactor = (float)EADK::random() / (float)0xFFFFFFFF; // Normalize to 0.0-1.0 int spawnX = marginX + randomFactor * (EADK::Screen::Width - 2 * marginX); Alien newAlien(spawnX); // Example: Random spawn within game area for (int i = 0; i < k_maxNumberOfAliens; i++) { if (aliens[i].isGhost()) { aliens[i] = Alien( Display::CommonHorizontalMargin + (float)EADK::random() / (float)0xFFFFFFFF * (EADK::Screen::Width - 2 * Display::CommonHorizontalMargin) ); break; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.