Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
485518a
starting test shmup
Dec 4, 2019
fd29ab0
add :autostart key to animated-sprite
Dec 5, 2019
ecba7da
normalize return [0 0] if zero length vector
Dec 6, 2019
3be969a
start shmup game, ship movement
Dec 6, 2019
d87d360
shmup assets
Dec 7, 2019
561b247
change sprites, init work on bullet system, simplify internals
Dec 7, 2019
1c16b1a
rename awwwliens-min build profile to just min
Dec 7, 2019
94808fc
preparing an example for realtime controls management
Dec 7, 2019
ace5455
remove bullets when they go outside of the screen
Dec 8, 2019
b6f871c
support dpad as an analog pad
Dec 8, 2019
c285c25
bullet a bit faster
Dec 9, 2019
b7a0e0e
update min profile for releases
Dec 9, 2019
a70fa94
update function names which are not updating scene state
Dec 10, 2019
f066c97
basic bounding rect collision detection
Dec 11, 2019
22a183d
ignore files
Dec 11, 2019
3bf961b
a bit of restructuring preparing for general collision handling
Dec 11, 2019
248059e
add enemy logic base code...lot of repeated code mmmm
Dec 12, 2019
83463e8
remove container only if the the parent is not null
Dec 13, 2019
98f4dfd
improve collision handling a bit but still not flexible enough
Dec 13, 2019
345d85c
three-way shots just to play around
Dec 13, 2019
27831d3
add a small delay between fire events
Dec 13, 2019
d083375
add get-sound utility function that returns a sound from resources cache
Dec 14, 2019
497e823
playing with Howler audio API
Dec 14, 2019
50eba93
sound do not use pixi resource loader for now
Dec 14, 2019
7891757
rename make-sound -> load
Dec 15, 2019
1fa2de5
put some sounds in the game
Dec 15, 2019
2fa01db
fix sounds_ declaration
Dec 15, 2019
7700aec
load impac sound
Dec 15, 2019
f891159
add boss entity, still no logic
Dec 15, 2019
75eceb5
very very stupid basic enemy behaviour, at least it is a start
Dec 16, 2019
dd99f98
a bit of refactoring enemy-ai -> enemy-behaviour
Dec 16, 2019
fe3ecb6
move collision detection function to proper namespace
Dec 18, 2019
d6e9bff
a bit of refactoring
Feb 16, 2020
9c8c2e2
move bullet damage to entity from view
Feb 23, 2020
5b7125c
a bit of cleaning
May 31, 2020
d5128b0
update figwheel-mail
Jun 1, 2020
7e746e4
added energy to boss
Jun 1, 2020
df111e7
organizing teh code in a kind of ECS style (WIP)
Jun 2, 2020
2bcc91c
there is something on the screen again! still WIP
Jun 2, 2020
8c89842
there is some movement again! (ECS like WIP)
Jun 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ pom.xml
.lein-plugins/
.repl
.nrepl-port
/.cpcache/
/.rebel_readline_history
11 changes: 6 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{:deps {org.clojure/clojurescript {:mvn/version "1.10.597"}
com.bhauman/figwheel-main {:mvn/version "0.2.3"}
com.bhauman/figwheel-main {:mvn/version "0.2.7"}
binaryage/oops {:mvn/version "0.7.0"}
cljsjs/pixi {:mvn/version "5.1.4-0"}}
cljsjs/pixi {:mvn/version "5.2.0-0"}
cljsjs/howler {:mvn/version "2.0.5-0"}}

:paths ["src" "target" "resources"]

:aliases {:dev
{:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]
:extra-deps {com.bhauman/figwheel-main {:mvn/version "0.2.3"}
:extra-deps {com.bhauman/figwheel-main {:mvn/version "0.2.7"}
com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}}
:awwwliens-min
{:main-opts ["-m" "figwheel.main" "-bo" "awwwliens-min"]}}}
:min
{:main-opts ["-m" "figwheel.main" "-bo" "min" "-O" "advanced"]}}}
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
[org.clojure/clojurescript "1.10.597"]
[org.clojure/core.async "0.4.500"]
[binaryage/oops "0.7.0"]
[cljsjs/pixi "5.1.2-0"]]
[cljsjs/pixi "5.1.2-0"]
[cljsjs/howler "2.0.5-0"]]

:plugins [[lein-figwheel "0.5.19"]
[lein-cljsbuild "1.1.7" :exclusions [[org.clojure/clojure]]]]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/public/images/shmup/game/boss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/public/images/shmup/game/bullet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions resources/public/images/shmup/game/player.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{"frames": {

"player-0.png":
{
"frame": {"x":1,"y":1,"w":42,"h":30},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":3,"y":0,"w":42,"h":30},
"sourceSize": {"w":48,"h":32}
},
"player-1.png":
{
"frame": {"x":1,"y":65,"w":42,"h":32},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":3,"y":0,"w":42,"h":32},
"sourceSize": {"w":48,"h":32}
},
"player-2.png":
{
"frame": {"x":1,"y":33,"w":42,"h":30},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":3,"y":0,"w":42,"h":30},
"sourceSize": {"w":48,"h":32}
},
"player-3.png":
{
"frame": {"x":1,"y":65,"w":42,"h":32},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":3,"y":0,"w":42,"h":32},
"sourceSize": {"w":48,"h":32}
}},
"animations": {
"player": ["player-0.png","player-1.png","player-2.png","player-3.png"]
},
"meta": {
"app": "https://www.codeandweb.com/texturepacker",
"version": "1.0",
"image": "player.png",
"format": "RGBA8888",
"size": {"w":44,"h":98},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:d1185eeb86274dab3a81508ace19f526:c1437acec00efe57d100076dc4fe28ad:86d5339b780aedd87b35e2b7c0a7e11b$"
}
}
Binary file added resources/public/images/shmup/game/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions resources/public/images/shmup/game/ufo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{"frames": {

"ufo-0.png":
{
"frame": {"x":1,"y":1,"w":42,"h":30},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":3,"y":2,"w":42,"h":30},
"sourceSize": {"w":48,"h":32}
},
"ufo-1.png":
{
"frame": {"x":1,"y":65,"w":42,"h":32},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":3,"y":0,"w":42,"h":32},
"sourceSize": {"w":48,"h":32}
},
"ufo-2.png":
{
"frame": {"x":1,"y":33,"w":42,"h":30},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":3,"y":2,"w":42,"h":30},
"sourceSize": {"w":48,"h":32}
},
"ufo-3.png":
{
"frame": {"x":1,"y":65,"w":42,"h":32},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":3,"y":0,"w":42,"h":32},
"sourceSize": {"w":48,"h":32}
}},
"animations": {
"ufo": ["ufo-0.png","ufo-1.png","ufo-2.png","ufo-3.png"]
},
"meta": {
"app": "https://www.codeandweb.com/texturepacker",
"version": "1.0",
"image": "ufo.png",
"format": "RGBA8888",
"size": {"w":44,"h":98},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:a0b7e703bae679cfdaffbf9c8146d488:2906306c4ca8a91aa6d00bf87ec882d4:9a4865e58023cfbd5f985c000455d470$"
}
}
Binary file added resources/public/images/shmup/game/ufo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/public/sfx/.DS_Store
Binary file not shown.
Binary file added resources/public/sfx/shmup/.DS_Store
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/explosion.mp3
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/explosion.ogg
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/gameover.mp3
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/gameover.ogg
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/impact_metal.mp3
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/impact_metal.ogg
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/shot.mp3
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/shot.ogg
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/shot_2.mp3
Binary file not shown.
Binary file added resources/public/sfx/shmup/game/shot_2.ogg
Binary file not shown.
25 changes: 25 additions & 0 deletions src/minasss_games/collision.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(ns minasss-games.collision
"Utility functions for (simple, bounding rect based) collision detection")

(defn make-rect-bounds
"Make a bounding rect based on provided position and rect size; rect is
centered around position"
[[x y] [width height]]
(let [hw (/ width 2)
hh (/ height 2)]
[(- x hw) (- y hh) (+ x hw) (+ y hh)]))

(defn rects-overlap
"Returns true if the provided rects overlaps"
[[ax-top ay-top ax-bottom ay-bottom] [bx-top by-top bx-bottom by-bottom]]
(and (< ax-top bx-bottom) (< ay-top by-bottom) (> ax-bottom bx-top) (> ay-bottom by-top)))

(comment
(make-rect-bounds [100 100] [10 10])
(make-rect-bounds [105 105] [10 10])

(rects-overlap
(make-rect-bounds [100 100] [10 10])
(make-rect-bounds [125 125] [10 10])
)
)
5 changes: 2 additions & 3 deletions src/minasss_games/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"A small experiment with PIXI javascript library"
(:require [minasss-games.pixi :as pixi]
[minasss-games.director :as director]
[minasss-games.experiments.awwwliens.intro :as awwwliens]))
;; [minasss-games.experiments.harvest-bot :as harvest-bot]))
[minasss-games.experiments.shmup.game :as shmup]))

(enable-console-print!)

Expand All @@ -12,7 +11,7 @@
(let [app (pixi/make-app {:width (.-innerWidth js/window)
:height (.-innerHeight js/window)})]
(director/init app)
(director/start-scene awwwliens/scene)
(director/start-scene shmup/scene)
app))

(defonce ^:export app (init))
Expand Down
7 changes: 5 additions & 2 deletions src/minasss_games/element.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@
(defmethod make-element :animated-sprite
[tag attrs]
(let [container (pixi/make-animated-sprite (:spritesheet attrs) (:animation-name attrs))
cleaned-attrs (dissoc attrs :spritesheet :animation-name)]
(pixi/set-attributes container cleaned-attrs)))
cleaned-attrs (dissoc attrs :spritesheet :animation-name :autostart)]
(pixi/set-attributes container cleaned-attrs)
(when (:autostart attrs)
(.play container))
container))

(defmethod make-element :text
[tag attrs]
Expand Down
40 changes: 40 additions & 0 deletions src/minasss_games/experiments/shmup/enemy_behaviour.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
(ns minasss-games.experiments.shmup.enemy-behaviour
"This namespace collects all enemy ai related functions and
state management. Still not sure how this is going to be
implemented, I expect it to be higlhy experimental and prone
to changes in structure and functionality.")

(defmulti update-state
(fn [entity] (get-in entity [::ai ::behaviour-type])))

(defmethod update-state :default
[entity]
entity)

(defmethod update-state ::horizontal-ping-pong
[{:keys [position direction] :as entity}]
(let [dir-x (first direction)
pos-x (first position)]
(cond
(> dir-x 0) (if (< 350 pos-x)
(assoc entity :direction [-1 0])
entity)
(< dir-x 0) (if (> 200 pos-x)
(assoc entity :direction [1 0])
entity)
:else entity)))

;; this multi method is used to create the initial state
;; for the specified behaviour type and "attach" it to the ::ai key
;; of the entity; this is needed because the main idea, for now,
;; is to change entity properties to reflect selected behaviour.
(defmulti init-state
(fn [behaviour-type _entity] behaviour-type))

(defmethod init-state ::horizontal-ping-pong
[behaviour-type entity]
(-> entity
(assoc
::ai {::behaviour-type behaviour-type}
:direction [1 0]
:speed 10)))
Loading