Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
oetzit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
commul
oetzit
Commits
b0b6534f
Commit
b0b6534f
authored
2 years ago
by
Paolo.Brasolin
Browse files
Options
Downloads
Patches
Plain Diff
feat: #fe atmosphere
parent
37299595
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
frontend/src/js/background_scene.ts
+93
-2
93 additions, 2 deletions
frontend/src/js/background_scene.ts
frontend/src/js/fight_scene.ts
+2
-0
2 additions, 0 deletions
frontend/src/js/fight_scene.ts
frontend/src/js/game_over_scene.ts
+6
-0
6 additions, 0 deletions
frontend/src/js/game_over_scene.ts
with
101 additions
and
2 deletions
frontend/src/js/background_scene.ts
+
93
−
2
View file @
b0b6534f
...
...
@@ -16,11 +16,29 @@ const LAYERS = {
b11
:
"
assets/background_layers/Layer_0000_9.png
"
,
};
// prettier-ignore
const
HSL_COLORS
=
[
[
"
#170048
"
,
"
#fbb468
"
],
// 06:00
[
"
#ffefd6
"
,
"
#b8ffc7
"
],
// 09:00
[
"
#ffffff
"
,
"
#ffffff
"
],
// 12:00
[
"
#fff9b8
"
,
"
#b0ff88
"
],
// 15:00
[
"
#def3ff
"
,
"
#77e176
"
],
// 18:00
[
"
#f490ff
"
,
"
#fdbf7d
"
],
// 21:00
[
"
#474095
"
,
"
#2d912d
"
],
// 00:00
[
"
#ff1111
"
,
"
#ff9bc0
"
],
// 03:00
]
const
COLORS
=
HSL_COLORS
.
map
((
pair
)
=>
pair
.
map
(
Phaser
.
Display
.
Color
.
HexStringToColor
),
);
export
default
class
BackgroundScene
extends
Phaser
.
Scene
{
layers
:
Phaser
.
GameObjects
.
TileSprite
[];
atmosphere
:
Phaser
.
Tweens
.
Tween
;
curtain
:
Phaser
.
GameObjects
.
Rectangle
;
constructor
()
{
super
(
"
hea
d
"
);
super
(
"
backgroun
d
"
);
this
.
layers
=
[];
}
...
...
@@ -28,19 +46,92 @@ export default class BackgroundScene extends Phaser.Scene {
Object
.
entries
(
LAYERS
).
forEach
(([
key
,
path
])
=>
this
.
load
.
image
(
key
,
path
));
}
interpColor
(
source
:
Phaser
.
Display
.
Color
,
target
:
Phaser
.
Display
.
Color
,
t
:
number
,
)
{
return
Phaser
.
Display
.
Color
.
GetColor
(
source
.
red
+
(
target
.
red
-
source
.
red
)
*
t
,
source
.
green
+
(
target
.
green
-
source
.
green
)
*
t
,
source
.
blue
+
(
target
.
blue
-
source
.
blue
)
*
t
,
);
}
createBackground
()
{
const
scale
=
this
.
cameras
.
main
.
height
/
LAYERS_HEIGHT
;
const
width
=
this
.
cameras
.
main
.
width
/
scale
;
const
height
=
this
.
cameras
.
main
.
height
/
scale
;
Object
.
keys
(
LAYERS
).
forEach
((
textureKey
)
=>
{
const
tileSprite
=
this
.
add
.
tileSprite
(
0
,
0
,
width
,
height
,
textureKey
);
tileSprite
.
setOrigin
(
0
).
setScale
(
scale
);
tileSprite
.
setOrigin
(
0
).
setScale
(
scale
).
setTint
(
// NOTE: this is a bit lazy but meh.
this
.
interpColor
(
COLORS
[
0
][
0
],
COLORS
[
0
][
0
],
0
),
this
.
interpColor
(
COLORS
[
0
][
0
],
COLORS
[
0
][
0
],
0
),
this
.
interpColor
(
COLORS
[
0
][
1
],
COLORS
[
0
][
1
],
0
),
this
.
interpColor
(
COLORS
[
0
][
1
],
COLORS
[
0
][
1
],
0
),
);
this
.
layers
.
push
(
tileSprite
);
});
}
createAtmosphere
()
{
this
.
atmosphere
=
this
.
tweens
.
addCounter
({
paused
:
true
,
from
:
0
,
to
:
255
*
(
COLORS
.
length
-
1
),
duration
:
20
*
60
*
1000
,
// 3000 * (COLORS.length - 1),
onUpdate
:
(
tween
)
=>
{
const
value
=
(
tween
.
getValue
()
%
256
)
/
256
;
const
i
=
Math
.
floor
(
tween
.
getValue
()
/
256
);
const
f
=
(
i
+
1
)
%
COLORS
.
length
;
const
topCol
=
this
.
interpColor
(
COLORS
[
i
][
0
],
COLORS
[
f
][
0
],
value
);
const
botCol
=
this
.
interpColor
(
COLORS
[
i
][
1
],
COLORS
[
f
][
1
],
value
);
this
.
layers
.
forEach
((
layer
)
=>
layer
.
setTint
(
topCol
,
topCol
,
botCol
,
botCol
),
);
},
});
}
createCurtain
()
{
this
.
curtain
=
this
.
add
.
rectangle
(
0
,
0
,
this
.
cameras
.
main
.
displayWidth
,
this
.
cameras
.
main
.
displayHeight
,
0x000000
,
1
,
)
.
setAlpha
(
0
)
.
setOrigin
(
0
,
0
);
}
dropCurtain
()
{
this
.
tweens
.
add
({
targets
:
this
.
curtain
,
alpha
:
1
,
ease
:
"
Linear
"
,
delay
:
0
,
duration
:
200
,
});
}
liftCurtain
()
{
this
.
tweens
.
add
({
targets
:
this
.
curtain
,
alpha
:
0
,
ease
:
"
Linear
"
,
delay
:
0
,
duration
:
200
,
});
}
create
()
{
this
.
createBackground
();
this
.
createAtmosphere
();
this
.
createCurtain
();
// this.scale.displaySize.setAspectRatio(
// this.cameras.main.width / this.cameras.main.height,
// );
...
...
This diff is collapsed.
Click to expand it.
frontend/src/js/fight_scene.ts
+
2
−
0
View file @
b0b6534f
...
...
@@ -11,6 +11,7 @@ import * as Types from "../../../backend/src/types";
import
Foe
from
"
./foe
"
;
import
Typewriter
from
"
./typewriter
"
;
import
HUD
from
"
./hud
"
;
import
BackgroundScene
from
"
./background_scene
"
;
const
DEVICE_KEY
=
"
OETZI/DEVICE_ID
"
;
...
...
@@ -192,6 +193,7 @@ export default class FightScene extends Phaser.Scene {
}
async
create
(
data
:
{
music
:
Phaser
.
Sound
.
BaseSound
})
{
(
this
.
scene
.
get
(
"
background
"
)
as
BackgroundScene
).
atmosphere
.
play
();
this
.
musicSoftReplace
(
this
.
sound
.
add
(
"
bkg_main_1
"
,
{
loop
:
true
}),
data
.
music
,
...
...
This diff is collapsed.
Click to expand it.
frontend/src/js/game_over_scene.ts
+
6
−
0
View file @
b0b6534f
import
"
phaser
"
;
import
BackgroundScene
from
"
./background_scene
"
;
export
default
class
GameOverScene
extends
Phaser
.
Scene
{
music
!
:
Phaser
.
Sound
.
BaseSound
;
...
...
@@ -23,6 +24,10 @@ export default class GameOverScene extends Phaser.Scene {
}
create
(
data
:
{
music
?:
Phaser
.
Sound
.
BaseSound
})
{
(
this
.
scene
.
get
(
"
background
"
)
as
BackgroundScene
).
dropCurtain
();
(
this
.
scene
.
get
(
"
background
"
)
as
BackgroundScene
).
atmosphere
.
stop
()
.
restart
();
this
.
musicHardReplace
(
this
.
sound
.
add
(
"
bkg_failure
"
,
{
loop
:
false
}),
data
.
music
,
...
...
@@ -65,6 +70,7 @@ export default class GameOverScene extends Phaser.Scene {
}
startFight
()
{
(
this
.
scene
.
get
(
"
background
"
)
as
BackgroundScene
).
liftCurtain
();
this
.
scene
.
start
(
"
welcome
"
,
{
music
:
this
.
music
});
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment