diff options
| author | arngo <[email protected]> | 2021-12-19 22:08:34 -0500 |
|---|---|---|
| committer | arngo <[email protected]> | 2021-12-19 22:08:34 -0500 |
| commit | 501fac5e7fe4d4c56dcc51467b77d42cea597174 (patch) | |
| tree | 061fd6f04cf6d161c82867f2341d0cced5ad777c /app | |
| parent | 154030e74b007b6fc65e45e50107b69b717c7b1f (diff) | |
| download | SteelWings-501fac5e7fe4d4c56dcc51467b77d42cea597174.tar.gz SteelWings-501fac5e7fe4d4c56dcc51467b77d42cea597174.zip | |
lock camera to player
Diffstat (limited to 'app')
| -rw-r--r-- | app/main.rb | 1 | ||||
| -rw-r--r-- | app/scenes/scenes.rb | 1 | ||||
| -rw-r--r-- | app/systems/move_camera.rb | 21 | ||||
| -rw-r--r-- | app/systems/start_game.rb | 1 |
4 files changed, 24 insertions, 0 deletions
diff --git a/app/main.rb b/app/main.rb index a5a1c5c..3bd54a2 100644 --- a/app/main.rb +++ b/app/main.rb @@ -39,6 +39,7 @@ require 'app/systems/camera.rb' require 'app/systems/collision_damage.rb' require 'app/systems/death.rb' require 'app/systems/player_weapon.rb' +require 'app/systems/move_camera.rb' require 'app/factories/bullet.rb' require 'app/factories/ships/osprey.rb' diff --git a/app/scenes/scenes.rb b/app/scenes/scenes.rb index 98e3632..5cbcdea 100644 --- a/app/scenes/scenes.rb +++ b/app/scenes/scenes.rb @@ -1,5 +1,6 @@ FF::Scn.new('BoidRules') FF::Scn.new('Debug') +FF::Scn.new('Camera') FF::Stg.add( FF::Scn.new('TitleScreen'), FF::Scn.new('Render'), diff --git a/app/systems/move_camera.rb b/app/systems/move_camera.rb new file mode 100644 index 0000000..c96cbc4 --- /dev/null +++ b/app/systems/move_camera.rb @@ -0,0 +1,21 @@ +FF::Scn::Camera.add( + FF::Sys.new('MoveCamera', priority: 100) do + camera = FF::Cmp::SingletonCamera[0] + player_boid = FF::Cmp::SingletonPlayer[0].entities[0].components[FF::Cmp::Boid][0] + camera.x = player_boid.x + camera.y = player_boid.y + #mouse = $gtk.args.inputs.mouse + #camera_pos = [0,0] + # + #angle = camera.angle * (Math::PI / 180) + #half_width = $gtk.args.grid.w * 0.5 + #half_height = $gtk.args.grid.h * 0.5 + #camera_pos[0] = (((((mouse.x - half_width) / camera.zoom) * Math.cos(-angle)) - (((mouse.y - half_height) / camera.zoom) * Math.sin(-angle)) + camera.x)-player_boid.x)/2 + #camera_pos[1] = (((((mouse.x - half_width) / camera.zoom) * Math.sin(-angle)) + (((mouse.y - half_height) / camera.zoom) * Math.cos(-angle)) + camera.y)-player_boid.y)/2 + + #camera.x = camera_pos[0] + #camera.y = camera_pos[1] + puts camera.x + puts camera.y + end +) diff --git a/app/systems/start_game.rb b/app/systems/start_game.rb index 42a3916..da415ec 100644 --- a/app/systems/start_game.rb +++ b/app/systems/start_game.rb @@ -40,6 +40,7 @@ FF::Sys.new('StartGame', priority: 50 ) do FF::Stg.add( FF::Scn::BoidRules, + FF::Scn::Camera, FF::Scn::Debug, ) |
