‘Primitive’ Classes

  • Image
  • Text
  • Point

Main Classes

  • UI - Needed? (adds theming, colouring, etc.)

    • Text (Bagel Prim) - Wrapper Class?
      • InputText
    • Image (Bagel Prim) - Wrapper Class?
  • Input - Inside Game or Scene?

  • Scene

    • GameScene
    • HomeScene
    • PlayerInfoScene
  • Person

    • Driver
    • Passenger
  • Car

    • Taxi
    • Environment Car
    • Enemy Car
  • Trip End Flag

  • Projectiles

    • Smoke
    • Fireball
  • Collectibles

    • Coin
    • Invincibility
  • Game

    • Includes Scenes
  • Collider

MAYBE

  • Timer
  • Camera

Master classes

  • SceneManager
  • FileManager
  • Stats
  • Object: Most things in the game derive from object.

Interfaces

  • Collidable: Contains method onCollision(Object other)
    • Scene always runs all onCollision methods contininously on all Collidable objects.
    • collidable boolean?
  • Damageable: Has a damage() method and an onDeath() method.
    • onDeath default is to hide the obj.
    • and a damageable boolean?
  • Damager
    • has a damage int (scene locals calls all damagers on damageables)
  • Visible
    • Has a draw method which scene calls for all visible objects
    • A visibility hide() which sets visibilty to false and show which does as expected
    • a getvisibility.
  • Inputable
    • Has a method handleInput
  • Themeable??

Skeletal Inheritance Tree UML

  classDiagram
 direction  TB
%%All scenes have input?

%%Interfaces

Damageable <|.. Person
Damageable <|.. Car
Visible <|.. Object
Damager <|.. Car
Damager <|.. Fireball
Inputable <|.. InputText
Collidable <|.. Car
Collidable <|.. Projectile
Collidable <|.. Pickup
Collidable <|.. TripEndFlag

Inputable <|.. GameObject

Object <|-- UIObject
Object <|-- GameObject

UIObject <|-- Text
Text <|-- InputText

VFX <|-- Smoke
VFX <|-- Fire
VFX <|-- TripEndFlag
VFX <|-- Blood

GameObject <|-- Pickup
GameObject <|-- Person
GameObject <|-- Car
GameObject <|-- Projectile
GameObject <|-- VFX

Person <|-- Driver
Person <|-- Passenger

Inputable <|.. Person
Inputable <|.. Taxi

Car <|-- Taxi
Car <|-- EnemyCar
Car <|-- EnvironmentCar   

Projectile <|-- Fireball
Pickup <|-- Coin
Pickup <|-- Invincibility

Scene <|-- PlayerInfoScene
Scene <|-- HomeScene
Scene <|-- GameScene
Scene <|-- EndScene

class Trip 
class FrameTimer
class Stats
class FileManager
class SceneManager

<<abstract>> Scene
<<abstract>> UIObject
<<abstract>> Person
<<abstract>> Car
<<abstract>> VFX
<<abstract>> Projectile
<<abstract>> Pickup
<<abstract>> Object
<<interface>> Collidable
<<interface>> Damageable
<<interface>> Damager
<<interface>> Visible
<<interface>> Inputable

note for Projectile "In case I add more projectiles"

Full Diagram

  classDiagram
 direction  TB
%%All scenes have input?

%%Interfaces

Damageable <|.. Person
Damageable <|.. Car
Visible <|.. Object
Damager <|.. Car
Damager <|.. Fireball
Inputable <|.. InputText
Collidable <|.. Car
Collidable <|.. Projectile
Collidable <|.. Pickup
Collidable <|.. TripEndFlag


%%For moving relative to player
Inputable <|.. GameObject

class Visible {
    -boolean visibility = true
    +void draw(Point position)
}

class Collidable {
    -boolean collidable = true
    -int collisionRadius
    -int timeoutInFrames = 200
    -FrameTimer collisionTimeoutTimer
    +void collidedWith(GameObject other)
}

class Damageable {
    -int health = 100
    -boolean damageable = true
    +void takeDamage(int value)
    +void onDeath()
}

class Damager {
    -int damage
}

class Inputable {
    +void handleInput(Input input)
}

%%Objects

class Object {
    -Point position
    -Rectangle bounds
    +Object(Scene parentScene)
    +void draw(Point position)
    +double getHeight()
    +double getWidth()

}

Object <|-- UIObject
Object <|-- GameObject


%%UIObjects

class Text {
    -String font = "res/FSO8BITR.TTF"
    -int fontSize = 24
    -String text = ""
    -Font font
    +setText(String text)
    +String getText()
}

class InputText {
    +void handleInput(Input typedChars)
}


UIObject <|-- Text
Text <|-- InputText

%%VFX

class VFX {
    -FrameTimer lifetimeTimer
    -int lifetimeInFrames = 20
}

class Smoke {
    -String spriteFilename = "smoke.png" 
}

class Fire {
    -String spriteFilename = "fire.png"
}

class TripEndFlag {
    -String spriteFilename = "tripEndFlag.png"
    -int collisionRadius = 80
}

class Blood {
    -String spriteFilename = "blood.png"
}

VFX <|-- Smoke
VFX <|-- Fire
VFX <|-- TripEndFlag
VFX <|-- Blood


%%GameObjects

class GameObject {
    -Image sprite
    -Point velocity = [0,0]
    -int playerOffsetY = -5
    -String spriteFilename
    +final void move()
    +double distanceBetween(Object a, Object b)$
    +void moveTowards(GameObject obj)
    +void moveAway(GameObject obj)
}

GameObject <|-- Pickup
GameObject <|-- Person
GameObject <|-- Car
GameObject <|-- Projectile
GameObject <|-- VFX

Person <|-- Driver
Person <|-- Passenger

Inputable <|.. Person
Inputable <|.. Taxi

Car <|-- Taxi
Car <|-- EnemyCar
Car <|-- EnvironmentCar   

Projectile <|-- Fireball

Pickup <|-- Coin
Pickup <|-- Invincibility

%%Scenes

class Scene {
    +List~Object~ children
    +Input input
    -Image background
    -String name
    +void addChild(Object child)
    +void deleteChild(Object child)
    +void update()
    +void start()
    +void clear()
}

class EndScene {
    +List~Object~ children
    boolean gameWon
    -void displayScores()
    +void update()
    +void start()
}

class GameScene {
    +List~Object~ children
    -Timer weatherDuration
    +void changeWeather()
    +void update()
    +void start()
}

class PlayerInfoScene {
    +List~Object~ children
}
class HomeScene {
    +List~Object~ children
}

Scene <|-- PlayerInfoScene
Scene <|-- HomeScene
Scene <|-- GameScene
Scene <|-- EndScene

%%Projectiles

class Fireball {
    -String spriteFilename = "fireball.png"
    -Point velocity = [0,7]
    -int damage = 20
}

%%Pickups

class Pickup {
    -Timer duration
        -int collisionRadius = 20
    -int effectDurationInFrames
    -void applyEffect()
    -void endEffect()
}

class Coin {
    -int effectDurationInFrames = 500
    -String spriteFilename = "coin.png"
    -void applyEffect()
    -void endEffect()
}

class Invincibility {
    -int effectDurationInFrames = 1000
    -String spriteFilename = "invinciblePower.png"
    -void applyEffect()
    -void endEffect()
}

%%Persons

class Person {
    -void takeDamage(int value)
    -void onDeath()
    +void onPickup()
    -Point velocity = [1,1]
}

class Driver {
    -void onDeath()
    -void onPickup()
    +void handleInput(Input arrowKeysOrWASD)
}

class Passenger {
    -boolean hasUmbrella;
    -int taxiDetectionRadius = 100
}


%%Cars

class Car {
    -int damage = 50
    -Point velocity = [0,2...5]
    -int collisionRadius = 32
}

class Taxi {
    -boolean driverInside
    -Point velocity = [1,5]
    -String spriteFilename = "taxi.png"
    -int damage = 100
    +void handleInput(Input arrowKeysOrWASD)
    -void pickup(Person person)
    -void eject(Person person, Point toPos)
    -void gameLoss()
    -void deleteIfOffscreen()
}

class EnvironmentCar {
    -String[2] spriteFilenames 
    = ["otherCar-1.png","otherCar-2.png"]
}

class EnemyCar {

    -String spriteFilename = "enemyCar.png"
    -shootFireball()
}

%%Other 

class Trip {
    -static double yDistRate = 0.1
    -static double yDistPenalty = 0.05
    -static double[3] priorityRates = [10,20,50]
    -int tripEndX;
    -int tripEndYDist;
    -double calculateTotalFee()
    +void start()
    +void end()
}

class FrameTimer {
    -int framesLeft
    -int framesDuration
    -boolean running
    +void onTimerEnd()
    +void reset()
    +void start()
    +void stop()
}

class Stats{
    -static double score = 0
    -static double targetScore = 500
    -static int gameFrames = 15000
    +static FrameTimer gameTimer;
    +static void addScore(double score)
    <<abstract>>
}
class FileManager{
    <<abstract>>
    +Property properties
    +void loadGameObjects()
    +void writeScoresToCSV()
    +String[5] getTopFiveScores()
    -void sortScores()
    -String[][] loadFromWorldFile(Scene game)
    %%Add to scores?
}

class SceneManager {
    <<abstract>>
    -List~Scene~ loadedScenes
    +setScene(Scene scene)$
    +static void gameWon()
    +static void gameLost()
}
<<abstract>> Scene

<<abstract>> UIObject
<<abstract>> Person
<<abstract>> Car
<<abstract>> VFX
<<abstract>> Projectile
<<abstract>> Pickup
<<abstract>> Object
<<interface>> Collidable
<<interface>> Damageable
<<interface>> Damager
<<interface>> Visible
<<interface>> Inputable

note for Projectile "In case I add more projectiles"

HomeScene

 classDiagram
direction TB

HomeScene -- "2" Text

PlayerInfoScene

classDiagram
direction TB

PlayerInfoScene -- "2" Text
PlayerInfoScene -- "1" InputText


GameScene

classDiagram

direction TB

GameObject <|-- Car
GameObject <|-- Person
GameObject <|-- Pickup
Car <|-- EnemyCar
Car <|-- Taxi
Person <|-- Driver
Person <|-- Passenger

GameScene "1" -- "4..*" GameObject
GameScene "1" -- "2" Image: weather
GameScene "1"  -- "1" Driver
GameScene "1" -- "9" Text

Passenger "1" -- "1"Trip: can start a
Passenger -- TripEndFlag: moves towards
Passenger -- "0..*" Blood

Trip "1" -- "1" TripEndFlag: spawns a

Taxi -- "1..2" Person: picks up

Pickup -- Driver: picked up by
Pickup -- Taxi: picked up by
  
Driver -- "0..*" Blood

Car -- "0..*" Fire
Car -- "0..*" Smoke

EnemyCar -- "0..*" Fireball: shoots
  

<<abstract>> Car
<<abstract>> Person
<<abstract>> GameObject