Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom level animation #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions eepers.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1029,14 +1029,17 @@ procedure Eepers is
Camera_Target: constant Vector2 := To_Vector2(Game.Player.Position)*Cell_Size;
Camera_Offset: constant Vector2 := Screen_Size*0.5 - Cell_Size*0.5;
Camera_Velocity: constant Vector2 := (Camera_Target - Game.Camera.target)*2.0;

-- set the zoom level to the ratio of the current and the reference screen size (FHD) and round it to the first decimal
Camera_Zoom: constant C_Float := C_Float'Rounding(C_Float'Max(Screen_Size.x/1920.0, Screen_Size.y/1080.0) * 10.0) / 10.0;
Camera_Zoom_Velocity: constant C_Float := (Camera_Zoom - Game.Camera.zoom)*4.0;
begin
Game.Camera.offset := Camera_Offset;
Game.Camera.target := Game.Camera.target + Camera_Velocity*Get_Frame_Time;
-- TODO: animate zoom similarly to Game.Camera.target
-- So it looks cool when you resize the game in the window mode.
-- TODO: The tutorial signs look gross on bigger screens.
-- We need to do something with the fonts
Game.Camera.zoom := C_Float'Max(Screen_Size.x/1920.0, Screen_Size.y/1080.0);
Game.Camera.zoom := Camera_Zoom;
Game.Camera.zoom := Game.Camera.zoom + Camera_Zoom_Velocity*Get_Frame_Time;
end;

function Interpolate_Positions(IPrev_Position, IPosition: IVector2; T: Float) return Vector2 is
Expand Down