Skip to content

Commit 22debd5

Browse files
committed
Initial commit
1 parent 7ba0713 commit 22debd5

27 files changed

+3021
-2
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/node_modules
2+
3+
# Ignore test-related files
4+
/coverage.data
5+
/coverage/
6+
/.parcel-cache
7+
8+
# Build files
9+
/dist

LICENSE.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright 2024 Gandolfi Luca
2+
3+
Permission to use, copy, modify, and/or distribute this software for any purpose
4+
with or without fee is hereby granted,provided that the above copyright notice
5+
and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
8+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
9+
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
10+
THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
11+
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
12+
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
13+
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

README.md

-2
This file was deleted.

index.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Test</title>
5+
</head>
6+
<body>
7+
</body>
8+
<!-- <script type="module" src="dist/demos/demos.js"></script> -->
9+
<!-- <script type="module" src="dist/demos/stress.js"></script> -->
10+
<script type="module" src="dist/demos/test.js"></script>
11+
</html>

package-lock.json

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@gandolphinnn/game",
3+
"version": "1.0.0",
4+
"description": "A Typescript game engine inspired by Angular",
5+
"license": "ISC",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
8+
"files": [
9+
"dist"
10+
],
11+
"scripts": {
12+
"live": "concurrently \"tsc --watch\" \"parcel index.html --open\"",
13+
"nvm22": "nvm use 22.1.0",
14+
"nvm14": "nvm use 14.21.3"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/gandolphinnn/GameEngine.git"
19+
},
20+
"author": "Gandolphinnn",
21+
"bugs": {
22+
"url": "https://github.com/gandolphinnn/GameEngine/issues"
23+
},
24+
"homepage": "https://github.com/gandolphinnn/GameEngine#readme",
25+
"dependencies": {
26+
"@gandolphinnn/utils": "^3.1.0"
27+
}
28+
}

src/graphics/README.md

+266
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
<a name="readme-top"></a>
2+
3+
[![Contributors][contributors-shield]][contributors-url]
4+
[![Forks][forks-shield]][forks-url]
5+
[![Stargazers][stars-shield]][stars-url]
6+
[![Issues][issues-shield]][issues-url]
7+
[![ISC License][license-shield]][license-url]
8+
[![LinkedIn][linkedin-shield]][linkedin-url]
9+
10+
<br>
11+
<div align="center">
12+
13+
<h3 align="center">GameEngine</h3>
14+
<h4 align="center">DISCLAIMER: THIS DOCUMENTATION IS STILL WIP</h4>
15+
16+
<p align="center">
17+
A Typescript game engine inspired by Angular
18+
<br>
19+
<a href="https://github.com/gandolphinnn/GameEngine">Explore the repo</a>
20+
·
21+
<a href="https://github.com/gandolphinnn/GameEngine/issues">Issues</a>
22+
</p>
23+
</div>
24+
25+
<!-- TABLE OF CONTENTS -->
26+
<details>
27+
<summary>Table of Contents</summary>
28+
<ol>
29+
<li><a href="#about-the-project">About The Project</a></li>
30+
<li>
31+
<a href="#installation">Installation</a>
32+
</li>
33+
<li>
34+
<a href="#usage">Usage</a>
35+
<ul>
36+
<li><a href="#style">Style</a></li>
37+
<li><a href="#index">Index</a></li>
38+
</ul>
39+
</li>
40+
<li><a href="#contributing">Contributing</a></li>
41+
<li><a href="#license">License</a></li>
42+
</ol>
43+
</details>
44+
45+
<!-- ABOUT THE PROJECT -->
46+
47+
## About The Project
48+
49+
TODO
50+
51+
![Demo Screen Shot][product-screenshot]
52+
53+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
54+
55+
## Installation
56+
57+
```sh
58+
npm i @gandolphinnn/graphics2
59+
```
60+
61+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
62+
63+
<!-- USAGE EXAMPLES -->
64+
65+
## Usage
66+
This package have 2 source files: Style.ts and Index.ts.
67+
Style.ts is used to modify the style of the CnvElements (see Index > CnvElements).
68+
You don't need to import this file because it's already exported by Index.ts.
69+
Index.ts contains multiple types, enums and classes to draw and write inside the canvas.
70+
The HTML canvas is managed by the MainCanvas Singleton.
71+
Coord, Angle.
72+
TODO
73+
74+
<a name="style"></a>
75+
76+
### Style.ts
77+
<details>
78+
<summary>Color</summary>
79+
The Color class represents a color in RGBA format (Red, Green, Blue, Alpha).
80+
The class also has three getter methods: hexStr, rgbaStr, and rgbaObj, which return the color in hexadecimal string format, RGBA string format, and RGBA object format, respectively.
81+
82+
The Color class must be called using its static methods, since the constructor is private.
83+
- The byName method creates a Color from a color name.
84+
- The byStr method creates a Color from an RGBA string.
85+
- The byValues method creates a Color from individual RGBA values.
86+
- The byObj method creates a Color from an RGBA object.
87+
- The default method creates a Color using the default color (black, but can be modified).
88+
</details>
89+
90+
<details>
91+
<summary>Style</summary>
92+
The Style class represents a style that can be applied to a canvas element.
93+
It has 5 main properties: fillStyle, strokeStyle, lineWidth, textAlign, and font:
94+
<table>
95+
<thead>
96+
<tr>
97+
<th>Property</th>
98+
<th>Type</th>
99+
</tr>
100+
</thead>
101+
<tbody>
102+
<tr>
103+
<td>fillStyle</td>
104+
<td>SubStyle</td>
105+
</tr>
106+
<tr>
107+
<td>strokeStyle</td>
108+
<td>SubStyle</td>
109+
</tr>
110+
<tr>
111+
<td>lineWidth</td>
112+
<td>number</td>
113+
</tr>
114+
<tr>
115+
<td>textAlign</td>
116+
<td>string</td>
117+
</tr>
118+
<tr>
119+
<td>font</td>
120+
<td>string</td>
121+
</tr>
122+
</tbody>
123+
</table>
124+
125+
The SubStyle type is a union type that can be a Color, CanvasGradient, or CanvasPattern.
126+
127+
The Style class can also perform merge operations with other Style instances using the merge method: it is used to override the properties of the current Style with the properties of another Style.
128+
Undefined properties are not overridden, null properties set the merged property to undefind.
129+
The empty and default methods create an empty and default Style, respectively.
130+
These methods return the Style instance itself, allowing the methods to be chained together.
131+
</details>
132+
133+
<a name="index"></a>
134+
135+
### Index.ts
136+
TODO
137+
<details>
138+
<summary>RenderAction</summary>
139+
An enum used by every CnvElement to
140+
</details>
141+
<details>
142+
<summary>Size</summary>
143+
144+
</details>
145+
<details>
146+
<summary>Coord</summary>
147+
148+
</details>
149+
<details>
150+
<summary>Angle</summary>
151+
152+
</details>
153+
<details>
154+
<summary>Mesh</summary>
155+
A group of CnvElements with a user-defined center.
156+
</details>
157+
<details>
158+
<summary>CnvElement</summary>
159+
CnvDrawing is an abstract child of CnvElement and is the parent of all of the following classes, Text excluded.
160+
<table>
161+
<thead>
162+
<tr>
163+
<th>Class</th>
164+
<th colspan="6">Constructor</th>
165+
<th>Default RenderAction</th>
166+
<th colspan="2">Example</th>
167+
</tr>
168+
</thead>
169+
<tbody style="font-size:14px">
170+
<tr>
171+
<td>Text</td>
172+
<td colspan="3">center: Coord</td>
173+
<td colspan="3">content: string</td>
174+
<td>Fill</td>
175+
<td><img src="demos/demo_text1.png"></td>
176+
<td><img src="demos/demo_text2.png"></td>
177+
</tr>
178+
<tr>
179+
<td>Line</td>
180+
<td colspan="3">point1: Coord</td>
181+
<td colspan="3">point2: Coord</td>
182+
<td>Stroke</td>
183+
<td colspan="2"><img src="demos/demo_line.png"></td>
184+
</tr>
185+
<tr>
186+
<td>Rect</td>
187+
<td colspan="3">center: Coord</td>
188+
<td colspan="3">size: Size</td>
189+
<td>Both</td>
190+
<td colspan="2"><img src="demos/demo_rect.png"></td>
191+
</tr>
192+
<tr>
193+
<td>Poly</td>
194+
<td colspan="6">...points: Coord[]</td>
195+
<td>Both</td>
196+
<td colspan="2"><img src="demos/demo_poly.png"></td>
197+
</tr>
198+
<tr>
199+
<td>Circle</td>
200+
<td colspan="3">center: Coord</td>
201+
<td colspan="3">radius: number</td>
202+
<td>Both</td>
203+
<td colspan="2"><img src="demos/demo_circle.png"></td>
204+
</tr>
205+
<tr>
206+
<td>Arc</td>
207+
<td>center: Coord</td>
208+
<td>radius: number</td>
209+
<td>start: Angle</td>
210+
<td>end: Angle</td>
211+
<td>counterClockwise = true</td>
212+
<td>cutByCenter = true</td>
213+
<td>Both</td>
214+
<td><img src="demos/demo_arc1.png"></td>
215+
<td><img src="demos/demo_arc2.png"></td>
216+
</tr>
217+
</tbody>
218+
</table>
219+
</details>
220+
221+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
222+
223+
<!-- CONTRIBUTING -->
224+
225+
## Contributing
226+
227+
Any contributions you make are **greatly appreciated**.
228+
229+
Feel free to assign yourself an open issue or create a new one.
230+
231+
If you have a suggestion that would make this better, please fork the repo and create a pull request.
232+
You can also simply open an issue with the tag "enhancement".
233+
Don't forget to give the project a star! Thanks again!
234+
235+
1. Fork the Project
236+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
237+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
238+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
239+
5. Open a Pull Request
240+
241+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
242+
243+
<!-- LICENSE -->
244+
245+
## License
246+
247+
Distributed under the ISC License. See `LICENSE.txt` for more information.
248+
249+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
250+
251+
<!-- MARKDOWN LINKS & IMAGES -->
252+
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
253+
254+
[contributors-shield]: https://img.shields.io/github/contributors/gandolphinnn/GameEngine.svg?style=for-the-badge
255+
[contributors-url]: https://github.com/gandolphinnn/GameEngine/graphs/contributors
256+
[forks-shield]: https://img.shields.io/github/forks/gandolphinnn/GameEngine.svg?style=for-the-badge
257+
[forks-url]: https://github.com/gandolphinnn/GameEngine/network/members
258+
[stars-shield]: https://img.shields.io/github/stars/gandolphinnn/GameEngine.svg?style=for-the-badge
259+
[stars-url]: https://github.com/gandolphinnn/GameEngine/stargazers
260+
[issues-shield]: https://img.shields.io/github/issues/gandolphinnn/GameEngine.svg?style=for-the-badge
261+
[issues-url]: https://github.com/gandolphinnn/GameEngine/issues
262+
[license-shield]: https://img.shields.io/github/license/gandolphinnn/GameEngine.svg?style=for-the-badge
263+
[license-url]: https://github.com/gandolphinnn/GameEngine/blob/master/LICENSE.txt
264+
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
265+
[linkedin-url]: https://linkedin.com/in/luca-gandolfi-531a93214
266+
[product-screenshot]: demos/demo.png

0 commit comments

Comments
 (0)