Skip to content

Commit

Permalink
cleanup; wasm build
Browse files Browse the repository at this point in the history
  • Loading branch information
bayou-brogrammer committed Oct 13, 2022
1 parent d081bc3 commit 51070e4
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ for:
mkdir forgotten
mv dist forgotten/$APPVEYOR_REPO_BRANCH
mv dist forgotten/$v
zip -r forgotten.zip forgotten
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "v*.*.*"

env:
PUBLIC_URL: /lecoqjacob/blood-oath-bevy
PUBLIC_URL: forgotten-7drl

jobs:
setup:
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/release-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "v*.*.*"

env:
RELEASE_NAME: my_game
RELEASE_NAME: forgotten
PUBLIC_URL: /bevy-shell-template/

jobs:
Expand All @@ -30,6 +30,7 @@ jobs:
run: |
cd ./launchers/native
cargo build --release
- name: Rename
run: |
mv ./target/release/native-launcher.exe ./${{ env.RELEASE_NAME }}.exe
Expand All @@ -55,19 +56,23 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build
run: |
cd ./launchers/native
cargo build --release
- name: Rename
run: |
mv ./target/release/native-launcher ./${{ env.RELEASE_NAME }}
- name: Zip release
uses: vimtor/action-zip@v1
with:
files: assets/ ./${{ env.RELEASE_NAME }}
recursive: false
dest: ./${{ env.RELEASE_NAME }}-${{ needs.setup.outputs.version }}-darwin.zip

- name: Upload
uses: softprops/action-gh-release@v1
with:
Expand All @@ -82,22 +87,27 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get dependencies
run: |
sudo apt install libasound2-dev libudev-dev pkg-config
- name: Build
run: |
cd ./launchers/native
cargo build --release
- name: Rename
run: |
mv ./target/release/native-launcher ./${{ env.RELEASE_NAME }}
- name: Zip release
uses: vimtor/action-zip@v1
with:
files: assets/ ./${{ env.RELEASE_NAME }}
recursive: false
dest: ./${{ env.RELEASE_NAME }}-${{ needs.setup.outputs.version }}-ubuntu.zip

- name: Upload
uses: softprops/action-gh-release@v1
with:
Expand Down
8 changes: 4 additions & 4 deletions Trunk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ target = "launchers/wasm/index.html"
# Watch top level dir (all crates)
watch = ["app", "forgotten", "launchers/wasm/src", "launchers/wasm/index.html"]

[[hooks]]
command = "cp"
command_arguments = ["-r", "audio-data", "launchers/wasm/"]
stage = "pre_build"
# [[hooks]]
# command = "cp"
# command_arguments = ["-r", "audio-data", "launchers/wasm/"]
# stage = "pre_build"
10 changes: 9 additions & 1 deletion app/src/controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,18 @@ impl Default for Controls {
];

let gamepad = btreemap![
// Action Keys
GamepadButton::North => AppInput::Get,
GamepadButton::Select => AppInput::Wait,
GamepadButton::RightBumper => AppInput::Examine,
// Movement Input
GamepadButton::LeftBumper => AppInput::Descend,

// Slot Keys
GamepadButton::West => AppInput::Slot(RangedWeaponSlot::Slot1),
GamepadButton::South => AppInput::Slot(RangedWeaponSlot::Slot2),
GamepadButton::East => AppInput::Slot(RangedWeaponSlot::Slot3),

// Movement Keys
GamepadButton::DPadLeft => AppInput::Direction(CardinalDirection::West),
GamepadButton::DPadRight => AppInput::Direction(CardinalDirection::East),
GamepadButton::DPadUp => AppInput::Direction(CardinalDirection::North),
Expand Down
4 changes: 1 addition & 3 deletions app/src/render/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ pub fn terrain_renderable(scope: &StateScope, tile: Tile, coord: Coord) -> Rende
let is_wall_below = scope.0.is_wall_known_at(coord + Coord::new(0, 1));
wall_renderable(tile, is_wall_below)
}
Tile::Reactor => {
RenderCell::BLANK.with_character('₪').with_background(LIGHT_GREY).with_foreground(REACTOR)
}
Tile::Reactor => RenderCell::BLANK.with_character('☼').with_foreground(REACTOR),
Tile::Stairs => RenderCell::BLANK.with_character('>').with_foreground(STAIRS),
_ => unreachable!("Tried to render a non-terrain tile as terrain: {:?}", tile),
}
Expand Down
54 changes: 52 additions & 2 deletions app/src/render/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,61 @@ pub fn prologue(width: u32) -> AppCF<()> {
}

pub fn help(width: u32) -> AppCF<()> {
text_component(width, vec![bold("Combat\n")])
text_component(
width,
vec![
bold("Combat\n"),
plain("Each weapon has a DMG(♥) and PEN(♦) stat, and each enemy has heatlh(♥) and armour(♦). "),
plain(
"If an enemy is hit with a weapon that has a higher PEN than their armour, their health is ",
),
plain(
"reduced by the weapon's DMG. If a projectile's PEN exceeds an enemy's armour, it continues ",
),
plain("on its path with its PEN reduced by the enemy's armour.\n\n"),
// Enemies
bold("Enemies\n"),
plain("Minibot - basic guard robot\n"),
plain("SecBot - upgraded minibot\n"),
plain("RoboCop - elite guard robot. Alerts nearby robots when it sees you.\n"),
plain("Doom Bot - Kill bot. Very hard to kill. Explodes on death\n\n"),
// Keys
bold("Default Keyboard Controls\n"),
plain("Movement/Aim: Arrows/WASD/HJKL\n"),
plain("Cancel Aim: Escape\n"),
plain("Wait: Space\n"),
plain("Examine: X\n"),
plain("Descend: Period\n"),
plain("Get Weapon: G\n"),
plain("Fire Ranged Weapon: 1-3\n\n"),
// Gamepad
bold("Default Gamepad Controls\n"),
plain("Movement/Aim: D-Pad\n"),
plain("Cancel Aim: Select\n"),
plain("Wait: Select\n"),
plain("Examine: Right Bumper\n"),
plain("Descend: Left Bumper\n"),
plain("Get Weapon: Y/Triangle\n"),
plain("Fire Ranged Weapon Slot 1: X/Square\n"),
plain("Fire Ranged Weapon Slot 2: A/Cross\n"),
plain("Fire Ranged Weapon Slot 2: B/Circle\n"),
faint("\n\n\n\n\nPress any key..."),
],
)
}

pub fn epilogue1(width: u32) -> AppCF<()> {
text_component(width, vec![])
text_component(
width,
vec![
norm(
"As you watch the reactor explode, you feel a sense of relief. You have done your part.
You have saved humanity.\n\n",
),
norm("You pickup your radio and radio in \"Mission Acomplished.\"....\n\n....*static*"),
faint("\n\n\n\nPress any key..."),
],
)
}

pub fn epilogue(width: u32) -> AppCF<()> {
Expand Down
3 changes: 3 additions & 0 deletions app/src/render/ui/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ impl Component for Log {
Message::DoomBotExplodes => {
vec![plain("The "), enemy_text(NpcType::DoomBot), plain(" self destructs!")]
}
Message::AlertedNearbyEntities => {
vec![plain("The "), enemy_text(NpcType::RoboCop), plain(" is alerting nearby robots!")]
}

// Player
Message::PlayerHitEnemy { enemy, weapon } => {
Expand Down
6 changes: 3 additions & 3 deletions forgotten/src/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ impl Game {

self.run_systems();

if self.is_game_over() && self.win_countdown.is_none() {
Some(ControlFlow::GameOver)
} else if self.is_won() {
if self.is_won() {
self.win_countdown = Some(Duration::from_secs(2));
None
} else if self.is_game_over() && self.win_countdown.is_none() {
Some(ControlFlow::GameOver)
} else {
None
}
Expand Down
2 changes: 0 additions & 2 deletions forgotten/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![warn(clippy::all, clippy::nursery)]

mod ai;
mod behavior;
mod flow;
Expand Down
1 change: 1 addition & 0 deletions forgotten/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum Message {
TakeCredit(u32),
EnemyDies(NpcType),
EnemyStunned(NpcType),
AlertedNearbyEntities,
EnemyHitPlayer(NpcType),
EquipWeapon(WeaponType),
EnemySlammedIntoWall(NpcType),
Expand Down
10 changes: 5 additions & 5 deletions forgotten/src/terrain/levels/first_floor.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#########
#......R#
#@.....>#
#..r...R#
#########
##########
#......R.#
#@.....>.#
#......R.#
##########
3 changes: 2 additions & 1 deletion forgotten/src/terrain/levels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ pub fn first_floor() -> Terrain {
const LEVEL: u8 = 0;

let grid = procgen::generate_from_str(include_str!("first_floor.txt"));
let mut world = World::new(grid.size(), LEVEL);
// let grid = procgen::generate(Size::new_u16(30, 30), 0);
let mut world = World::new(Size::new_u16(40, 33), LEVEL);

let agents = ComponentTable::default();
let (player_entity, _) = spawn_terrain(grid, &mut world, None);
Expand Down
2 changes: 2 additions & 0 deletions forgotten/src/terrain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub fn build_station(
println!("Generating last floor");
}

let level = FINAL_LEVEL;

const STATION_SIZE: Size = Size::new_u16(40, 33);

let grid = procgen::generate(STATION_SIZE, level);
Expand Down
2 changes: 2 additions & 0 deletions forgotten/src/terrain/procgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub fn generate_from_str(s: &str) -> Grid<LevelCell> {
let rows = s.split('\n').filter(|s| !s.is_empty()).collect::<Vec<_>>();
let size = Size::new_u16(rows[0].len() as u16, rows.len() as u16);

log::info!("Generating map of size {:?}", size);
let mut map: Grid<LevelCell> = Grid::new_default(size);
for (y, row) in rows.iter().enumerate() {
for (x, ch) in row.chars().enumerate() {
Expand All @@ -55,6 +56,7 @@ pub fn generate_from_str(s: &str) -> Grid<LevelCell> {
'@' => LevelCell::PlayerSpawn,
'R' => LevelCell::Light(Rgb24 { r: 255, g: 0, b: 0 }),
'r' => LevelCell::Reactor,
' ' => LevelCell::Floor,
_ => unreachable!("Unknown tile: {}", ch),
};

Expand Down
4 changes: 3 additions & 1 deletion forgotten/src/world/action/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ impl World {
let spatial = &self.spatial_table;
for (e, npc) in self.components.npc.iter_mut() {
let current_coord = spatial.coord_of(e).unwrap();
if current_coord.distance2(robo_cop_coord) <= 150 {
if current_coord.distance2(robo_cop_coord) <= 100 {
npc.move_to = Some(spatial.coord_of(player_entity).unwrap());
} else {
npc.move_to = None;
}
}

crate::log::append_entry(Message::AlertedNearbyEntities);

let _ = self.character_walk_in_direction(entity, direction);
}
}
Loading

0 comments on commit 51070e4

Please sign in to comment.