diff --git a/Documentation/README.md b/Documentation/README.md deleted file mode 100644 index ae3434e..0000000 --- a/Documentation/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Diagrammes - -## Diagramme UML - -Les modélisation UML du projet sont disponibles sous forme de [PlantUML](https://www.plantuml.com) dans ce dossier. Les diagrammes sont générés automatiquement à partir des fichiers `.puml` afin de pouvoir être versionnés et mis à jour facilement. Vous pouvez les consulter en récupérant le contenu des fichiers et en les prévisualisant sur [PlantUML](https://www.plantuml.com/plantuml). - -- [Diagramme de classes](./UML/class-diagram.puml) -- [Diagramme d'activités](./UML/activity-diagram/activity-diagram.puml) -- [Diagramme de cas d'utilisation](./UML/use-case-diagram.puml) -- [Diagramme d'états](./UML/state-diagram/state-diagram.puml) - -## Diagramme de Gantt - -La modélisation du diagramme de Gantt est générée automatiquement à partir du fichier [gant-diagram.gantt](./gantt-diagram.gantt) en utilisant n'importe quel outil de visualisation de diagramme de Gantt. Vous pouvez par exemple installer [GanttProject](https://www.ganttproject.biz/) ou utiliser l'outil en ligne [Online Gantt](https://www.onlinegantt.com/#/gantt). diff --git a/Documentation/Sujet-Projet-Geometry-Dash.pdf b/Documentation/Sujet-Projet-Geometry-Dash.pdf index 124e5fe..2cbce73 100644 Binary files a/Documentation/Sujet-Projet-Geometry-Dash.pdf and b/Documentation/Sujet-Projet-Geometry-Dash.pdf differ diff --git a/Documentation/diagrammes.md b/Documentation/diagrammes.md new file mode 100644 index 0000000..afcfa61 --- /dev/null +++ b/Documentation/diagrammes.md @@ -0,0 +1,14 @@ +# Diagrammes + +## Diagramme UML + +Les modélisations UML du projet sont générés à partir des fichiers `.puml` dans le dossier [UML](./UML). Vous pouvez les consulter en récupérant le contenu des fichiers et en les prévisualisant sur [PlantUML](https://www.plantuml.com/plantuml). + +- [Diagramme de classes](./UML/class-diagram.puml) +- [Diagramme d'activités](./UML/activity-diagram/activity-diagram.puml) +- [Diagramme de cas d'utilisation](./UML/use-case-diagram.puml) +- [Diagramme d'états](./UML/state-diagram/state-diagram.puml) + +## Diagramme de Gantt + +La modélisation du diagramme de Gantt est générée à partir du fichier [gant-diagram.gantt](./gantt-diagram.gantt) en utilisant n'importe quel outil de visualisation de diagramme de Gantt. Vous pouvez par exemple installer [GanttProject](https://www.ganttproject.biz/) ou utiliser l'outil en ligne [Online Gantt](https://www.onlinegantt.com/#/gantt). diff --git a/Documentation/unity.md b/Documentation/unity.md new file mode 100644 index 0000000..2acaa7c --- /dev/null +++ b/Documentation/unity.md @@ -0,0 +1,231 @@ +# Unity + +Documentation about the basics of [Unity](https://unity.com/) (cross-platform game engine) and most useful things to know, to develop a 2D game. + +## Links + +- [Unity 6 User Manual](https://docs.unity3d.com/Manual/index.html) +- [YouTube (Game Maker's Toolkit) - The Unity Tutorial For Complete Beginners](https://www.youtube.com/watch?v=XtQMytORBmM) + +## Unity Interface (4 panels by default) + +- Project (bottom): Contains everything that is in our game, like sprites (2D graphical object/image), sound effects, scripts, fonts, etc. Some of them are made in Unity. We can also import files from our computer. +- Hierarchy (left): Contains all the stuff that's in the current scene. +- Scene (middle): A **scene** is a level in our game. Scene are made up of **GameObjects**. +- Inspector (right): Shows the properties and **components** of the selected **GameObject**. + +## GameObject + +`GameObject` is an invisible container. Properties: + +- **Name** +- **Transform** + - a Position (`X`, `Y`, `Z`) + - a Rotation (`X`, `Y`, `Z`) + - a Scale (`X`, `Y`, `Z`) +- **Components**: to add extra features (e.g: `SpriteRenderer` to display a sprite, `BoxCollider2D` to detect collisions, etc). + +To create a new `GameObject`, we can right-click in the `Hierarchy` panel and select `Create Empty`. + +`GameObject` can have children `GameObject`s. Nesting `GameObject`s is useful to group objects together, and for example, move them all at once, just by moving the parent `GameObject`. + +## Components + +### SpriteRenderer + +The `SpriteRenderer` component renders the Sprite and controls how it visually appears in a Scene. Fields: + +- `Sprite`: to select the sprite to render. We can drag a sprite from the `Project` panel. + +### Camera + +The `Camera` component renders the scene from the point of view of the camera. Fields: + +- `Size`: to zoom in and out. +- `Background`: background color. + +### Rigidbody2D + +The `Rigidbody2D` component allows a `GameObject` to react to physics (gravity, mass). + +### Collider2D + +The `Collider2D` component allows a `GameObject` to interact with other `GameObject`s. It allows to detect collisions (control hitboxes). + +There are different types of colliders: + +- `BoxCollider2D`: a box-shaped collider. +- `CircleCollider2D`: a circle-shaped collider. + +etc. + +### Script + +Allows to make our own custom component with C# code. + +`MonoBehaviour` is the base class from which script derives. It offers life cycle functions: `Start`, `Update`, `OnEnable` etc. + +It has a property called `gameObject` which is the `GameObject` to which the script is attached. For example, to change the name of the `GameObject` to which the script is attached, we can write `gameObject.name = "New Name";`. + +```csharp +using UnityEngine; + +public class BirdScript : MonoBehaviour +{ + // Start is called once before the first execution of Update after the MonoBehaviour is created + public void Start() + { + + } + + // Update is called every frame over, over and over again, run as often as it can depending on the frame rate and computer performance + public void Update() + { + + } +} +``` + +## UnityEngine C# + +### Script communication with other components (for example with `Rigidbody2D`) + +By default, the script is unaware of the other components attached to the `GameObject`. + +To access the `Rigidbody2D` component from the script, we can create a public field of type `Rigidbody2D` in the script. + +```csharp +using UnityEngine; + +public class BirdScript : MonoBehaviour +{ + public Rigidbody2D myRigidBody; +} +``` + +In the Unity Editor, the `myRigidBody` field will appear in the `Inspector` panel. We can drag the `Rigidbody2D` component from the `GameObject` to the `myRigidBody` field. + +### Input + +To get input from the player, we can use the `Input` class. + +For example, to detect when the player presses the `Space` key, we can use the `Input.GetKeyDown` method. + +In the following example, when the player presses the `Space` key, the bird object will jump. + +```csharp +using UnityEngine; + +public class BirdScript : MonoBehaviour +{ + public Rigidbody2D rigidBody; + + public void Update() + { + if (Input.GetKeyDown(KeyCode.Space)) + { + rigidBody.linearVelocity = Vector2.up * 10; + } + } +} +``` + +### `Time.deltaTime` + +`Time.deltaTime` is the interval in seconds from the last frame to the current one. + +It's useful to make the game frame rate independent, as it ensures that the game runs at the same speed on different computers, (code inside `Update` method). + +```csharp +using UnityEngine; + +public class BirdScript : MonoBehaviour +{ + public Rigidbody2D rigidBody; + + public void Update() + { + // Move the bird to the right, 5 units per second + transform.position = transform.position + (5 * Time.deltaTime * Vector3.right); + } +} +``` + +### `Debug.Log` + +`Debug.Log` is a method that prints a message to the console, helpful for debugging. + +```csharp +using UnityEngine; + +public class BirdScript : MonoBehaviour +{ + public void Start() + { + Debug.Log("Hello World!"); + } +} +``` + +### `Destroy` + +To destroy a `GameObject`, we can use the `Destroy` method. Useful for performance optimization, for example to destroy a pipe that is no longer visible on the screen. + +For example, to destroy a pipe when it reaches a certain position on the left side of the screen (`deadZone`): + +```csharp +using UnityEngine; + +public class PipeMoveScript : MonoBehaviour +{ + public float moveSpeed = 5; + public float deadZone = -45; + + public void Update() + { + transform.position = transform.position + (Time.deltaTime * moveSpeed * Vector3.left); + + if (transform.position.x < deadZone) + { + Destroy(gameObject); + } + } +} +``` + +### Prefabricated `GameObject` + +`GameObject` can be prefabricated. Prefabs are reusable `GameObject`s that can be created and modified in the `Project` panel (like a blueprint), for example to spawn objects in the scene dynamically at runtime, with `Instantiate`. + +```csharp +using UnityEngine; + +public class PipeSpawnScript : MonoBehaviour +{ + public GameObject pipe; + + public void Start() + { + Instantiate(pipe, transform.position, transform.rotation); + } +} +``` + +### `[ContextMenu]` + +The `[ContextMenu]` attribute allows to add a custom function to the context menu of the script in the Unity Editor. + +It's useful for debugging, to be able to call a function directly from the Unity Editor. + +```csharp +using UnityEngine; + +public class LogicManagerScript : MonoBehaviour +{ + [ContextMenu("AddScore")] + public void AddScore() + { + Debug.Log("Score added!"); + } +} +``` diff --git a/README.md b/README.md index 5afd1c2..37c4c62 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,11 @@ Développement d'une reproduction du jeu [Geometry Dash](https://fr.wikipedia.or - [Sujet](./Documentation/Sujet-Projet-Geometry-Dash.pdf) - [Kanban Board (Trello)](https://trello.com/b/ugG5Siaw/cnam-geometry-dash) -- [Diagrammes UML](./UML) +- [Explication Diagrammes](./Documentation/diagrammes.md) + - [Diagramme de GANTT](./Documentation/gantt-diagram.gantt) + - [Diagrammes UML](./Documentation/UML) - [Conventions développement informatique](./Documentation/conventions.md) +- [Unity - Prise de notes (Anglais)](./Documentation/unity.md) ## Prérequis