summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt3
-rw-r--r--assets/map-new.pngbin0 -> 1467 bytes
-rw-r--r--assets/map.pngbin1467 -> 1338 bytes
-rw-r--r--eepers.adb90
4 files changed, 55 insertions, 38 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index f4143ef..39acd8c 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -2,7 +2,8 @@
- @rexim - Added items that extend the amount of bombs you can carry
- @rexim - Do not restart on Any Key Press. Restart automatically after 2 seconds.
-- @ProgKea - Fix the Boss killing the Player on the same turn as it does - https://github.com/tsoding/eepers/pull/24
+- @ProgKea - Fix the Boss killing the Player on the same turn as it dies - https://github.com/tsoding/eepers/pull/24
+- @slukovic - Camera adjusts its zoom on bigger screen - https://github.com/tsoding/eepers/pull/27
- ...
# Eepers v1.3
diff --git a/assets/map-new.png b/assets/map-new.png
new file mode 100644
index 0000000..3d01c7c
--- /dev/null
+++ b/assets/map-new.png
Binary files differ
diff --git a/assets/map.png b/assets/map.png
index 3d01c7c..5c1a26b 100644
--- a/assets/map.png
+++ b/assets/map.png
Binary files differ
diff --git a/eepers.adb b/eepers.adb
index 2a3fa87..38973b7 100644
--- a/eepers.adb
+++ b/eepers.adb
@@ -1,5 +1,4 @@
-with Ada.Text_IO;
-with Text_IO; use Text_IO;
+with Ada.Text_IO; use Ada.Text_IO;
with Interfaces.C; use Interfaces.C;
with Raylib; use Raylib;
with Raymath; use Raymath;
@@ -73,9 +72,24 @@ procedure Eepers is
return Color_From_HSV(H, S, V);
end;
- procedure Increment(X: in out Integer) is
+ procedure Inc(X: in out Integer; Offset: Integer := 1) is
begin
- X := X + 1;
+ X := X + Offset;
+ end;
+
+ procedure Dec(X: in out Integer; Offset: Integer := 1) is
+ begin
+ X := X - Offset;
+ end;
+
+ procedure Inc(X: in out Byte; Offset: Byte := 1) is
+ begin
+ X := X + Offset;
+ end;
+
+ procedure Dec(X: in out Byte; Offset: Byte := 1) is
+ begin
+ X := X - Offset;
end;
Palette_RGB: array (Palette) of Color := (others => (A => 255, others => 0));
@@ -103,7 +117,7 @@ procedure Eepers is
begin
Open(F, In_File, File_Name);
while not End_Of_File(F) loop
- Line_Number := Line_Number + 1;
+ Inc(Line_Number);
declare
Line: Unbounded_String := To_Unbounded_String(Get_Line(F));
@@ -419,7 +433,11 @@ procedure Eepers is
Items: Item_Array;
Bombs: Bomb_State_Array;
- Camera_Position: Vector2 := (x => 0.0, y => 0.0);
+ Camera: Camera2D := (
+ offset => (x => 0.0, y => 0.0),
+ target => (x => 0.0, y => 0.0),
+ rotation => 0.0,
+ zoom => 1.0);
Tutorial: Tutorial_State;
Checkpoint: Checkpoint_State;
@@ -760,7 +778,8 @@ procedure Eepers is
Game.Map(Row, Column) := Cell_Floor;
when Level_Father =>
if Update_Camera then
- Game.Camera_Position := Screen_Size*0.5 - (To_Vector2((Column, Row))*Cell_Size + To_Vector2((7, 7))*Cell_Size*0.5);
+ Game.Camera.target := (To_Vector2((Column, Row)) + To_Vector2((7, 7))*0.5) * Cell_Size;
+ Game.Camera.offset := Screen_Size*0.5 - Cell_Size*0.5;
end if;
Spawn_Father(Game, (Column, Row));
Game.Map(Row, Column) := Cell_Floor;
@@ -922,20 +941,20 @@ procedure Eepers is
case Item.Kind is
when Item_None => null;
when Item_Key =>
- Game.Player.Keys := Game.Player.Keys + 1;
+ Inc(Game.Player.Keys);
Item.Kind := Item_None;
Play_Sound(Key_Pickup_Sound);
when Item_Bomb_Refill => if
Game.Player.Bombs < Game.Player.Bomb_Slots
and then Item.Cooldown <= 0
then
- Game.Player.Bombs := Game.Player.Bombs + 1;
+ Inc(Game.Player.Bombs);
Item.Cooldown := BOMB_GENERATOR_COOLDOWN;
Play_Sound(Bomb_Pickup_Sound);
end if;
when Item_Bomb_Slot =>
Item.Kind := Item_None;
- Increment(Game.Player.Bomb_Slots);
+ Inc(Game.Player.Bomb_Slots);
Game.Player.Bombs := Game.Player.Bomb_Slots;
when Item_Checkpoint =>
Item.Kind := Item_None;
@@ -947,7 +966,7 @@ procedure Eepers is
end loop;
when Cell_Door =>
if Game.Player.Keys > 0 then
- Game.Player.Keys := Game.Player.Keys - 1;
+ Dec(Game.Player.Keys);
Flood_Fill(Game, New_Position, Cell_Floor);
Game.Player.Position := New_Position;
Play_Sound(Open_Door_Sound);
@@ -1011,20 +1030,17 @@ procedure Eepers is
);
procedure Game_Update_Camera(Game: in out Game_State) is
- Camera_Target: constant Vector2 :=
- Screen_Size*0.5 - To_Vector2(Game.Player.Position)*Cell_Size - Cell_Size*0.5;
- Camera_Velocity: constant Vector2 := (Camera_Target - Game.Camera_Position)*2.0;
+ 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;
begin
- Game.Camera_Position := Game.Camera_Position + Camera_Velocity*Get_Frame_Time;
- end;
-
- function Game_Camera(Game: in Game_State) return Camera2D is
- begin
- return (
- offset => Game.Camera_Position,
- target => (x => 0.0, y => 0.0),
- rotation => 0.0,
- zoom => 1.0);
+ 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);
end;
function Interpolate_Positions(IPrev_Position, IPosition: IVector2; T: Float) return Vector2 is
@@ -1053,7 +1069,7 @@ procedure Eepers is
begin
Q.Items((Q.Start + Q.Size) mod Command_Capacity) := C;
if Q.Size < Command_Capacity then
- Q.Size := Q.Size + 1;
+ Inc(Q.Size);
else
Q.Start := (Q.Start + 1) mod Command_Capacity;
end if;
@@ -1065,7 +1081,7 @@ procedure Eepers is
return False;
end if;
C := Q.Items(Q.Start);
- Q.Size := Q.Size - 1;
+ Dec(Q.Size);
Q.Start := (Q.Start + 1) mod Command_Capacity;
return True;
end;
@@ -1086,7 +1102,7 @@ procedure Eepers is
end loop;
for Bomb of Game.Bombs loop
if Bomb.Countdown > 0 then
- Bomb.Countdown := Bomb.Countdown - 1;
+ Dec(Bomb.Countdown);
if Bomb.Countdown <= 0 then
Play_Sound(Blast_Sound);
Explode(Game, Bomb.Position);
@@ -1183,7 +1199,7 @@ procedure Eepers is
Position := Position + Direction_Vector(Dir);
if Within_Map(Game, Position) and then Eeper.Path(Position.Y, Position.X) = Current - 1 then
Available_Positions(Count) := Position;
- Count := Count + 1;
+ Inc(Count);
exit;
end if;
end loop;
@@ -1196,7 +1212,7 @@ procedure Eepers is
end;
Eeper.Attack_Cooldown := GUARD_ATTACK_COOLDOWN;
else
- Eeper.Attack_Cooldown := Eeper.Attack_Cooldown - 1;
+ Dec(Eeper.Attack_Cooldown);
end if;
if Eeper.Path(Eeper.Position.Y, Eeper.Position.X) = 1 then
@@ -1237,7 +1253,7 @@ procedure Eepers is
and then Eeper.Path(New_Position.Y, New_Position.X) > Eeper.Path(Position.Y, Position.X)
then
Available_Positions(Count) := New_Position;
- Count := Count + 1;
+ Inc(Count);
end if;
end;
end loop;
@@ -1264,7 +1280,7 @@ procedure Eepers is
for Item of Game.Items loop
if Item.Kind = Item_Bomb_Refill then
if Item.Cooldown > 0 then
- Item.Cooldown := Item.Cooldown - 1;
+ Dec(Item.Cooldown);
end if;
end if;
end loop;
@@ -1424,9 +1440,9 @@ procedure Eepers is
Delta_Timestamp: constant Double := Step_Timestamp - Game.Tutorial.Prev_Step_Timestamp;
begin
if Delta_Timestamp < 0.2 Then
- Game.Tutorial.Hurry_Count := Game.Tutorial.Hurry_Count + 1;
+ Inc(Game.Tutorial.Hurry_Count);
elsif Game.Tutorial.Hurry_Count > 0 then
- Game.Tutorial.Hurry_Count := Game.Tutorial.Hurry_Count - 1;
+ Dec(Game.Tutorial.Hurry_Count);
end if;
Game.Tutorial.Prev_Step_Timestamp := Step_Timestamp;
end;
@@ -1466,7 +1482,7 @@ procedure Eepers is
exit;
end if;
end loop;
- Game.Player.Bombs := Game.Player.Bombs - 1;
+ Dec(Game.Player.Bombs);
Play_Sound(Plant_Bomb_Sound);
end if;
@@ -1721,12 +1737,12 @@ begin
end if;
if Is_Key_Down(Keys(Up)) then
- Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) := Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) + 1;
+ Inc(Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component));
Palette_RGB(Palette_Editor_Choice) := HSV_To_RGB(Palette_HSV(Palette_Editor_Choice));
end if;
if Is_Key_Down(Keys(Down)) then
- Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) := Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) - 1;
+ Dec(Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component));
Palette_RGB(Palette_Editor_Choice) := HSV_To_RGB(Palette_HSV(Palette_Editor_Choice));
end if;
else
@@ -1760,7 +1776,7 @@ begin
end if;
Game_Update_Camera(Game);
- Begin_Mode2D(Game_Camera(Game));
+ Begin_Mode2D(Game.Camera);
Game_Cells(Game);
Game_Items(Game);
Game_Player(Game);