Skip to content

Commit

Permalink
use 1.1 formatter to fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Acepie committed May 1, 2024
1 parent 3e1f4df commit 99c44da
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 111 deletions.
6 changes: 3 additions & 3 deletions src/bullet_heck_gleam.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ fn setup(p: P5) -> WorldState {
}

fn draw(p: P5, state: WorldState) {
p5.background(p, "#000000")
case state {
GameRunning(dungeon, player, bullets) -> {
p5.background(p, "#000000")
dungeon.draw(p, dungeon)
player.draw(p, player)
list.each(bullets, bullet.draw(p, _))
p
}
GameOver(_) -> {
p5.background(p, "#000000")
p
}
}
}
Expand Down Expand Up @@ -168,7 +168,7 @@ fn on_tick(state: WorldState) -> WorldState {
use <- bool.guard(
player.position.z <. 0.0
&& dungeon.is_over_pit(dungeon, player.position),
GameOver(False),
GameOver(True),
)

let player = player.update_velocity(player)
Expand Down
16 changes: 12 additions & 4 deletions src/dungeon.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,12 @@ fn get_location_to_place_pit(rooms: Rooms, pits: List(Pit)) -> vector.Vector {
let point = get_random_point_in_room(rooms)

// Get a random offset from the point
let offset_x = random.float(-30.0, 30.0) |> random.random_sample
let offset_y = random.float(-30.0, 30.0) |> random.random_sample
let offset_x =
random.float(-30.0, 30.0)
|> random.random_sample
let offset_y =
random.float(-30.0, 30.0)
|> random.random_sample
let position = vector.add(point, vector.Vector(offset_x, offset_y, 0.0))

case
Expand All @@ -284,8 +288,12 @@ fn get_location_to_place_pit(rooms: Rooms, pits: List(Pit)) -> vector.Vector {

// Get a random point by generating random coordinates until a room is found.
fn get_random_point_in_room(rooms: Rooms) -> vector.Vector {
let random_x = random.int(0, dungeon_size) |> random.random_sample
let random_y = random.int(0, dungeon_size) |> random.random_sample
let random_x =
random.int(0, dungeon_size)
|> random.random_sample
let random_y =
random.int(0, dungeon_size)
|> random.random_sample
let coordinate = #(random_x, random_y)
case dict.get(rooms, coordinate) {
Error(_) -> get_random_point_in_room(rooms)
Expand Down
208 changes: 104 additions & 104 deletions test/player_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ pub fn player_tests() {
it("move", fn() {
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(1.0, 2.0, 3.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(1.0, 2.0, 3.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.move,
Player(
position: Vector(1.0, 2.0, 3.0),
Expand All @@ -45,14 +45,14 @@ pub fn player_tests() {
it("update_velocity", fn() {
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(1.0, 1.0, 1.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(1.0, 1.0, 1.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.update_velocity,
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -66,14 +66,14 @@ pub fn player_tests() {
)
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(5.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(5.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.update_velocity,
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -89,14 +89,14 @@ pub fn player_tests() {
it("jump", fn() {
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.jump,
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -110,14 +110,14 @@ pub fn player_tests() {
)
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 1.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 1.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.jump,
Player(
position: Vector(0.0, 0.0, 1.0),
Expand All @@ -133,14 +133,14 @@ pub fn player_tests() {
it("accelerate_x", fn() {
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.accelerate_x(True),
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -154,14 +154,14 @@ pub fn player_tests() {
)
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.accelerate_x(False),
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -177,14 +177,14 @@ pub fn player_tests() {
it("accelerate_y", fn() {
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.accelerate_y(True),
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -198,14 +198,14 @@ pub fn player_tests() {
)
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 0.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.accelerate_y(False),
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -221,14 +221,14 @@ pub fn player_tests() {
it("stop_x", fn() {
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(1.0, 1.0, 0.0),
acceleration: vector.Vector(1.0, 1.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(1.0, 1.0, 0.0),
acceleration: vector.Vector(1.0, 1.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.stop_x,
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -244,14 +244,14 @@ pub fn player_tests() {
it("stop_y", fn() {
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(1.0, 1.0, 0.0),
acceleration: vector.Vector(1.0, 1.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(1.0, 1.0, 0.0),
acceleration: vector.Vector(1.0, 1.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.stop_y,
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -267,14 +267,14 @@ pub fn player_tests() {
it("apply_gravity", fn() {
expect.to_equal(
Player(
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 1.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, 0.0),
velocity: vector.Vector(0.0, 0.0, 1.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.apply_gravity,
Player(
position: Vector(0.0, 0.0, 0.0),
Expand All @@ -288,14 +288,14 @@ pub fn player_tests() {
)
expect.to_equal(
Player(
position: Vector(0.0, 0.0, -1.0),
velocity: vector.Vector(0.0, 0.0, 1.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
position: Vector(0.0, 0.0, -1.0),
velocity: vector.Vector(0.0, 0.0, 1.0),
acceleration: vector.Vector(0.0, 0.0, 0.0),
last_fire_time: 0,
last_hit_time: 0,
current_health: 100,
max_health: 100,
)
|> player.apply_gravity,
Player(
position: Vector(0.0, 0.0, 0.0),
Expand Down

0 comments on commit 99c44da

Please sign in to comment.