49 lines
1.8 KiB
Rust
49 lines
1.8 KiB
Rust
//! configuration for constants used within the game
|
|
|
|
// aspect ratio of the screen (height / width)
|
|
const SCREEN_ASPECT_RATIO: f32 = 600.0 / 800.0;
|
|
// width and height of enemies in pixels
|
|
const ENEMY_WIDTH_PX: f32 = 12.0;
|
|
const ENEMY_HEIGHT_PX: f32 = 8.0;
|
|
|
|
// how many rows / columns of enemies to draw
|
|
pub const ENEMY_ROWS: usize = 3;
|
|
pub const ENEMY_COLS: usize = 6;
|
|
// space in between enemies
|
|
pub const ENEMY_DISTANCE: f32 = 12.0;
|
|
// size of each pixel of the enemy texture
|
|
pub const ENEMY_PIXEL_SIZE: f32 = 0.01;
|
|
// width and height of an enemy
|
|
pub const ENEMY_WIDTH: f32 = ENEMY_WIDTH_PX * SCREEN_ASPECT_RATIO;
|
|
pub const ENEMY_HEIGHT: f32 = ENEMY_HEIGHT_PX;
|
|
// horizontal and vertical enemy movement speed
|
|
pub const ENEMY_SPEED: f32 = 0.2;
|
|
pub const ENEMY_SPEED_VERT: f32 = 0.03;
|
|
// maximum horizontal enemy offset
|
|
pub const ENEMY_CLAMP: f32 = 0.25;
|
|
// distance from one enemy to the next enemy (respective to their center points)
|
|
pub const ENEMY_COL_SKIP: f32 = (ENEMY_WIDTH + ENEMY_DISTANCE) * ENEMY_PIXEL_SIZE;
|
|
pub const ENEMY_ROW_SKIP: f32 = (ENEMY_HEIGHT + ENEMY_DISTANCE) * ENEMY_PIXEL_SIZE;
|
|
// where to place the top-left enemy
|
|
pub const ENEMY_OFFSET_TOP: f32 = 0.7;
|
|
pub const ENEMY_OFFSET_LEFT: f32 = ENEMY_PIXEL_SIZE
|
|
* -((ENEMY_COLS as f32 / 2.0) * (ENEMY_WIDTH + ENEMY_DISTANCE) - ENEMY_DISTANCE);
|
|
|
|
// speed of the player
|
|
pub const PLAYER_SPEED: f32 = 0.8;
|
|
// maximum / minimum player x-coordinate
|
|
pub const PLAYER_CLAMP: f32 = 0.8;
|
|
// width and height of the player
|
|
pub const PLAYER_WIDTH: f32 = 0.12;
|
|
pub const PLAYER_HEIGHT: f32 = PLAYER_WIDTH * (8.0 / 12.0) / SCREEN_ASPECT_RATIO;
|
|
// y-coordinate of player
|
|
pub const PLAYER_OFFSET_BOTTOM: f32 = -0.8;
|
|
|
|
// width and height of bullets
|
|
pub const BULLET_WIDTH: f32 = 0.01;
|
|
pub const BULLET_HEIGHT: f32 = 0.05;
|
|
// bullet speed
|
|
pub const BULLET_SPEED: f32 = 1.5;
|
|
// time between shots
|
|
pub const BULLET_DELAY: f32 = 500.0;
|