update and add sprites
BIN
src/content/assets/img/border_corner_down_left.png
Normal file
After Width: | Height: | Size: 651 B |
BIN
src/content/assets/img/border_corner_down_right.png
Normal file
After Width: | Height: | Size: 667 B |
BIN
src/content/assets/img/border_corner_up_left.png
Normal file
After Width: | Height: | Size: 602 B |
BIN
src/content/assets/img/border_corner_up_right.png
Normal file
After Width: | Height: | Size: 596 B |
BIN
src/content/assets/img/border_down.png
Normal file
After Width: | Height: | Size: 809 B |
BIN
src/content/assets/img/border_left.png
Normal file
After Width: | Height: | Size: 811 B |
BIN
src/content/assets/img/border_right.png
Normal file
After Width: | Height: | Size: 840 B |
BIN
src/content/assets/img/border_up.png
Normal file
After Width: | Height: | Size: 776 B |
Before Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 776 B |
Before Width: | Height: | Size: 855 B |
BIN
src/content/assets/img/papy_down.png
Normal file
After Width: | Height: | Size: 928 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 870 B |
Before Width: | Height: | Size: 857 B After Width: | Height: | Size: 881 B |
Before Width: | Height: | Size: 838 B |
BIN
src/content/assets/img/papy_up.png
Normal file
After Width: | Height: | Size: 840 B |
BIN
src/content/assets/img/space.png
Normal file
After Width: | Height: | Size: 509 B |
Before Width: | Height: | Size: 9.5 KiB |
BIN
src/content/assets/img/space1.png
Normal file
After Width: | Height: | Size: 753 B |
BIN
src/content/assets/img/space2.png
Normal file
After Width: | Height: | Size: 684 B |
Before Width: | Height: | Size: 941 B |
Before Width: | Height: | Size: 865 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 512 B |
BIN
src/content/assets/img/water_border_down.png
Normal file
After Width: | Height: | Size: 673 B |
BIN
src/content/assets/img/water_border_left.png
Normal file
After Width: | Height: | Size: 715 B |
BIN
src/content/assets/img/water_border_right.png
Normal file
After Width: | Height: | Size: 702 B |
BIN
src/content/assets/img/water_border_up.png
Normal file
After Width: | Height: | Size: 684 B |
BIN
src/content/assets/img/water_corner_down_left.png
Normal file
After Width: | Height: | Size: 779 B |
BIN
src/content/assets/img/water_corner_down_right.png
Normal file
After Width: | Height: | Size: 784 B |
BIN
src/content/assets/img/water_corner_up_left.png
Normal file
After Width: | Height: | Size: 803 B |
BIN
src/content/assets/img/water_corner_up_right.png
Normal file
After Width: | Height: | Size: 786 B |
Before Width: | Height: | Size: 671 B |
@ -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 =
|
||||
|
@ -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))
|
||||
|]
|
||||
|