Skip to content

Commit

Permalink
chore: improve CI
Browse files Browse the repository at this point in the history
  • Loading branch information
shiryel committed Aug 26, 2024
1 parent 8119386 commit a4eecad
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Run Tests

on: [push, pull_request]
on:
- push
- pull_request

jobs:
tests:
Expand Down Expand Up @@ -49,3 +51,23 @@ jobs:

- name: Check Dialyzer
run: mix dialyzer

- name: Check 3D Picking example
run: |
cd examples/3d_picking
mix deps.get
mix compile --warnings-as-errors
mix credo --strict
mix format --check-formatted
mix dialyzer --force-check
cd ../..
- name: Check Scale Rectangle example
run: |
cd examples/scale_rectangle
mix deps.get
mix compile --warnings-as-errors
mix credo --strict
mix format --check-formatted
mix dialyzer --force-check
cd ../..
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ iex> The3dPicking.run()
## Contributing

There are a few things that you need to know about the code:
* This project aims to run each one of [those functions](https://www.raylib.com/cheatsheet/cheatsheet.html) with elixir
* This project aims to run each one of [these functions](https://www.raylib.com/cheatsheet/cheatsheet.html) with elixir
* To do so, we are using [Unifex](https://hexdocs.pm/unifex/readme.html) to create NIFs
* On `c_src/rayex/rayex.spec.exs` you can find the definitions that will be generated by Unifex
* On `c_src/rayex/rayex.c` you can find how they are implemented
Expand Down
29 changes: 16 additions & 13 deletions examples/3d_picking/lib/the3d_picking.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ defmodule The3dPicking do
end

defp game_loop(%{camera: camera, hit?: hit?} = state) do
camera = (is_cursor_hidden?() && update_camera(camera, @camera_first_person)) || camera
camera =
if is_cursor_hidden?() do
update_camera(camera, @camera_first_person)
else
camera
end

if mouse_button_pressed?(@mouse_right) do
(is_cursor_hidden?() && enable_cursor()) ||
disable_cursor()
end

ray = get_mouse_position() |> get_mouse_ray(camera)

Expand All @@ -48,16 +58,12 @@ defmodule The3dPicking do
hit?
end

if mouse_button_pressed?(@mouse_right) do
(is_cursor_hidden?() && enable_cursor()) ||
disable_cursor()
end
state = draw(ray, %{state | hit?: hit?, camera: camera})

state = %{state | hit?: hit?, camera: camera}
(window_should_close() && close_window()) || game_loop(state)
end

#
# draw
#
defp draw(ray, %{camera: camera, hit?: hit?} = state) do
begin_drawing()
clear_background(@color_white)

Expand Down Expand Up @@ -85,11 +91,8 @@ defmodule The3dPicking do
draw_fps(10, 10)

end_drawing()
#
# end draw
#

(window_should_close() && close_window()) || game_loop(state)
state
end

defp check_hit(ray) do
Expand Down

0 comments on commit a4eecad

Please sign in to comment.