summaryrefslogtreecommitdiffhomepage
path: root/app/systems/ui
diff options
context:
space:
mode:
authorArnold <[email protected]>2021-12-26 18:39:15 -0500
committerGitHub <[email protected]>2021-12-26 18:39:15 -0500
commitb7dea8016b5b1328808e28b76cc12343907de63e (patch)
tree5339c23bbde03c4d6c8c79d96b2033ab9e838ec0 /app/systems/ui
parentf70283e5ad5f5a5744ca0695a184f72f88803aca (diff)
downloadSteelWings-b7dea8016b5b1328808e28b76cc12343907de63e.tar.gz
SteelWings-b7dea8016b5b1328808e28b76cc12343907de63e.zip
implement ai randomizer, gameover screen, and other bug fixes
* Cleaned up factory. Fixed most bugs with death(last bug should be with move camera). * check if player entity is nil before shooting or moving camera * implement ai randomizer * separate button click detection to new system * implement gameover screen with button to return to menu * use reverse_each instead of cloning Co-authored-by: realtradam <[email protected]>
Diffstat (limited to 'app/systems/ui')
-rw-r--r--app/systems/ui/button.rb26
-rw-r--r--app/systems/ui/return_to_menu.rb13
2 files changed, 39 insertions, 0 deletions
diff --git a/app/systems/ui/button.rb b/app/systems/ui/button.rb
new file mode 100644
index 0000000..5ec855b
--- /dev/null
+++ b/app/systems/ui/button.rb
@@ -0,0 +1,26 @@
+FF::Scn::UI.add(
+ FF::Sys.new('ButtonHandler', priority: 50) do
+ FF::Cmp::Button.each do |button|
+ sprite = button.entities[0].components[FF::Cmp::Sprite][0]
+ hitbox = button.entities[0].components[FF::Cmp::Hitbox][0]
+ mouse = $gtk.args.inputs.mouse
+
+ if button.clicked
+ sprite.props[:path] = button.pressed_sprite_path
+ else
+ sprite.props[:path] = button.unpressed_sprite_path
+ end
+
+ if mouse.x > hitbox.x and mouse.x < hitbox.x + hitbox.w and mouse.y > hitbox.y and mouse.y < hitbox.y + hitbox.h
+ if mouse.down
+ button.clicked = true
+ elsif mouse.up and button.clicked
+ button.clicked = false
+ button.action.call
+ end
+ else
+ button.clicked = false
+ end
+ end
+ end
+)
diff --git a/app/systems/ui/return_to_menu.rb b/app/systems/ui/return_to_menu.rb
new file mode 100644
index 0000000..8b6f0c0
--- /dev/null
+++ b/app/systems/ui/return_to_menu.rb
@@ -0,0 +1,13 @@
+FF::Sys.new('ReturnToMenu', priority: 200) do
+ FF::Ent.each do |entity|
+ entity.components.each do |manager, manager_array|
+ manager_array.reverse_each do |component|
+ next if component.respond_to?(:singleton)
+ component.delete
+ end
+ end
+ entity.delete
+ end
+ FF::Scn::BoidRules.add(FF::Sys::Follow, FF::Sys::RandomizeAI)
+ FF::Sys::InitTitleScreen.call
+end