mirror of
				https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
				synced 2025-06-27 11:58:51 +02:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			5dc42fec95
			...
			51404e5cc6
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					51404e5cc6 | ||
| 
						 | 
					af64c2e0f4 | ||
| c6be884024 | 
@@ -5,44 +5,40 @@ public class PlayerScript : MonoBehaviour
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public Rigidbody2D rigidBody;
 | 
					    public Rigidbody2D rigidBody;
 | 
				
			||||||
    public GameObject playerObject;
 | 
					    public GameObject playerObject;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public ParticleSystem particle;
 | 
					    public ParticleSystem particle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private bool wantsToJump = false;
 | 
					 | 
				
			||||||
    public bool isColliding = true;
 | 
					    public bool isColliding = true;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public AudioSource audioSource;
 | 
					    public AudioSource audioSource;
 | 
				
			||||||
 | 
					    private bool hasStarted = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private bool canJump = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void Start()
 | 
					    public void Start()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        var mainModule = particle.main;
 | 
					        var mainModule = particle.main;
 | 
				
			||||||
        mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
 | 
					        mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
 | 
				
			||||||
        particle.transform.parent = null;
 | 
					        particle.transform.parent = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Invoke(nameof(EnableInput), 0.1f);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void EnableInput()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        hasStarted = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void Update()
 | 
					    public void Update()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        transform.position += Time.deltaTime * 8.6f * Vector3.right;
 | 
					        rigidBody.linearVelocity = new Vector2(8.6f, rigidBody.linearVelocity.y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (Input.GetKey(KeyCode.Space))
 | 
					        if (hasStarted && isColliding && Input.GetKey(KeyCode.Space) && canJump)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            wantsToJump = true;
 | 
					            Jump();
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            wantsToJump = false;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!IsJumping())
 | 
					        if (!IsJumping())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            AlignRotation();
 | 
					            AlignRotation();
 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (wantsToJump)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Jump();
 | 
					 | 
				
			||||||
                wantsToJump = false;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            particle.gameObject.SetActive(true);
 | 
					            particle.gameObject.SetActive(true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
@@ -88,13 +84,14 @@ public class PlayerScript : MonoBehaviour
 | 
				
			|||||||
    public void OnCollisionEnter2D(Collision2D collision)
 | 
					    public void OnCollisionEnter2D(Collision2D collision)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        isColliding = true;
 | 
					        isColliding = true;
 | 
				
			||||||
 | 
					        canJump = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (collision.gameObject.tag == "Kill")
 | 
					        if (collision.gameObject.CompareTag("Kill"))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 | 
					            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (collision.gameObject.tag == "Win")
 | 
					        if (collision.gameObject.CompareTag("Win"))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            SceneManager.LoadScene("HomeScene");
 | 
					            SceneManager.LoadScene("HomeScene");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,46 +5,107 @@ skinparam classAttributeIconSize 0
 | 
				
			|||||||
skinparam classFontStyle Bold
 | 
					skinparam classFontStyle Bold
 | 
				
			||||||
hide enum methods
 | 
					hide enum methods
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Position {
 | 
					class GameManager {
 | 
				
			||||||
  {field} + column: Integer
 | 
					  - score: int
 | 
				
			||||||
  {field} + row: Integer
 | 
					  - isPaused: Boolean
 | 
				
			||||||
 | 
					  + StartGame()
 | 
				
			||||||
  {method} + Position(column: Integer, row: Integer)
 | 
					  + RestartLevel()
 | 
				
			||||||
  {method} + equals(position: Position)
 | 
					  + PauseGame()
 | 
				
			||||||
 | 
					  + ResumeGame()
 | 
				
			||||||
 | 
					  + UpdateScore(points: int)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Level {
 | 
					class Level {
 | 
				
			||||||
  {field} + songPath: String
 | 
					  - name: String
 | 
				
			||||||
  {field} + backgroundPath: String
 | 
					  - musicPath: String
 | 
				
			||||||
  {field} + speed: Double
 | 
					  + StartLevel()
 | 
				
			||||||
 | 
					  + EndLevel()
 | 
				
			||||||
  {method} + Level()
 | 
					  + CheckCompletion(): Boolean
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
Level *--> "*\n- grid" GameObject : <<Is made up of>>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
abstract class GameObject {
 | 
					abstract class LevelElement {
 | 
				
			||||||
  {method} + getImagePath(): String {abstract}
 | 
					  - x: Float
 | 
				
			||||||
  {method} + safeSides(): List<PositionSide> {abstract}
 | 
					  - y: Float
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
GameObject o--> "1\n- " Position : <<Has>>
 | 
					 | 
				
			||||||
GameObject ..> PositionSide : <<Uses>>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Spike extends GameObject {}
 | 
					abstract class Obstacle extends LevelElement {
 | 
				
			||||||
 | 
					  + TriggerEffect(player: Player)
 | 
				
			||||||
class Game {
 | 
					 | 
				
			||||||
  {field} - score: Integer
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  {method} + start(): void
 | 
					 | 
				
			||||||
  {method} + restart(): void
 | 
					 | 
				
			||||||
  {method} + end(): void
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
Game o--> "1\n- currentLevel" Level : <<Has>>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum PositionSide <<enumeration>> {
 | 
					class Platform extends LevelElement {
 | 
				
			||||||
  TOP
 | 
					 | 
				
			||||||
  RIGHT
 | 
					 | 
				
			||||||
  BOTTOM
 | 
					 | 
				
			||||||
  LEFT
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Spike extends Obstacle {
 | 
				
			||||||
 | 
					  + TriggerEffect(player: Player)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Portal extends LevelElement {
 | 
				
			||||||
 | 
					  - destination: Vector2
 | 
				
			||||||
 | 
					  - type: PortalType
 | 
				
			||||||
 | 
					  + Teleport(player: Player)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum PortalType {
 | 
				
			||||||
 | 
					  Normal, Gravity, Speed
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Bumper extends LevelElement {
 | 
				
			||||||
 | 
					  - bounceForce: Float
 | 
				
			||||||
 | 
					  + Bounce(player: Player)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class LevelEnd extends LevelElement {
 | 
				
			||||||
 | 
					  + TriggerEndGame()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Collectible extends LevelElement {
 | 
				
			||||||
 | 
					  - points: int
 | 
				
			||||||
 | 
					  + Collect(player: Player)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Player {
 | 
				
			||||||
 | 
					  - JUMP_FORCE: static const Float = 26.6581
 | 
				
			||||||
 | 
					  - SPEED: static const Float = 8.6
 | 
				
			||||||
 | 
					  - rigidBody: Rigidbody2D
 | 
				
			||||||
 | 
					  - isColliding: Boolean
 | 
				
			||||||
 | 
					  - isGrounded: Boolean
 | 
				
			||||||
 | 
					  - gravityScale: Float
 | 
				
			||||||
 | 
					  + Jump()
 | 
				
			||||||
 | 
					  + IsJumping(): Boolean
 | 
				
			||||||
 | 
					  + OnCollisionEnter2D(collision: Collision2D)
 | 
				
			||||||
 | 
					  + OnCollisionExit2D(collision: Collision2D)
 | 
				
			||||||
 | 
					  + ChangeGravity()
 | 
				
			||||||
 | 
					  + Die()
 | 
				
			||||||
 | 
					  + Respawn()
 | 
				
			||||||
 | 
					  + CollectItem(item: Collectible)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class LevelLoader {
 | 
				
			||||||
 | 
					  + LoadLevel(jsonPath: String): Level
 | 
				
			||||||
 | 
					  + UnloadLevel(level: Level)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class LevelParser {
 | 
				
			||||||
 | 
					  + ParseJSON(jsonData: String): Level
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class MusicManager {
 | 
				
			||||||
 | 
					  - currentTrack: String
 | 
				
			||||||
 | 
					  - volume: Float
 | 
				
			||||||
 | 
					  + PlayMusic(musicPath: String)
 | 
				
			||||||
 | 
					  + StopMusic()
 | 
				
			||||||
 | 
					  + SetVolume(level: Float)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GameManager *--> Level : <<Manages>>
 | 
				
			||||||
 | 
					GameManager --> LevelLoader : <<Uses>>
 | 
				
			||||||
 | 
					LevelLoader --> LevelParser : <<Uses>>
 | 
				
			||||||
 | 
					Level *--> LevelElement : <<Contains>>
 | 
				
			||||||
 | 
					GameManager *--> Player : <<Owns>>
 | 
				
			||||||
 | 
					GameManager --> MusicManager : <<Controls>>
 | 
				
			||||||
 | 
					Player --> LevelEnd : <<Triggers>>
 | 
				
			||||||
 | 
					Player --> Portal : <<Interacts>>
 | 
				
			||||||
 | 
					Player --> Collectible : <<Collects>>
 | 
				
			||||||
 | 
					Obstacle --> Player : <<Affects>>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@enduml
 | 
					@enduml
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user