mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-04-10 21:47:07 +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 GameObject playerObject;
|
||||
|
||||
public ParticleSystem particle;
|
||||
|
||||
private bool wantsToJump = false;
|
||||
public bool isColliding = true;
|
||||
|
||||
public AudioSource audioSource;
|
||||
private bool hasStarted = false;
|
||||
|
||||
private bool canJump = true;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
var mainModule = particle.main;
|
||||
mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
|
||||
particle.transform.parent = null;
|
||||
|
||||
Invoke(nameof(EnableInput), 0.1f);
|
||||
}
|
||||
|
||||
private void EnableInput()
|
||||
{
|
||||
hasStarted = true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
wantsToJump = false;
|
||||
Jump();
|
||||
}
|
||||
|
||||
if (!IsJumping())
|
||||
{
|
||||
AlignRotation();
|
||||
|
||||
if (wantsToJump)
|
||||
{
|
||||
Jump();
|
||||
wantsToJump = false;
|
||||
}
|
||||
|
||||
particle.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
@ -88,13 +84,14 @@ public class PlayerScript : MonoBehaviour
|
||||
public void OnCollisionEnter2D(Collision2D collision)
|
||||
{
|
||||
isColliding = true;
|
||||
canJump = true;
|
||||
|
||||
if (collision.gameObject.tag == "Kill")
|
||||
if (collision.gameObject.CompareTag("Kill"))
|
||||
{
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||
}
|
||||
|
||||
if (collision.gameObject.tag == "Win")
|
||||
if (collision.gameObject.CompareTag("Win"))
|
||||
{
|
||||
SceneManager.LoadScene("HomeScene");
|
||||
}
|
||||
|
@ -5,46 +5,107 @@ skinparam classAttributeIconSize 0
|
||||
skinparam classFontStyle Bold
|
||||
hide enum methods
|
||||
|
||||
class Position {
|
||||
{field} + column: Integer
|
||||
{field} + row: Integer
|
||||
|
||||
{method} + Position(column: Integer, row: Integer)
|
||||
{method} + equals(position: Position)
|
||||
class GameManager {
|
||||
- score: int
|
||||
- isPaused: Boolean
|
||||
+ StartGame()
|
||||
+ RestartLevel()
|
||||
+ PauseGame()
|
||||
+ ResumeGame()
|
||||
+ UpdateScore(points: int)
|
||||
}
|
||||
|
||||
class Level {
|
||||
{field} + songPath: String
|
||||
{field} + backgroundPath: String
|
||||
{field} + speed: Double
|
||||
|
||||
{method} + Level()
|
||||
- name: String
|
||||
- musicPath: String
|
||||
+ StartLevel()
|
||||
+ EndLevel()
|
||||
+ CheckCompletion(): Boolean
|
||||
}
|
||||
Level *--> "*\n- grid" GameObject : <<Is made up of>>
|
||||
|
||||
abstract class GameObject {
|
||||
{method} + getImagePath(): String {abstract}
|
||||
{method} + safeSides(): List<PositionSide> {abstract}
|
||||
abstract class LevelElement {
|
||||
- x: Float
|
||||
- y: Float
|
||||
}
|
||||
GameObject o--> "1\n- " Position : <<Has>>
|
||||
GameObject ..> PositionSide : <<Uses>>
|
||||
|
||||
class Spike extends GameObject {}
|
||||
|
||||
class Game {
|
||||
{field} - score: Integer
|
||||
|
||||
{method} + start(): void
|
||||
{method} + restart(): void
|
||||
{method} + end(): void
|
||||
abstract class Obstacle extends LevelElement {
|
||||
+ TriggerEffect(player: Player)
|
||||
}
|
||||
Game o--> "1\n- currentLevel" Level : <<Has>>
|
||||
|
||||
enum PositionSide <<enumeration>> {
|
||||
TOP
|
||||
RIGHT
|
||||
BOTTOM
|
||||
LEFT
|
||||
class Platform extends LevelElement {
|
||||
}
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user