NAME

Game::Floppy::Raylib - Floppy in a window, when raylib is there

VERSION

Version 0.10

SYNOPSIS

use Game::Floppy::Raylib;

if (Game::Floppy::Raylib->available) {
    my $result = Game::Floppy::Raylib->new(seed => 'anything')->start;
}
else {
    warn Game::Floppy::Raylib->why_not;
}

Or, from a shell:

floppy --raylib

DESCRIPTION

The window of release 0.08, drawn from the same three sprites at the same size, with the engine and the bot of this release behind it. Raylib::FFI is loaded when the window is asked for, never when this module is, so the module compiles and the distribution's tests run on a machine without raylib. Raylib::FFI itself needs perl 5.38 or later; the rest of this distribution does not. Loading it prints a warning that builtin::export_lexically is experimental and one for each raylib function the installed library lacks; those are its, not ours, and cannot be silenced from here. Raylib also logs to the terminal of its own accord.

The window runs at twenty frames a second and ticks the engine once a frame, which is exactly 0.08's loop. Space, up, Enter, w and k flap, as does a mouse release; p pauses; q, Escape or closing the window quits; after a death, space or a click plays again.

0.08 drew its pipes 20 pixels inside the gap it collided with and its bird from the top-left corner of the circle it collided with. The engine transcribes the collision; this module draws 0.08's picture over it, so the window looks and plays as 0.08 did. The inset is one constant, inset.

CLASS METHODS

available, why_not

Whether Raylib::FFI and Raylib::Color can be loaded, and one sentence on why not, with no file and line in it.

frame_for, source_for

my $frame = Game::Floppy::Raylib->frame_for($game->ticks);    # 0 .. 3
my ($x, $y, $w, $h) = @{ Game::Floppy::Raylib->source_for($frame) };

The bird's frame for a tick count, cycling through the four on the sheet, and the sheet rectangle for a frame.

pipe_at

my $at = Game::Floppy::Raylib->pipe_at($tube);    # { top => [x, y, 180], bottom => [x, y, 0] }

Where the two pipe sprites are drawn for a tube of "tubes" in Game::Floppy, with their rotation: the top pipe rotated 180 about its drawn corner, as 0.08 drew it, 20 pixels inside each lip of the collision gap.

key_for

The name of a key code: flap, pause, quit or undefined.

sheet, sprite_size, inset

The path of a sprite (background, bird or pipe), its size in pixels, and the inset.

METHODS

new

Game::Floppy::Raylib->new(seed => '...', level => 3, watch => 0, fps => 20, title => 'Floppy', max_ticks => 0);

Every argument has a default, shown. A missing seed is made fresh.

start

Opens the window, plays until a quit or the cap, closes the window and returns the last game's Game::Floppy::Result, or undefined when raylib is not available.

seed, level, watch, fps, title, max_ticks, game, clock, ticker, frames, refused, best

The arguments, the game, the clock and the ticker, and the counts.

AUTHOR

LNATION, <email at lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2024 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)