aganew
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Documentation of SLTD (SWA Group 17) ## SLTDControlPanel * primary goal is to create and visualize the UI-controlls of the game * 'knows' the game -> so buttons can trigger functions (e.g. for building new Towers) * game is able to sent messages to the controllpanel (e.g. for statistic updates (gold, score, lives, kills, waves)) and in future for features like the changable tower attack pattern ### update: listens to publisher. if changed is called within one of the dependents from dependents collection aParameter is received from method. depending on aParameter a method is called ## SLTDGame A SLTDGame is an instance of our Super Lovely Tower Defence Game world (TODO: refactor to rename master panel). SLTDGame holds universal path variable. It is currently used to add morphs for the path visualization in `initializePathVisualization`. It should later be used to hand over the path to the SLTDEnemy via the SLTDEnemyFactory. ### Comunication with ControlPanel SLTDControllpanel added itself to SLTDGame's Dependents (so it "subscribed" to updates from SLTDGame) `SLTDControllpanel >> update:` happens when `SLTDGame >> changed:` is called. The message-protocol is `{#message_tag. aObject}`. ### Access Entities Do not access entities directly. If you want to access Entites from other Entities, use the `SLTDGameEntity>>*Within:` methods. Otherwise, use `entitiesWithin: radiusNumber from: aPoint`, `towersWithin:from:`, ... Depending on the number of entity types and their access requirements, this interface might be refactored. ### Modify Entities To add or modify individual entities, please refer to `SLTDGameEntity`. Do not directly interfere with the entities. To add Morphs or entities on initialization, please add their creation in a new method and modify the initializatoin methods. * Enitites: * Please modify the `initializeEntities` method * Gameplay handlers or managers: * `initializeGameplay`. To remove `anEntity`, send `unregisterAtGame` to `anEntity` ### Positioning / Tiling If you wish to use tiling information, use the following methods (all in game coordinates): * `nearestTile: aPoint` - Returns the center of the nearest tile to aPoint. If you use this for positioning of morphs, first consider `SLTDGameEntity>>snapToTile`. * `randomPoint` - Returns a random point within the game. * `randomTile` - Returns a random point within the game that is in the center of a tile. * `inGame:` translates an absolute point to in-game coordinates * `outGame:` translates a relative point to absolute coordinates ## SLTDGameEntity A SLTDGameEntity is an Actor of the gameplay. ### Accessors `game` - the SLTDGame the entity acts in ### Creation Creation pattern for subclasses: ``` (<SLTDGameEntity subclass> newFromGame: <game>) <initialization>; registerAtGame. ``` Notable initialization messages are: * `inGamePosition:` - sets the general position (refer Positioning) * `snapToTile` - Positions the center of this entity at the closest tile. The `onRegisterAtGame` method is called just before the entity is added to the game. Currently it adjusts positioning as extend and therefore the center might have changed since `initialize`. ### Removal To remove `anEntity` from a game, send the `unregisterAtGame` message to `anEntity`. ### Accessing Collection of all entities of some type within some radius: `*Within: radiusNumber` e.g. `enemiesWithin:` `towersWithin:` ... ### Positioning **Do not use `position`, `center` or similar within entities.** * Use `inGamePosition` and `inGamePosition:`. They offer a uniform and almost transparent translation of coordinate systems across the game. Also, they use floating point numbers, hence do not suffer from precision loss as much. All computation within gameplay elements should be in game coordinates. ### Subclass implementation When creating a subclass `SLTDGameEntitySubclass`, to enable interaction with other entities, add the following methods to `SLTDGameEntity`: ``` isSLTDGameEntitySubclass ^ false ``` and ``` SLTDGameEntitySubclassesWithin: radiusNumber ^ self game SLTDGameEntitySubclassesWithin: radiusNumber from: (self center) ``` similar to the existing methods. ## SLTDEnemy ### public accessors * distanceTraveled * goldValue * health * healthFraction (0 to 1, how much of original health is left) * isAlive ### movement * Currently, the enemy follows the path, but in principle, you can set any pont as `targetPoint` to go to. This point can change dynamically. * Movement is controlled by stepping, and the speed is independent from `stepTime` (although low stepTimes are smoother). * `moveFor:` takes a Duration and moves the enemy towards the target point by the product of its speed and the duration. At any point within this distance, the enemy might reach its target and select a new one, removing the need for alignment of path points and stepTime. * `moveTowards: targetPoint by: distanceNumber` is a helper that moves the enemy towards a static target point by at most `distanceNumber` and returns the leftover of distanceNumber. * reachedTargetPoint is a helper callback. * `reachedEndOfPath` calls `game enemyReachedEndOfPath` * `takeDamage:from:` tells the enemy that it took damage from some other entity (usually a tower) ### Misc * `kill` is invoked by `takeDamage` and notifies the game. ## SLTDCursorVisualizer (prev. SLTDShadowMorph) * is a morph to interact with the user * visualise the next place, where the user could place the tower * currently: calculated if player has enough gold to place a tower. Should probably be moved to game? Would need rework of the way towers are placed because the shadowmorph registers the tower with the game so the game has no (simple) way of checking wether the user has enough gold ## SLTDTower ### accessors: damage, damage: range, range: targetMode, targetMode: ### setTargetModeFirst/setTargetModeLast/setTargetModeStrongest/setTargetModeClosest sets target mode accordingly. Can be used for Buttons later ### getObjectOfInterest detects all enemies within the range of the tower and saves them in set ### selectFirst:/selectLast:/selectStrongest:/selectClosest: selects the first/last... enemy from the given set. returns enemy ### selectTarget: applies filter to Set from targetMode-Block ## SLTDShotVisualisation * will be created in SLTDTower>>shot, stored in SLTDTower * is turned transparent via addAlarm:after: 50ms after the shot * redrawn when the tower shoots the next time ## SLTDEnemyFactory * Probably not a "real" factory. Idk. * Holds the `game` it creates enemies for. * There are capabilities to create enemies by prototype, but they are dangerous due to the complications of the `copy` method of morphs. Don't try this at home. We now use factories. * Usage: ``` (enemyFactory makeEnemy: #quick) <modifications> registerAtGame. ``` Where `#quick` can be replaced with `#strong` or `#weak` for now. ## SLTDWaveManager * `waves` - Collection of current waves (private!) * `game`, `enemyFactory` as the names imply. * Use `startWave:` and `stopWave:` to manipulate ongoing waves * receives steps from game and forwards them to its waves * starts new wave when old one is finished ## SLTDWave Is organized by SLTDWaveManager, not to be interacted with. * `age` - duration the wave has been goin on for * `enemies` - enemies associated with this wave * `enemyFactory` - refers to the one from WaveManager * `manager` - SLTDWaveManager for this wave * `spawn: aSymbol` * `duration` - time after which this wave is removed from its manager (by default 1 second after all enemies have been spawned) * `schedule:at:` - set a time for a type of enemy to spawn Similar to Enemyspawner, decides what enemies should be spawned at what time. ## REMOVED ~~SLTDEnemy_old~~ ### Accessors * health, health: * path, path: * speed, speed: * isEnemy --- ### movement #### setDirection sets movement direction towards next point on path. sends "reachedPathEnd" when enemy reaches last point of path --- ### stepping and behavior #### death sends "stopStepping" #### isAlive returns (health > 0) #### pathPosition will be increased by the amount of speed every step. Enemy with highest pathPosition is first in line #### reachedPathEnd Called when last point of path is reached. Currently stops the enemy from stepping #### step Sets new position according to the movement direction. Once next point of path is reached, "setDirection" is sent to set it towards the next point. #### stepTime #### takeDamage: aNumber from: aSource Subtracts amount from health. Sends "death" if health is now <= 0. Currently changes color to red, should be removed (left in for visualization for debugging) ## REMOVED ~~SLTDEnemySpawner~~ ### class on: aGame Creates an EnemySpawner that gets aGame passed to game: ### enemyTypes ifNil-getter that defines the characterictics of different enemy types. Keys are the color names as symbols. ### spawnEnemy: aType Spawns a new Enemy of the given type with the characteristics from enemyTypes in the game. ### Accessors * game: * path ## REMOVED ~~SLTDMasterpanel~~ ### Initialization * hardcoded: size of the controllPanel and the game * sizes are points (x - width, y - depth)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully