Ver código fonte

Added cursor movement with range 6 and more tiny fixes...

master
Ognjen Milan Robovic 1 semana atrás
pai
commit
ff9cf274d0
9 arquivos alterados com 40 adições e 31 exclusões
  1. +14
    -2
      source/core.adb
  2. +5
    -0
      source/core.ads
  3. +1
    -1
      source/main.adb
  4. +7
    -10
      source/ui.adb
  5. +3
    -2
      source/ui.ads
  6. +10
    -16
      source/world.adb
  7. BIN
      sprite/ui/dwarf/title_bar_left.png
  8. BIN
      sprite/ui/dwarf/title_bar_middle.png
  9. BIN
      sprite/ui/dwarf/title_bar_right.png

+ 14
- 2
source/core.adb Ver arquivo

@@ -134,6 +134,18 @@ package body core is

------------------------------------------------------------------------------------------

function center_x (object : in integer) return integer is begin return (window_width - object) / 2; end center_x;
function center_y (object : in integer) return integer is begin return (window_height - object) / 2; end center_y;

------------------------------------------------------------------------------------------

function cursor_inside (x, y, width, height : in integer) return boolean is
begin
return cursor.x > x and cursor.x < x + width and cursor.y > y and cursor.y < y + height;
end cursor_inside;

------------------------------------------------------------------------------------------

function import_sprite (file_path : in string; frames, states : in integer) return sprite is
this : sprite;
begin
@@ -217,8 +229,8 @@ package body core is
ray.draw_text (data => font_array (data.index),
text => c_string (text),
view => (float (x), float (y)),
scale => float ((if size = 0 then data.scale else size)),
space => float (data.space),
scale => (if size = 0 then float (font_array (data.index).base) else float (size)),
space => float (font_array (data.index).pad),
tint => new_tint);
end write;



+ 5
- 0
source/core.ads Ver arquivo

@@ -110,6 +110,11 @@ package core is
function window_width return integer;
function window_height return integer;

function center_x (object : in integer) return integer;
function center_y (object : in integer) return integer;

function cursor_inside (x, y, width, height : in integer) return boolean;

function import_sprite (file_path : in string; frames, states : in integer) return sprite;
function import_font (file_path : in string; scale, space : in integer) return font;
function import_song (file_path : in string) return song;


+ 1
- 1
source/main.adb Ver arquivo

@@ -105,7 +105,7 @@ procedure main is

procedure introduction is
begin
ui.write ("[-- Please press Spacebar to continue]", 0, 0, 14, (102, 102, 102, 255));
core.write ("[-- Please press Spacebar to continue]", 0, center_y (24), (102, 102, 102, 255));
end introduction;

------------------------------------------------------------------------------------------


+ 7
- 10
source/ui.adb Ver arquivo

@@ -70,13 +70,6 @@ package body ui is

------------------------------------------------------------------------------------------

function cursor_inside (x, y, width, height : in integer) return boolean is
begin
return core.cursor.x > x and core.cursor.x < x + width and core.cursor.y > y and core.cursor.y < y + height;
end cursor_inside;

------------------------------------------------------------------------------------------

procedure draw (index : in element := none;
x : in integer := 0;
y : in integer := 0;
@@ -229,6 +222,8 @@ package body ui is
procedure synchronize is
use core;
begin
prioritize := false;
--
for index in 0 .. structure_count - 1 loop
if signal_mode = structure_array (index).toggle then
structure_array (index).show := not structure_array (index).show;
@@ -236,13 +231,15 @@ package body ui is
--
if structure_array (index).show then
draw_structure (structure_array (index));
--
prioritize := true;
end if;
end loop;
end synchronize;

------------------------------------------------------------------------------------------

procedure write (text : in string; x, y : in integer; size : in natural := 0; tint : in core.colour := (others => 255)) is
procedure write (text : in string; x, y : in integer; tint : in core.colour := (others => 255); size : in natural := 0) is
begin
core.write (text, x, y, tint, font (active).scale, font (active));
end write;
@@ -258,7 +255,7 @@ package body ui is
core.draw (data, x, y);
core.zoom := save_zoom;
--
if cursor_inside (x, y, core.icon, core.icon) then
if core.cursor_inside (x, y, core.icon, core.icon) then
draw (icon_selected, x, y);
--
core.write_text_box (description);
@@ -360,7 +357,7 @@ package body ui is
--
draw_horizontally (title_bar_middle, x + sprite (active, title_bar_left).width, y - sprite (active, title_bar_middle).height, middle_width);
--
write (title, x + sprite (active, title_bar_left).width + offset, y - font (active).scale - 4, tint => font_tint (active));
write (title, x + sprite (active, title_bar_left).width, y - font (active).scale - 4, tint => font_tint (active));
end draw_title_bar;

------------------------------------------------------------------------------------------


+ 3
- 2
source/ui.ads Ver arquivo

@@ -47,14 +47,15 @@ package ui is

------------------------------------------------------------------------------------------

active : style := main;
active : style := main;
prioritize : boolean := false;

------------------------------------------------------------------------------------------

procedure configure;
procedure synchronize;

procedure write (text : in string; x, y : in integer; size : in natural := 0; tint : in core.colour := (others => 255));
procedure write (text : in string; x, y : in integer; tint : in core.colour := (others => 255); size : in natural := 0);

procedure draw_icon (data : in core.sprite; description : in string; x, y : in integer; action : core.pointer := core.idle'access);
procedure draw_overicon (data : in core.sprite; description : in string; x, y : in integer; action : core.pointer := core.idle'access);


+ 10
- 16
source/world.adb Ver arquivo

@@ -130,16 +130,15 @@ package body world is
v => v,
width => core.base,
height => core.base);
--~--MOVE PLAYER TO TILE WHERE YOU CLICKED
--~if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom
--~and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom
--~and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom
--~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom
--~and core.cursor_mode = 1 then
--~core.camera.x := horizontal;
--~core.camera.y := vertical;
--~core.cursor_mode := 0;
--~end if;
if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6
and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6
and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom - 6
and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom + 6
and core.cursor_mode = 1 and not ui.prioritize then
core.camera.x := horizontal;
core.camera.y := vertical;
core.cursor_mode := 0;
end if;
end if;
end loop;
end loop;
@@ -174,7 +173,7 @@ package body world is
for horizontal in 0 .. map.width - 1 loop
exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
--
if (horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach then
if (horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach then
core.draw (data => dark,
x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom,
y => offset.y + (vertical - core.camera.y) * core.base * core.zoom);
@@ -189,11 +188,6 @@ package body world is
offset : core.vector := ((core.window_width - core.base) / 2,
(core.window_height - core.base) / 2);
begin
--~for x in 0 .. view_reach loop
--~for y in 0 .. view_reach loop
--~map.views ((x + core.camera.x - view_reach / 2) mod map.width, (y + core.camera.y - view_reach / 2) mod map.height) := true;
--~end loop;
--~end loop;
for vertical in 0 .. map.height - 1 loop
exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;
--


BIN
sprite/ui/dwarf/title_bar_left.png Ver arquivo

Antes Depois
Largura: 48  |  Altura: 48  |  Tamanho: 511B Largura: 48  |  Altura: 48  |  Tamanho: 539B

BIN
sprite/ui/dwarf/title_bar_middle.png Ver arquivo

Antes Depois
Largura: 24  |  Altura: 48  |  Tamanho: 155B Largura: 24  |  Altura: 48  |  Tamanho: 155B

BIN
sprite/ui/dwarf/title_bar_right.png Ver arquivo

Antes Depois
Largura: 48  |  Altura: 48  |  Tamanho: 403B Largura: 48  |  Altura: 48  |  Tamanho: 434B

Carregando…
Cancelar
Salvar