Compare commits
5 Commits
f094877001
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e28b85a7fa | |||
| efa08b3f03 | |||
| 89ca768c48 | |||
| 758ddbd44e | |||
| a13e3c4166 |
10
Makefile
10
Makefile
@@ -85,6 +85,13 @@ web/index.html: $(WEB_OBJECTS) main.sex shell.html web/libraylib.web.a
|
|||||||
|
|
||||||
web: web/index.html
|
web: web/index.html
|
||||||
|
|
||||||
|
web-pack: web release.zip
|
||||||
|
|
||||||
|
release.zip:
|
||||||
|
mkdir -p web-pack
|
||||||
|
cp web/index.html web/index.wasm web/index.js web/index.data web-pack
|
||||||
|
zip release.zip -r web-pack
|
||||||
|
|
||||||
serve: web
|
serve: web
|
||||||
python3 -m http.server -d web 8000
|
python3 -m http.server -d web 8000
|
||||||
|
|
||||||
@@ -94,5 +101,6 @@ clean:
|
|||||||
$(MAKE) -C $(RAYLIB_SRC) clean
|
$(MAKE) -C $(RAYLIB_SRC) clean
|
||||||
rm -rf ./build ./web
|
rm -rf ./build ./web
|
||||||
rm -f $(OBJECTS) catch-phase
|
rm -f $(OBJECTS) catch-phase
|
||||||
|
rm -f release.zip
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean web-pack
|
||||||
|
|||||||
118
game.sex
118
game.sex
@@ -17,9 +17,7 @@
|
|||||||
(define FISHING-POPUP-WIDTH 480.0f)
|
(define FISHING-POPUP-WIDTH 480.0f)
|
||||||
(define FISHING-POPUP-HEIGHT 560.0f)
|
(define FISHING-POPUP-HEIGHT 560.0f)
|
||||||
(define FISHING-POPUP-PADDING 32.0f)
|
(define FISHING-POPUP-PADDING 32.0f)
|
||||||
(define BOBBER-WIDTH 28.0f)
|
|
||||||
(define BOBBER-HEIGHT 36.0f)
|
(define BOBBER-HEIGHT 36.0f)
|
||||||
(define FISH-GAP 20.0f)
|
|
||||||
(define FISH-SPEED 0.75f)
|
(define FISH-SPEED 0.75f)
|
||||||
|
|
||||||
;; Physics is expressed in abstract units; this maps them to popup pixels
|
;; Physics is expressed in abstract units; this maps them to popup pixels
|
||||||
@@ -65,7 +63,9 @@
|
|||||||
|
|
||||||
;; Caught fish counter
|
;; Caught fish counter
|
||||||
(caught-fish int)
|
(caught-fish int)
|
||||||
(fish-texture Texture2D)))
|
(popup-back Texture2D)
|
||||||
|
(popup-magnet Texture2D)
|
||||||
|
(popup-target Texture2D)))
|
||||||
|
|
||||||
(ops camera
|
(ops camera
|
||||||
(fn init ((self (* camera))) void
|
(fn init ((self (* camera))) void
|
||||||
@@ -137,7 +137,9 @@
|
|||||||
(pub fn mk-game ((app-state (* app-state))) page
|
(pub fn mk-game ((app-state (* app-state))) page
|
||||||
(var state _ (mem-alloc game-state))
|
(var state _ (mem-alloc game-state))
|
||||||
(= (. state app-state) app-state)
|
(= (. state app-state) app-state)
|
||||||
(= (. state fish-texture) (LoadTexture "res/img/small-fish.png"))
|
(= (. state popup-back) (LoadTexture "res/img/fishing-popup-back.png"))
|
||||||
|
(= (. state popup-magnet) (LoadTexture "res/img/fishing-popup-magnet.png"))
|
||||||
|
(= (. state popup-target) (LoadTexture "res/img/fishing-popup-target.png"))
|
||||||
(audio-play-game-music)
|
(audio-play-game-music)
|
||||||
|
|
||||||
(var map (* tmx-map) (load-tmx MAP-FILE))
|
(var map (* tmx-map) (load-tmx MAP-FILE))
|
||||||
@@ -194,8 +196,12 @@
|
|||||||
|
|
||||||
(pub fn rm-game ((state (* game-state))) void
|
(pub fn rm-game ((state (* game-state))) void
|
||||||
(unload-tmx (. state map))
|
(unload-tmx (. state map))
|
||||||
(if (IsTextureValid (. state fish-texture))
|
(if (IsTextureValid (. state popup-back))
|
||||||
(UnloadTexture (. state fish-texture)))
|
(UnloadTexture (. state popup-back)))
|
||||||
|
(if (IsTextureValid (. state popup-magnet))
|
||||||
|
(UnloadTexture (. state popup-magnet)))
|
||||||
|
(if (IsTextureValid (. state popup-target))
|
||||||
|
(UnloadTexture (. state popup-target)))
|
||||||
(free state)
|
(free state)
|
||||||
(return))
|
(return))
|
||||||
|
|
||||||
@@ -204,7 +210,57 @@
|
|||||||
|
|
||||||
;; Dim the game behind the popup
|
;; Dim the game behind the popup
|
||||||
(DrawRectangle 0 0 WIN-WIDTH WIN-HEIGHT (Fade BLACK 0.5f))
|
(DrawRectangle 0 0 WIN-WIDTH WIN-HEIGHT (Fade BLACK 0.5f))
|
||||||
(GuiPanel popup "Fishing")
|
(if (IsTextureValid (. state popup-back))
|
||||||
|
(DrawTexture (. state popup-back)
|
||||||
|
(cast (. popup x) int)
|
||||||
|
(cast (. popup y) int)
|
||||||
|
WHITE)
|
||||||
|
(GuiPanel popup "Fishing"))
|
||||||
|
|
||||||
|
;; Magnet hangs from the top of the popup and marks the bobber position.
|
||||||
|
(var bobber-bottom float
|
||||||
|
(- (+ (. popup y) (. popup height))
|
||||||
|
FISHING-POPUP-PADDING))
|
||||||
|
|
||||||
|
(if (IsTextureValid (. state popup-magnet))
|
||||||
|
(do
|
||||||
|
(var magnet-width float (cast (. state popup-magnet width) float))
|
||||||
|
(var magnet-height float (cast (. state popup-magnet height) float))
|
||||||
|
(var magnet-x float
|
||||||
|
(+ (. popup x)
|
||||||
|
(/ (- (. popup width) magnet-width) 2.0f)))
|
||||||
|
(var magnet-y float
|
||||||
|
(- bobber-bottom
|
||||||
|
magnet-height
|
||||||
|
(. state bobber-y)))
|
||||||
|
(BeginScissorMode (cast (. popup x) int)
|
||||||
|
(cast (. popup y) int)
|
||||||
|
(cast (. popup width) int)
|
||||||
|
(cast (. popup height) int))
|
||||||
|
(DrawTexture (. state popup-magnet)
|
||||||
|
(cast magnet-x int)
|
||||||
|
(cast magnet-y int)
|
||||||
|
WHITE)
|
||||||
|
(EndScissorMode)))
|
||||||
|
|
||||||
|
;; Target arrows move vertically over the same range as the magnet.
|
||||||
|
(if (IsTextureValid (. state popup-target))
|
||||||
|
(do
|
||||||
|
(var target-range float (fishing-bobber-range))
|
||||||
|
(var target-width float (cast (. state popup-target width) float))
|
||||||
|
(var target-height float (cast (. state popup-target height) float))
|
||||||
|
(var target-x float
|
||||||
|
(+ (. popup x)
|
||||||
|
(/ (- (. popup width) target-width) 2.0f)))
|
||||||
|
(var target-center-y float
|
||||||
|
(- bobber-bottom
|
||||||
|
(* (. state fish-y) target-range)))
|
||||||
|
(var target-y float
|
||||||
|
(- target-center-y (/ target-height 2.0f)))
|
||||||
|
(DrawTexture (. state popup-target)
|
||||||
|
(cast target-x int)
|
||||||
|
(cast target-y int)
|
||||||
|
WHITE)))
|
||||||
|
|
||||||
(GuiLabel #(Rectangle :
|
(GuiLabel #(Rectangle :
|
||||||
(+ (. popup x) FISHING-POPUP-PADDING)
|
(+ (. popup x) FISHING-POPUP-PADDING)
|
||||||
@@ -213,11 +269,6 @@
|
|||||||
40.0f)
|
40.0f)
|
||||||
"X: pull! ESC: leave...")
|
"X: pull! ESC: leave...")
|
||||||
|
|
||||||
;; The golden rectangle is the bobber, hanging at the bottom of the popup
|
|
||||||
(var bobber-bottom float
|
|
||||||
(- (+ (. popup y) (. popup height))
|
|
||||||
FISHING-POPUP-PADDING))
|
|
||||||
|
|
||||||
(var progress-bar-length int (- (. popup width) (* 2 FISHING-POPUP-PADDING)))
|
(var progress-bar-length int (- (. popup width) (* 2 FISHING-POPUP-PADDING)))
|
||||||
(var progress-bar-bg _
|
(var progress-bar-bg _
|
||||||
#(Rectangle :
|
#(Rectangle :
|
||||||
@@ -232,48 +283,7 @@
|
|||||||
(+ (. popup y) -10 (* 3 FISHING-POPUP-PADDING))
|
(+ (. popup y) -10 (* 3 FISHING-POPUP-PADDING))
|
||||||
(* progress-bar-length (. state catch-progress))
|
(* progress-bar-length (. state catch-progress))
|
||||||
6))
|
6))
|
||||||
(DrawRectangleRec progress-bar BLUE)
|
(DrawRectangleRec progress-bar BLUE))
|
||||||
(var bobber-bg _
|
|
||||||
#(Rectangle :
|
|
||||||
(+ (. popup x)
|
|
||||||
-1.0f
|
|
||||||
(/ (- (. popup width) BOBBER-WIDTH) 2.0f))
|
|
||||||
(+ (. popup y) -1.0f (* 3.0f FISHING-POPUP-PADDING))
|
|
||||||
(+ 2.0f BOBBER-WIDTH)
|
|
||||||
(- (+ (. popup height) 2.0f)
|
|
||||||
(* 4.0f FISHING-POPUP-PADDING))))
|
|
||||||
(DrawRectangleLinesEx bobber-bg 2.0f DARKBROWN)
|
|
||||||
(var bobber-rect _
|
|
||||||
#(Rectangle :
|
|
||||||
(+ (. popup x)
|
|
||||||
(/ (- (. popup width) BOBBER-WIDTH) 2.0f))
|
|
||||||
(- bobber-bottom BOBBER-HEIGHT (. state bobber-y))
|
|
||||||
BOBBER-WIDTH
|
|
||||||
BOBBER-HEIGHT))
|
|
||||||
(DrawRectangleRec bobber-rect GOLD)
|
|
||||||
(DrawRectangleLinesEx bobber-rect 2.0f DARKBROWN)
|
|
||||||
|
|
||||||
;; Fish sprite sits beside the bobber and moves over the same range
|
|
||||||
(if (IsTextureValid (. state fish-texture))
|
|
||||||
(do
|
|
||||||
(var fish-range float (fishing-bobber-range))
|
|
||||||
(var fish-width float (cast (. state fish-texture width) float))
|
|
||||||
(var fish-height float (cast (. state fish-texture height) float))
|
|
||||||
(var fish-rect _
|
|
||||||
#(Rectangle :
|
|
||||||
(+ (. popup x)
|
|
||||||
(/ (- (. popup width) BOBBER-WIDTH) 2.0f)
|
|
||||||
BOBBER-WIDTH
|
|
||||||
FISH-GAP)
|
|
||||||
(- bobber-bottom
|
|
||||||
(* (. state fish-y) fish-range)
|
|
||||||
fish-height)
|
|
||||||
fish-width
|
|
||||||
fish-height))
|
|
||||||
(DrawTexture (. state fish-texture)
|
|
||||||
(cast (. fish-rect x) int)
|
|
||||||
(cast (. fish-rect y) int)
|
|
||||||
WHITE))))
|
|
||||||
|
|
||||||
(pub fn render-game ((state (* game-state))) void
|
(pub fn render-game ((state (* game-state))) void
|
||||||
(BeginDrawing)
|
(BeginDrawing)
|
||||||
|
|||||||
BIN
res/img/fishing-popup-back.png
Normal file
BIN
res/img/fishing-popup-back.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.8 KiB |
BIN
res/img/fishing-popup-magnet.png
Normal file
BIN
res/img/fishing-popup-magnet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
res/img/fishing-popup-target.png
Normal file
BIN
res/img/fishing-popup-target.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 307 B |
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.10" tiledversion="1.12.2" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="16" tileheight="16" infinite="0" nextlayerid="17" nextobjectid="2">
|
<map version="1.10" tiledversion="1.12.2" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="16" tileheight="16" infinite="0" nextlayerid="17" nextobjectid="8">
|
||||||
<tileset firstgid="1" source="basictiles.tsx"/>
|
<tileset firstgid="1" source="basictiles.tsx"/>
|
||||||
<tileset firstgid="121" name="Sprite-0004" tilewidth="16" tileheight="16" tilecount="16" columns="8">
|
<tileset firstgid="121" name="Sprite-0004" tilewidth="16" tileheight="16" tilecount="16" columns="8">
|
||||||
<image source="Sprite-0004.png" width="128" height="32"/>
|
<image source="Sprite-0004.png" width="128" height="32"/>
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
<image source="dead.png" width="48" height="64"/>
|
<image source="dead.png" width="48" height="64"/>
|
||||||
</tileset>
|
</tileset>
|
||||||
<tileset firstgid="149" source="ekko.tsx"/>
|
<tileset firstgid="149" source="ekko.tsx"/>
|
||||||
<objectgroup id="16" name="fishing-spots"/>
|
|
||||||
<layer id="1" name="background" width="64" height="64">
|
<layer id="1" name="background" width="64" height="64">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
@@ -825,6 +824,13 @@
|
|||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
|
<objectgroup id="16" name="fishing-spots">
|
||||||
|
<object id="2" x="182" y="512.667" width="41.3333" height="30"/>
|
||||||
|
<object id="3" x="249.333" y="342" width="48" height="28"/>
|
||||||
|
<object id="4" x="479.333" y="649.333" width="49.3333" height="40"/>
|
||||||
|
<object id="5" x="636.667" y="419.333" width="44" height="37.3333"/>
|
||||||
|
<object id="7" x="490.667" y="385.333" width="52" height="38.6667"/>
|
||||||
|
</objectgroup>
|
||||||
<objectgroup color="#ffffff" id="15" name="objects">
|
<objectgroup color="#ffffff" id="15" name="objects">
|
||||||
<object id="1" name="player" gid="149" x="497.75" y="350" width="32" height="32"/>
|
<object id="1" name="player" gid="149" x="497.75" y="350" width="32" height="32"/>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user