update and add sprites

This commit is contained in:
zapashcanon 2022-12-08 23:54:01 +01:00
parent 31f130f8c9
commit 2dc73eb99d
37 changed files with 13 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 857 B

After

Width:  |  Height:  |  Size: 881 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 779 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 786 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 671 B

View File

@ -17,12 +17,14 @@ let get request =
[ txt "please update your browser or enable javascript" ]
in
let img_grass = mk_img "grass" in
let img_papy_bottom = mk_img "papy_bottom" in
let img_papy_down = mk_img "papy_down" in
let img_water = mk_img "water" in
let img_space = mk_img "space" in
let page =
div ~a:[ a_class [ "centered" ] ]
@@ [ canvas; img_grass; img_papy_bottom; img_water ]
@@ [ canvas; img_grass; img_papy_down; img_water; img_space ]
in
let js =

View File

@ -4,7 +4,7 @@ module Map = struct
type background =
| Grass
| Water
| Black
| Space
let width = 1000
@ -17,10 +17,10 @@ module Map = struct
Array.init height (fun _y ->
if Random.int 1000 <= 42 then Water else Grass ) )
let get_tile_kind ~x ~y = try m.(x).(y) with Invalid_argument _ -> Black
let get_tile_kind ~x ~y = try m.(x).(y) with Invalid_argument _ -> Space
end
let tile_size = 40
let tile_size = 32
let width = 835
@ -55,10 +55,12 @@ let orig_y = (height - (tiles_per_h * tile_size)) / 2
let grass = Jv.get Jv.global "grass"
let papy_bottom = Jv.get Jv.global "papy_bottom"
let papy_down = Jv.get Jv.global "papy_down"
let water = Jv.get Jv.global "water"
let space = Jv.get Jv.global "space"
let draw_map () =
let player_x, player_y = !Map.player_pos in
Format.printf "player_x = %d@\nplayer_y = %d@\n" player_x player_y;
@ -70,7 +72,7 @@ let draw_map () =
match Map.get_tile_kind ~x:mapx ~y:mapy with
| Grass -> grass
| Water -> water
| Black -> water
| Space -> space
in
let (_ : Jv.t) =
Jv.call context "drawImage"
@ -84,7 +86,7 @@ let draw_map () =
done;
let (_ : Jv.t) =
Jv.call context "drawImage"
[| papy_bottom; Jv.of_int (width / 2); Jv.of_int (height / 2) |]
[| papy_down; Jv.of_int (width / 2); Jv.of_int (height / 2) |]
in
()
@ -148,7 +150,7 @@ let () =
let draw_papy () =
let (_ : Jv.t) =
Jv.call context "drawImage"
[| papy_bottom
[| papy_down
; Jv.of_int ((width / 2) - (tile_size / 2))
; Jv.of_int ((height / 2) - (tile_size / 2))
|]