Crate babalcore[][src]

Structs

FakeInput

A fake input used for tests, to simulate user inputs.

InputJump

Used to handle jump input. This is to encapsulate all the nitty-picky logic about considering a button is still pressed a fraction of seconds after it has been pressed, etc. It does not actually poll and/or listens to the real hardware, it just keeps track of what's happening with push/pop operations.

InputSteer

An object to tract steering, that is, going left, or going right. This does not actually poll/reacts to the physical controllers, it just collects "go right" or "go left" informations then aggregates and consolidates them.

Level

Contains the level definition, where are slabs, and of what type.

Player
PlayerEvent
PointsCounter
Row
Slab
TimeTracker

Enums

PlayerEventKind

Events which can be triggered by the player.

Skill

Different skills.

SlabDef

Different defs of slabs (those rectangles the ball can roll on). A def is what defines a slab, it will be translated into a kind at runtime. Typically some defs can be "a random slab", or even "a slab that varies with time", etc.

SlabKind

Different kind of slabs (those rectangles the ball can roll on).

Constants

ABSOLUTE_LENGTH_MAX

Indices for rows can not be bigger than this. It is insanely big though, at 100 slabs per sec, it represents 1 million seconds, which is more than 10 days of continuous play.

BASE_KEYBOARD_ACC_VALUE

When first pressing a key, this value is put in the accumulator. This is to avoid waiting for the first repeat to actually do something.

DEFAULT_KEYBOARD_SENSIBILITY

Keyboard sensibility, one way to think of it is "how many pixels should be a corresponding mouse move, if it lasted 1 second". So moving the mouse of 1000 pixels in 1 second is equivalent to keeping a move arrow pressed for 1 second. Setting it to negative value will invert keyboard.

DEFAULT_MOUSE_SENSIBILITY

Default mouse sensibility, as this is an arbitrary unit, default is 1. Setting it to a negative value will invert mouse.

DEFAULT_STICKINESS_SECS_F64

By default, the stickiness is set to a bit more than 1/10th of a second. This means that if player pushes a jump control less than 1/10th of a second before it can actually jump, the jump is still recorded as valid.

INTENSITY_MAX

Maximum intensity.

INTENSITY_MIN

Minimum intensity.

MAX_ITEM
PLAYER_EVENT_BOOST
PLAYER_EVENT_CATCH_UP
PLAYER_EVENT_CHANGE_COLUMN
PLAYER_EVENT_FALL
PLAYER_EVENT_FINISH
PLAYER_EVENT_HIGH_SCORE
PLAYER_EVENT_JUMP
PLAYER_EVENT_LAND
PLAYER_EVENT_OVERDRIVE
PLAYER_EVENT_PERCENT_TIME
PLAYER_EVENT_START
PLAYER_EVENT_THOUSAND_SCORE
SLIDING_LENGTH_MAX

History about one level will be kept only below this limit. Above it, the initial slabs will disappear. This should really not be a problem as for a complete restart, we can reinitialize with a seed, and otherwise it stills allows going back in time by 10k slabs, which means several minutes even at high speed.

TIME_TRACKER_MAX_SEC

Maximum number of seconds we can track. This is related to the limit of a mantissa in 64-bit IEEE numbers, which is about 10^15. Since we count in msec, we have to divide to take away 3 digits. This is still several centuries.

WIDTH_MAX

A maximum width, most playable values should range from 6 to 12, so 32 is already a lot. To simplify/optimize code, program uses fixed size rows, set to the WIDTH_MAX. With slabs of 4 or 8 bytes, it means only 256 bytes (worst case) for a row. With this setting, a 10_000 rows level, playable for about an hour, at 3 slabs/sec still fits into 30Mb of memory.

Traits

InputQuery

A trait to abstract the input query interface, it is mostly used for testing the game logic without having real inputs.

LevelQuery

Functions

boxcar

Boxcar function as defined here: https://en.wikipedia.org/wiki/Boxcar_function With A=1, a=0, b=1, so it is 0 if x<0, 1 if x>0 and x<1 an 1 if x>1.

fade_in

Fade in func, 0 if x<0, linear between 0 and 1, 1 if x>0.

fade_out

Fade out func, 1 if x<0, linear between 0 and 1, 0 if x>0.

format_type_of

Return a string describing the type.

generate_first_row
generate_next_row
heaviside_step

Heavyside step function as defined here: https://en.wikipedia.org/wiki/Heaviside_step_function It is 1 is x > 0, and 0 if x < 0.

pulse

Pulse func as defined here: https://en.wikipedia.org/wiki/Pulse_wave The global period is 1, the alpha value can be used to control the ratio between 1s and 0s.

sawtooth_wave

Sawtooth wave func as defined here: https://en.wikipedia.org/wiki/Sawtooth_wave It alternates between values of -1 and 1, with a global period of 1. It switches between them at x == 0.5.

sine_wave

Sine wave func as defined here: https://en.wikipedia.org/wiki/Sine_wave It's a simple sinusoid, only this one has a period of 1 instead of 2PI. The idea is to be able to use it as a drop in for triangle_wave for instance, without introducing a 2*PI factor. If you want a real sin, just use the builtin func.

square_wave

Square wave func as defined here: https://en.wikipedia.org/wiki/Square_wave It alternates between values of -1 and 1, with a global period of 1. It switches between them at x == 0.5.

triangle_wave

Triangle wave func as defined here: https://en.wikipedia.org/wiki/Triangle_wave It alternates between values of -1 and 1, with a global period of 1. It switches between them at x == 0.5.

unwrap_now

Return the time contained in the option if it is defined. If not (None was passed) returns the result of an actual call to Instant::now(). This is useful for testing: in mainstream production code, just pass None, but for testing it is possible to pass fake instants.