xhampion/xhampion.adb

97 lines
2.0 KiB
Ada
Raw Normal View History

with raylib;
use raylib;
procedure xhampion is
type monster_index is (
afrit,
brown_chaos_serpent,
centaur,
dark_bishop,
death_wyvern,
ettin,
green_chaos_serpent,
maulotaur,
pig,
reiver,
stalker,
wendigo
);
view : aliased camera_3d := (
position => (0.0, 0.0, 0.0),
target => (0.0, 0.0, 1.0),
up => (0.0, 1.0, 0.0),
field_of_view => 90.0,
projection => camera_perspective
);
model_count : natural := 2;
model_array : array (0 .. 1) of model;
texture_count : natural := 2;
texture_array : array (0 .. 1) of texture;
movement : vector_3d := (0.0, 0.0, 0.0);
rotation : vector_3d := (0.0, 0.0, 0.0);
dd : vector_2d := (0.0, 0.0);
begin
open_window (1800, 900, "Xhampion" & character'val (0));
disable_cursor;
set_target_fps (60);
set_trace_log_level (log_none);
model_array (0) := load_model ("./sprite/wall.obj" & character'val (0));
model_array (1) := load_model ("./sprite/meme.obj" & character'val (0));
texture_array (0) := load_texture ("./sprite/hand.png" & character'val (0));
gameplay: loop
exit when window_should_close;
if is_key_pressed (key_w) then movement.x := movement.x + 1.0;
elsif is_key_pressed (key_s) then movement.x := movement.x - 1.0;
elsif is_key_pressed (key_a) then movement.y := movement.y - 1.0;
elsif is_key_pressed (key_d) then movement.y := movement.y + 1.0;
end if;
dd := get_mouse_delta;
rotation.x := dd.x;
update_camera_pro (view'access, movement, rotation, 1.0);
begin_drawing;
clear_background (sky_blue);
begin_mode_3d (view);
for i in 0 .. 40
loop
for j in 0 .. 40
loop
draw_model (model_array (0), (float (i) * (-4.0), -1.0, float (j) * (-4.0)), 2.0, white);
draw_model (model_array (1), (float (i) * (-4.0), -1.0, float (j) * (-4.0)), 2.0, white);
end loop;
end loop;
end_mode_3d;
draw_texture (texture_array (0), (get_screen_width - 960) / 2, get_screen_height - 600, white);
draw_fps (0, 0);
end_drawing;
end loop gameplay;
close_window;
end xhampion;