Skip to content

Commit bb7d83c

Browse files
committed
refactor: apply prettier format
1 parent ddcfa1f commit bb7d83c

26 files changed

Lines changed: 607 additions & 513 deletions

.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 4,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "es5",
8+
"bracketSpacing": true,
9+
"arrowParens": "always",
10+
"jsxSingleQuote": false,
11+
"endOfLine": "lf"
12+
}

index.html

Lines changed: 105 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,115 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8">
5-
<title>Human Invaders</title>
6-
<meta name="description" content="">
7-
<meta name="author" content="Murillo">
8-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9-
<link rel="stylesheet" href="./src/library/pages/css/bootstrap.min.css">
10-
<link href="./src/library/pages/css/styles.css" type="text/css" rel="stylesheet" />
11-
</head>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Human Invaders</title>
6+
<meta name="description" content="" />
7+
<meta name="author" content="Murillo" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9+
<link rel="stylesheet" href="./src/library/pages/css/bootstrap.min.css" />
10+
<link href="./src/library/pages/css/styles.css" type="text/css" rel="stylesheet" />
11+
</head>
1212

13-
<body>
13+
<body>
14+
<!-- Start Page -->
15+
<div id="menuContainer">
16+
<div class="background"></div>
17+
<div class="github-ribbon">
18+
<a href="https://github.com/Murillo/Human-Invaders-Web-Game" target="_blank">
19+
<img
20+
decoding="async"
21+
width="149"
22+
height="149"
23+
src="https://github.blog/wp-content/uploads/2008/12/forkme_left_white_ffffff.png"
24+
class="attachment-full size-full"
25+
alt="Fork me on GitHub"
26+
loading="lazy"
27+
/>
28+
</a>
29+
</div>
30+
<div class="container-wrapper">
31+
<div class="container">
32+
<h1>Human Invaders</h1>
33+
<ul>
34+
<li><a href="#">Start</a></li>
35+
<li><a href="#" class="open-modal">About</a></li>
36+
</ul>
37+
</div>
38+
</div>
39+
</div>
1440

15-
<!-- Start Page -->
16-
<div id="menuContainer">
17-
<div class="background"></div>
18-
<div class="github-ribbon">
19-
<a href="https://github.com/Murillo/Human-Invaders-Web-Game" target="_blank">
20-
<img decoding="async" width="149" height="149" src="https://github.blog/wp-content/uploads/2008/12/forkme_left_white_ffffff.png" class="attachment-full size-full" alt="Fork me on GitHub" loading="lazy">
21-
</a>
22-
</div>
23-
<div class="container-wrapper">
24-
<div class="container">
25-
<h1>Human Invaders</h1>
26-
<ul>
27-
<li><a href="#">Start</a></li>
28-
<li><a href="#" class="open-modal">About</a></li>
29-
</ul>
30-
</div>
31-
</div>
32-
</div>
41+
<!-- Game Page -->
42+
<div id="gameContainer" class="hidden">
43+
<div class="menu-game">
44+
<!-- Name of the game -->
45+
<div class="game-name">
46+
<a href="/">Human Invaders</a>
47+
</div>
3348

34-
<!-- Game Page -->
35-
<div id="gameContainer" class="hidden" >
36-
<div class="menu-game">
37-
<!-- Name of the game -->
38-
<div class="game-name">
39-
<a href="/">Human Invaders</a>
40-
</div>
41-
42-
<!-- Game Menu -->
43-
<ul class="hidden">
44-
<li><a href="#">Option 1</a></li>
45-
</ul>
46-
</div>
49+
<!-- Game Menu -->
50+
<ul class="hidden">
51+
<li><a href="#">Option 1</a></li>
52+
</ul>
53+
</div>
4754

48-
<div id="main">
49-
<div id="menu">
50-
<div class="left-menu"></div>
51-
<div class="center-menu">
52-
<div class="text">Life:</div>
53-
<div class="result">
54-
<progress id="life" value="100" max="100">
55-
</div>
56-
<div class="text">Shots:</div>
57-
<div id="shots" class="result value"></div>
58-
<div class="text">Score:</div>
59-
<div id="score" class="result value">0</div>
60-
</div>
61-
<div class="right-menu"></div>
62-
</div>
63-
<div id="game"></div>
55+
<div id="main">
56+
<div id="menu">
57+
<div class="left-menu"></div>
58+
<div class="center-menu">
59+
<div class="text">Life:</div>
60+
<div class="result">
61+
<progress id="life" value="100" max="100"></progress>
62+
</div>
63+
<div class="text">Shots:</div>
64+
<div id="shots" class="result value"></div>
65+
<div class="text">Score:</div>
66+
<div id="score" class="result value">0</div>
67+
</div>
68+
<div class="right-menu"></div>
69+
</div>
70+
<div id="game"></div>
71+
</div>
6472
</div>
65-
</div>
66-
67-
<div id="modal">
68-
<div class="modal-header">
69-
<div class="modal-title">The story</div>
70-
<div class="modal-close">
71-
</div>
72-
</div>
73-
<div class="modal-body">
74-
<p>In the distant reaches of space, the planet of the Xerthians faces an existential threat from the relentless advance of human forces. In "Human Invaders," players take on the role of Xelar, one of the last remaining pilots of the Xerthian fleet. With his advanced spacecraft, the Phoenix, Xelar embarks on a perilous mission to repel the human incursion and defend his homeworld.</p>
7573

76-
<p>As players guide Xelar through intense space battles and dangerous missions, they must employ cunning tactics and quick reflexes to outmaneuver their human adversaries. From engaging in dogfights amidst asteroid fields to launching covert raids on enemy outposts, every decision is crucial in the fight for survival.</p>
74+
<div id="modal">
75+
<div class="modal-header">
76+
<div class="modal-title">The story</div>
77+
<div class="modal-close"></div>
78+
</div>
79+
<div class="modal-body">
80+
<p>
81+
In the distant reaches of space, the planet of the Xerthians faces an
82+
existential threat from the relentless advance of human forces. In "Human
83+
Invaders," players take on the role of Xelar, one of the last remaining pilots
84+
of the Xerthian fleet. With his advanced spacecraft, the Phoenix, Xelar embarks
85+
on a perilous mission to repel the human incursion and defend his homeworld.
86+
</p>
87+
88+
<p>
89+
As players guide Xelar through intense space battles and dangerous missions,
90+
they must employ cunning tactics and quick reflexes to outmaneuver their human
91+
adversaries. From engaging in dogfights amidst asteroid fields to launching
92+
covert raids on enemy outposts, every decision is crucial in the fight for
93+
survival.
94+
</p>
7795

78-
<p>As Xelar delves deeper into the conflict, he uncovers the true motivations behind the human invasion—a ruthless quest for domination and exploitation of the planet's resources. Fueled by greed and ambition, the human forces show no mercy in their pursuit of conquest.</p>
96+
<p>
97+
As Xelar delves deeper into the conflict, he uncovers the true motivations
98+
behind the human invasion—a ruthless quest for domination and exploitation of
99+
the planet's resources. Fueled by greed and ambition, the human forces show no
100+
mercy in their pursuit of conquest.
101+
</p>
102+
103+
<p>
104+
In the climactic showdown aboard the human flagship, the Leviathan, Xelar
105+
confronts the enemy commander in a final, epic battle to decide the fate of
106+
their planet. With explosions lighting up the void of space, players must summon
107+
all their skills to emerge victorious and ensure the survival of the Xerthian
108+
species against the relentless onslaught of the human invaders.
109+
</p>
110+
</div>
111+
</div>
79112

80-
<p>In the climactic showdown aboard the human flagship, the Leviathan, Xelar confronts the enemy commander in a final, epic battle to decide the fate of their planet. With explosions lighting up the void of space, players must summon all their skills to emerge victorious and ensure the survival of the Xerthian species against the relentless onslaught of the human invaders.</p>
81-
</div>
82-
</div>
83-
84-
<script type="module" src="./src/main.js"></script>
85-
86-
</body>
113+
<script type="module" src="./src/main.js"></script>
114+
</body>
87115
</html>

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"build": "tsc && npx vite build",
88
"start": "npx vite --port 3000",
9-
"test": "echo \"Error: no test specified\" && exit 1"
9+
"test": "echo \"Error: no test specified\" && exit 1",
10+
"prettier:format": "prettier --write \"src/**/*.{ts,js,css,html}\" index.html"
1011
},
1112
"keywords": [],
1213
"author": "Murillo Grübler",
@@ -17,6 +18,7 @@
1718
},
1819
"devDependencies": {
1920
"@types/three": "^0.160.0",
21+
"prettier": "^3.7.4",
2022
"rollup": "^4.22.4",
2123
"typescript": "^5.3.3",
2224
"vite": "^5.4.12"

src/Game.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import { CameraComponent, CameraMode } from './components/models/CameraComponent
1010
import { Device } from './util/Device';
1111

1212
export class Game {
13-
14-
private container : HTMLElement;
13+
private container: HTMLElement;
1514
private scene: THREE.Scene;
1615
private renderer: THREE.WebGLRenderer;
1716
private cameraComponent: CameraComponent;
1817
private width = window.innerWidth;
1918
private height = window.innerHeight;
2019
private spaceCraft: SpaceAlienComponent;
21-
private stars: StarsComponent
20+
private stars: StarsComponent;
2221
private components: SpaceComponentBase[] = [];
2322
private gameOverText: TextComponent;
2423
private shootComponents: ShootComponent[] = [];
@@ -41,35 +40,38 @@ export class Game {
4140
this.cameraComponent = new CameraComponent(() => this.spaceCraft.positions);
4241
}
4342

44-
public async load() : Promise<void> {
43+
public async load(): Promise<void> {
4544
/* ********* Initial Setup *********** */
4645
this.renderer.setSize(this.width, this.height);
47-
this.renderer.setClearColor("#191644");
46+
this.renderer.setClearColor('#191644');
4847
this.renderer.shadowMap.enabled = true;
4948
this.container.appendChild(this.renderer.domElement);
50-
const initialCameraMode: CameraMode = Device.isMobileDevice() ? CameraMode.Top : CameraMode.Default;
49+
const initialCameraMode: CameraMode = Device.isMobileDevice()
50+
? CameraMode.Top
51+
: CameraMode.Default;
5152
await this.cameraComponent.load(this.scene, initialCameraMode);
52-
53+
5354
/* ********* Models *********** */
5455
await this.spaceCraft.load(this.scene);
5556
await this.stars.load(this.scene);
5657
await this.gameOverText.load(this.scene);
5758
for (let i = 0; i < this.initialNumberEnemies; i++) {
5859
const spaceShuttle = await SpaceShuttleComponent.create(
59-
this.scene,
60-
this.limitsPositionEnemy);
60+
this.scene,
61+
this.limitsPositionEnemy
62+
);
6163
this.components.push(spaceShuttle);
6264
}
6365
/* ***************************** */
64-
66+
6567
/* ********* Object Axes *********** */
6668
const searchParams = new URLSearchParams(window.location.search);
6769
if (searchParams.has('axes')) {
6870
const axesHelper = new THREE.AxesHelper(15);
6971
this.scene.add(axesHelper);
7072
}
7173
/* ***************************** */
72-
74+
7375
/* ************ Light ************** */
7476
const light = new THREE.DirectionalLight('white', 5);
7577
light.position.set(10, 10, 10);
@@ -90,7 +92,7 @@ export class Game {
9092
this.shootComponents.push(shoot);
9193
}
9294

93-
this.shootComponents.forEach(item => item.update());
95+
this.shootComponents.forEach((item) => item.update());
9496
for (let i = 0; i < this.components.length; i++) {
9597
this.components[i].update();
9698

@@ -112,9 +114,10 @@ export class Game {
112114
this.spaceCraft.addScore(10);
113115

114116
const newSpaceShuttle = await SpaceShuttleComponent.create(
115-
this.scene,
117+
this.scene,
116118
this.limitsPositionEnemy,
117-
nextSpaceSpeed);
119+
nextSpaceSpeed
120+
);
118121
this.components.push(newSpaceShuttle);
119122

120123
break;
@@ -128,13 +131,13 @@ export class Game {
128131
}
129132
}
130133

131-
public start() :void {
134+
public start(): void {
132135
const render = () => {
133136
this.renderer.render(this.scene, this.cameraComponent.instance);
134-
this.update(); // Update game components such as spaceCraft, stars, etc.
137+
this.update(); // Update game components such as spaceCraft, stars, etc.
135138
TWEEN.update(); // Update the tweening library
136139
requestAnimationFrame(render);
137-
}
140+
};
138141
requestAnimationFrame(render);
139-
}
142+
}
140143
}

0 commit comments

Comments
 (0)