Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Team 10
Global Game Jam 2019
Cock O The
Commits
2b47c824
Commit
2b47c824
authored
Jan 26, 2019
by
Andrea Ruggiero
⚡
Browse files
Cose?
parents
fb67b20b
40e311a5
Pipeline
#6387
skipped with stage
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/FallManager.css
0 → 100644
View file @
2b47c824
@-webkit-keyframes
falling
{
0
%
{
-webkit-transform
:
translate3d
(
300
,
0
,
0
)
rotate
(
0deg
);
}
100
%
{
-webkit-transform
:
translate3d
(
-350px
,
700px
,
0
)
rotate
(
90deg
);
opacity
:
0
;
}
}
.falling
{
animation
:
falling
5s
infinite
}
\ No newline at end of file
src/FallManager.js
0 → 100644
View file @
2b47c824
import
'
./FallManager.css
'
class
FallManager
{
fallings
=
[]
maxHeight
=
0
constructor
()
{
window
.
onresize
=
()
=>
{
this
.
maxHeight
=
document
.
documentElement
.
scrollHeight
}
this
.
maxHeight
=
document
.
documentElement
.
scrollHeight
}
tick
()
{
this
.
fallings
.
forEach
(
a
=>
{
const
rect
=
a
.
element
.
getBoundingClientRect
()
a
.
top
+=
2
+
Math
.
round
(
Math
.
random
()
*
4
);
a
.
ticks
--
;
a
.
clonedElement
.
style
=
`z-index: 10000; position: absolute; top:
${
a
.
top
}
px; left:
${
rect
.
left
+
window
.
scrollX
}
px;
width:
${
a
.
element
.
offsetWidth
}
px; height:
${
a
.
element
.
offsetHeight
}
; opacity:
${
a
.
ticks
>
50
?
(
a
.
ticks
-
50
)
/
50
:
1
}
`
if
(
a
.
ticks
===
0
)
{
a
.
clonedElement
.
remove
()
}
if
(
a
.
top
<
0
||
a
.
top
>
this
.
maxHeight
-
100
)
{
a
.
ticks
=
0
a
.
clonedElement
.
remove
()
}
})
this
.
fallings
=
this
.
fallings
.
filter
(
a
=>
a
.
ticks
!==
0
)
if
(
Math
.
round
(
Math
.
random
()
*
50
)
===
25
)
{
const
elements
=
Array
.
from
(
document
.
querySelectorAll
(
'
.real-usable
'
))
const
element
=
elements
[
Math
.
round
(
Math
.
random
()
*
elements
.
length
)]
const
clonedElement
=
element
.
cloneNode
(
true
)
document
.
getElementById
(
'
game-container
'
).
appendChild
(
clonedElement
)
console
.
log
(
element
)
const
rect
=
element
.
getBoundingClientRect
()
const
falling
=
{
element
,
clonedElement
,
ticks
:
100
+
Math
.
round
(
Math
.
random
()
*
50
),
top
:
rect
.
top
+
window
.
scrollY
}
element
.
style
=
'
opacity: 0
'
clonedElement
.
style
=
`z-index: 100000; position: absolute; top:
${
falling
.
top
}
px; left:
${
rect
.
left
+
window
.
scrollX
}
px;
width:
${
element
.
offsetWidth
}
px; height:
${
element
.
offsetHeight
}
; opacity: 1`
clonedElement
.
classList
.
remove
(
'
real-usable
'
)
element
.
classList
.
remove
(
'
real-usable
'
)
element
.
classList
.
remove
(
'
usable
'
)
clonedElement
.
classList
.
add
(
'
falling
'
)
this
.
fallings
.
push
(
falling
)
}
/*this.setFallable()
this.fall()*/
}
fall
()
{
let
fallables
=
document
.
querySelectorAll
(
'
.fallable
'
)
console
.
log
(
fallables
)
for
(
let
i
=
0
;
i
<
fallables
.
length
;
i
++
)
{
var
currentY
=
fallables
[
i
].
style
.
top
.
replace
(
'
px
'
,
''
)
if
(
currentY
<=
this
.
maxheight
)
{
currentY
=
++
currentY
+
1
fallables
[
i
].
style
.
top
=
currentY
+
'
px
'
}
}
}
setFallable
()
{
let
usables
=
document
.
querySelectorAll
(
'
.real-usable
'
)
for
(
let
i
=
0
;
i
<
usables
.
length
;
i
++
)
{
let
random
=
Math
.
floor
((
Math
.
random
()
*
100
)
+
1
)
if
(
random
==
1
&&
!
usables
[
i
].
classList
.
contains
(
'
fallable
'
))
{
let
_x
=
usables
[
i
].
getBoundingClientRect
()[
'
x
'
]
let
_y
=
usables
[
i
].
getBoundingClientRect
()[
'
y
'
]
if
(
!
usables
[
i
].
classList
)
{
usables
[
i
].
classList
=
[]
}
usables
[
i
].
classList
.
add
(
'
fallable
'
)
usables
[
i
].
style
.
top
=
_y
+
'
px
'
usables
[
i
].
style
.
left
=
_x
+
'
px
'
}
}
}
}
export
default
FallManager
\ No newline at end of file
src/Game.css
View file @
2b47c824
html
{
scroll-behavior
:
smooth
;
}
...
...
@@ -11,6 +12,7 @@ html {
padding
:
1em
;
border
:
1px
solid
#ddd
;
box-shadow
:
0
10px
20px
rgba
(
0
,
0
,
0
,
0.19
),
0
6px
6px
rgba
(
0
,
0
,
0
,
0.23
);
z-index
:
5001
}
.win-game-modal-container
{
...
...
@@ -24,6 +26,7 @@ html {
top
:
0
;
backdrop-filter
:
blur
(
10px
);
-webkit-backdrop-filter
:
blur
(
10px
);
z-index
:
5000
}
#game-close
{
...
...
src/Game.js
View file @
2b47c824
...
...
@@ -8,6 +8,7 @@ import bgmusic from './assets/bgmusic.mp3'
import
shootSFX
from
'
./assets/shootSFX.mp3
'
import
PageParser
from
'
./PageParser
'
import
Ticker
from
'
./Ticker
'
import
FallManager
from
'
./FallManager
'
;
import
{
base64ToArrayBuffer
}
from
'
./Utils
'
import
Multiplayer
from
'
./Multiplayer
'
...
...
@@ -23,8 +24,8 @@ class Game {
homeFinder
=
null
pageParser
=
null
ticker
=
null
fallmanager
=
null
;
multiplayer
=
null
bgmusic
=
null
audioCtx
=
null
source
=
null
...
...
@@ -73,6 +74,7 @@ class Game {
start
()
{
this
.
ticker
=
new
Ticker
(
this
)
this
.
started
=
true
this
.
UIManager
=
new
UIManager
()
this
.
UIManager
.
setTimerSeconds
(
60
)
this
.
goal
=
this
.
homeFinder
.
selectGoal
()
...
...
@@ -85,6 +87,7 @@ class Game {
behavior
:
'
smooth
'
});
setTimeout
(()
=>
{
this
.
fallmanager
=
new
FallManager
();
this
.
pageParser
=
new
PageParser
(
this
)
this
.
character
=
new
Character
(
this
)
this
.
multiplayer
=
new
Multiplayer
(
this
)
...
...
@@ -93,6 +96,7 @@ class Game {
this
.
ticker
.
add
(
this
.
gameFinishChecker
)
this
.
ticker
.
add
(
this
.
UIManager
)
this
.
UIManager
.
startTimer
()
this
.
ticker
.
add
(
this
.
fallmanager
)
},
this
.
delayBeforeStart
)
this
.
playSound
(
this
.
bgmusic
)
...
...
@@ -154,6 +158,11 @@ class Game {
this
.
source
.
start
(
0
);
});
}
}
export
default
Game
\ No newline at end of file
src/PageParser.js
View file @
2b47c824
import
Enemy
from
'
./Enemy
'
class
PageParser
{
...
...
@@ -21,9 +20,18 @@ class PageParser {
this
.
game
=
game
this
.
getAllTextNodes
(
skipFunction
)
this
.
getAllTextNodes
(
skipFunction
)
this
.
getAllTextNodes
(
skipFunction
)
this
.
getAllTextNodes
(
skipFunction
)
this
.
getAllTextNodes
(
skipFunction
)
// Don't ask .
}
escapeHtml
(
text
)
{
return
text
.
replace
(
'
&
'
,
"
&
"
)
.
replace
(
'
<
'
,
"
<
"
)
.
replace
(
'
>
'
,
"
>
"
)
.
replace
(
'
"
'
,
'
"
'
)
.
replace
(
"
'
"
,
"
'
"
);
}
getAllTextNodes
(
skipFunction
=
null
)
{
let
nodes
=
[]
...
...
@@ -41,15 +49,23 @@ class PageParser {
if
(
!
elements
[
i
].
classList
)
elements
[
i
].
classList
=
[]
elements
[
i
].
classList
.
add
(
'
usable
'
)
}
if
(
elements
[
i
][
'
nodeName
'
]
!==
'
SCRIPT
'
&&
elements
[
i
][
'
nodeName
'
]
!==
'
STYLE
'
)
{
if
(
(
elements
[
i
][
"
nodeName
"
]
==
'
SPAN
'
)
&&
elements
[
i
][
"
children
"
].
length
==
0
)
{
if
(
!
elements
[
i
].
classList
)
elements
[
i
].
classList
=
[]
elements
[
i
].
classList
.
add
(
'
usable
'
)
continue
;
}
if
(
elements
[
i
][
'
nodeName
'
]
!==
'
SCRIPT
'
&&
elements
[
i
][
'
nodeName
'
]
!==
'
STYLE
'
&&
!
elements
[
i
].
classList
.
contains
(
"
usable
"
)
)
{
nodes
.
push
(((
elements
[
i
][
'
childNodes
'
])))
for
(
let
j
=
0
;
j
<
elements
[
i
][
"
childNodes
"
].
length
;
j
++
)
{
for
(
let
j
=
0
;
j
<
elements
[
i
][
"
childNodes
"
].
length
;
j
++
)
{
if
(
typeof
elements
[
i
][
'
childNodes
'
][
j
][
'
nodeName
'
]
!=
'
undefined
'
)
{
if
(
elements
[
i
][
'
childNodes
'
][
j
][
'
nodeName
'
]
===
'
#text
'
)
{
if
(
elements
[
i
][
'
childNodes
'
][
j
][
'
nodeName
'
]
===
'
#text
'
||
elements
[
i
][
'
childNodes
'
][
j
][
'
nodeName
'
]
===
'
B
'
||
elements
[
i
][
'
childNodes
'
][
j
][
'
nodeName
'
]
===
'
STRONG
'
)
{
if
(
elements
[
i
][
'
childNodes
'
][
j
][
'
textContent
'
].
trim
().
length
!==
0
)
{
let
textthathastobeputintospans
=
elements
[
i
][
'
childNodes
'
][
j
][
'
textContent
'
]
let
textthathastobeputintospans
=
elements
[
i
][
'
childNodes
'
][
j
][
'
textContent
'
]
.
replace
(
'
'
,
'
'
);
if
(
skipFunction
!==
null
&&
!
skipFunction
(
elements
[
i
]))
continue
elements
[
i
].
innerHTML
=
elements
[
i
].
innerHTML
.
replace
(
textthathastobeputintospans
,
'
<span>
'
+
textthathastobeputintospans
+
'
</span>
'
)
elements
[
i
].
innerHTML
=
elements
[
i
].
innerHTML
.
replace
(
'
'
,
'
'
).
replace
(
textthathastobeputintospans
,
'
<span>
'
+
textthathastobeputintospans
+
'
</span>
'
)
if
(
!
elements
[
i
][
'
childNodes
'
][
j
])
continue
if
(
typeof
elements
[
i
][
'
childNodes
'
][
j
].
classList
!=
'
undefined
'
)
{
elements
[
i
][
'
childNodes
'
][
j
].
classList
.
add
(
'
usable
'
)
...
...
@@ -92,6 +108,16 @@ class PageParser {
this.game.ticker.add(enemy)
})*/
}
/* this.ticker.add(this.UIManager)
this.ticker.add(this.setFallable)*/
}
export
default
PageParser
\ No newline at end of file
export
default
PageParser
src/Projectile.css
View file @
2b47c824
...
...
@@ -5,10 +5,12 @@
background
:
#ffbc24
;
border
:
6px
solid
pink
;
position
:
absolute
;
z-index
:
5000
}
.game-explosion
{
width
:
100px
;
height
:
100px
;
position
:
absolute
;
z-index
:
5000
}
\ No newline at end of file
src/Usable.css
View file @
2b47c824
/*
.real-usable {
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
min-width: 40px;
display: inline-block;
background: linear-gradient(to right, #36992f 0%,#327208 17%,#128212 33%,#008a00 57%,#007c06 81%,#116000 100%);
<<<<<<< HEAD
}
.fallable
{
position: absolute;
=======
z-index: 5000;
background-size: contain;
padding: .1em .1em;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment