Packages

  • package root
    Definition Classes
    root
  • package o1

    O1Library is a toolkit designed for the course Programming 1 (a.k.a. O1) at Aalto University.

    O1Library is a toolkit designed for the course Programming 1 (a.k.a. O1) at Aalto University. It contains an assortment of tools; most prominently, it provides a framework for simple graphical programming and utilities for playing sound.

    This is the front page of O1Library’s documentation. However, this is probably not the best place to start learning about O1Library as a student. That’s because the relevant content of this library is introduced bit by bit in the chapters of O1’s custom ebook alongside the associated programming concepts and assignments.

    You may still find this documentation useful as a reference. You can also find some optional content here that you may wish to try.

    This front page lists the content available in the top-level package called simply o1. These tools are available with the simple command import o1._ in your Scala programs. Some of them you’ll use a lot; some of them you won’t necessarily need at all.

    The tools listed here are actually implemented in a number of subpackages (o1.gui, o1.sound, etc.); what you see here are just “shortcut aliases” to those actual implementations. The aliases are here to make that convenient import command work and to provide you with this list of links to some of the more commonly used tools in O1Library. The subpackages also contain additional content not listed here.

    O1Library has been developed by Aleksi Lukkarinen and Juha Sorva. Several of the key components in o1.gui and o1.world are built upon Aleksi’s Scala Media Computation Library. Some parts of O1Library draw inspiration from the “teachpacks” of the Racket programming language.

    We are grateful to Riku Autio, Joonatan Honkamaa, Juhani Numminen, Leo Varis, Veera Kahva, and anonymous students for bug reports and fixes. We thank Otto Seppälä for helpful discussions.

    Definition Classes
    root
  • package world

    This package contains tools for locations and movement in two-dimensional space.

    This package contains tools for locations and movement in two-dimensional space.

    The tools in this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._.

    The subpackage o1.world.objects contains additional tools for representing entities that reside within two-dimensional spaces.

    Definition Classes
    o1
  • package objects

    This package contains tools for representing objects that exist in two-dimensional space.

    This package contains tools for representing objects that exist in two-dimensional space. In particular, it defines:

    • the Anchor type: an anchor is the point where an object connects to its environment; and
    • a number of traits (HasPos, HasVelocity, etc.) the classes of an application can mix in to gain access to various convenience methods.

    NOTE TO STUDENTS: In this course, you don't need to understand how this package works or can be used. That being said, some students may wish to experiment with some of its contents. Many of the traits in this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._.

    Definition Classes
    world
  • object mutable

    This subpackage defines a few additional traits that extend the ones in of o1.world.objects.

    This subpackage defines a few additional traits that extend the ones in of o1.world.objects. These traits provide additional convenience methods for working with mutable objects in two-dimensional space.

    NOTE TO STUDENTS: In this course, you don't need to understand how this package works or can be used. That being said, some students may wish to experiment with some of its contents. Many of the traits in this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._.

    Definition Classes
    objects
  • ContainedObject
  • MovingObject
  • MovingObjectInContainer
  • MutablePos
t

o1.world.objects.mutable

MovingObjectInContainer

trait MovingObjectInContainer extends ContainedObject with HasVelocity

A supertype for objects that take up a rectangular area and have a velocity as well as a mutable position that may be constrained by a larger object around them.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MovingObjectInContainer
  2. HasVelocity
  3. ContainedObject
  4. HasContainer
  5. HasEdges
  6. HasAnchor
  7. HasSize
  8. MutablePos
  9. HasPos
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract val container: HasEdges

    another object that clampX, clampY, and clamp use for constraining this object’s position

    another object that clampX, clampY, and clamp use for constraining this object’s position

    Definition Classes
    HasContainer
  2. abstract def height: Double

    this object’s height: the distance from its top edge to its bottom edge

    this object’s height: the distance from its top edge to its bottom edge

    Definition Classes
    HasSize
  3. abstract val pos: Pos

    the object’s location

    the object’s location

    Definition Classes
    MutablePosHasPos
  4. abstract def velocity: Velocity

    the object's velocity

    the object's velocity

    Definition Classes
    HasVelocity
  5. abstract def width: Double

    this object’s width: the distance from its left edge to its right edge

    this object’s width: the distance from its left edge to its right edge

    Definition Classes
    HasSize

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def anchor: Anchor

    Returns the object’s anchoring point, which is Anchor.Center unless overridden.

    Returns the object’s anchoring point, which is Anchor.Center unless overridden.

    Definition Classes
    HasEdgesHasAnchor
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def bottom: Double

    Returns the y coordinate of the bottom edge.

    Returns the y coordinate of the bottom edge.

    Definition Classes
    HasEdges
  7. def bottomLeft: Pos

    Returns the coordinates of this object’s bottom left-hand corner.

    Returns the coordinates of this object’s bottom left-hand corner.

    Definition Classes
    HasEdges
  8. def bottomRight: Pos

    Returns the coordinates of this object’s bottom right-hand corner.

    Returns the coordinates of this object’s bottom right-hand corner.

    Definition Classes
    HasEdges
  9. def bringToContainer(): Unit

    Causes this object’s pos to change so that the object is within its container, as per clamp.

    Causes this object’s pos to change so that the object is within its container, as per clamp.

    Definition Classes
    ContainedObject
  10. def bringXToContainer(): Unit

    Causes this object’s pos to change so that its left and right edges don’t extend beyond its container, as per clampX.

    Causes this object’s pos to change so that its left and right edges don’t extend beyond its container, as per clampX.

    Definition Classes
    ContainedObject
  11. def bringYToContainer(): Unit

    Causes this object’s pos to change so that its top and bottom edges don’t extend beyond its container, as per clampY.

    Causes this object’s pos to change so that its top and bottom edges don’t extend beyond its container, as per clampY.

    Definition Classes
    ContainedObject
  12. def center: Pos

    Returns the average position between this object’s edges.

    Returns the average position between this object’s edges.

    Definition Classes
    HasEdges
  13. def centerFromTopLeft: Pos

    the location of this object’s center: the average point between its edges, expressed in coordinates relative to the object’s top left-hand corner

    the location of this object’s center: the average point between its edges, expressed in coordinates relative to the object’s top left-hand corner

    Definition Classes
    HasSize
  14. def clamp(): Pos

    Looks for a position for this object that is as close to possible to the object's current pos but keeps the object's edges within the bounds of the object's container.

    Looks for a position for this object that is as close to possible to the object's current pos but keeps the object's edges within the bounds of the object's container. Returns that Pos.

    Definition Classes
    HasContainer
  15. def clampWhollyInside(container: HasEdges, desiredPosition: Pos = this.pos): Pos

    Looks for a position for this object that is as close to possible to a particular target position but keeps the object's edges within the bounds of the given other object.

    Looks for a position for this object that is as close to possible to a particular target position but keeps the object's edges within the bounds of the given other object.

    container

    another object that sets the boundaries for the return value

    desiredPosition

    the ideal position for this object (defaults to its current pos)

    returns

    the location closest to desiredPosition where this object’s anchor can be placed without its edges extending beyond container

    Definition Classes
    HasEdges
  16. def clampX(): Pos

    Looks for a position for this object that is as close to possible to the object's current pos but keeps the left and right edges of the object within the bounds of the object's container.

    Looks for a position for this object that is as close to possible to the object's current pos but keeps the left and right edges of the object within the bounds of the object's container. Returns that Pos.

    Definition Classes
    HasContainer
  17. def clampXWhollyInside(container: HasEdges, desiredPosition: Pos = this.pos): Pos

    Looks for a position for this object that is as close to possible to a particular target position but keeps the left and right edges of the object within the bounds of the given other object.

    Looks for a position for this object that is as close to possible to a particular target position but keeps the left and right edges of the object within the bounds of the given other object.

    container

    another object that sets the boundaries for the return value

    desiredPosition

    the ideal position for this object (defaults to its current pos)

    returns

    the location closest to desiredPosition where this object’s anchor can be placed without its left or right edge extending beyond container

    Definition Classes
    HasEdges
  18. def clampY(): Pos

    Looks for a position for this object that is as close to possible to the object's current pos but keeps the top and bottom edges of the object within the bounds of the object's container.

    Looks for a position for this object that is as close to possible to the object's current pos but keeps the top and bottom edges of the object within the bounds of the object's container. Returns that Pos.

    Definition Classes
    HasContainer
  19. def clampYWhollyInside(container: HasEdges, desiredPosition: Pos = this.pos): Pos

    Looks for a position for this object that is as close to possible to a particular target position but keeps the top and bottom edges of the object within the bounds of the given other object.

    Looks for a position for this object that is as close to possible to a particular target position but keeps the top and bottom edges of the object within the bounds of the given other object.

    container

    another object that sets the boundaries for the return value

    desiredPosition

    the ideal position for this object (defaults to its current pos)

    returns

    the location closest to desiredPosition where this object’s anchor can be placed without its top or bottom edge extending beyond container

    Definition Classes
    HasEdges
  20. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  21. def closestPosTo(target: Pos): Pos

    Returns the position within this object’s edges that is as close as possible to the given position.

    Returns the position within this object’s edges that is as close as possible to the given position.

    Definition Classes
    HasEdges
  22. def containsBetweenEdges(candidate: Pos): Boolean

    Determines whether the given Pos’s x coordinate is between this object’s left edge (inclusive) and its right edge (exclusive) and if it’s y coordinate is similarly between the top and bottom edges.

    Determines whether the given Pos’s x coordinate is between this object’s left edge (inclusive) and its right edge (exclusive) and if it’s y coordinate is similarly between the top and bottom edges.

    Definition Classes
    HasEdges
  23. def distance(another: HasPos): Double

    Determines the distance (“as the crow flies”) between this object’s pos and that of the given object.

    Determines the distance (“as the crow flies”) between this object’s pos and that of the given object.

    Definition Classes
    HasPos
  24. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  25. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  26. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  27. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  28. def internalAnchorPos: Pos

    Returns the Pos of the anchoring point within this object, expressed as coordinates relative to the object’s top left-hand corner.

    Returns the Pos of the anchoring point within this object, expressed as coordinates relative to the object’s top left-hand corner.

    Definition Classes
    HasAnchor
  29. def internalAnchorX: Double

    Returns the x coordinate of the anchoring point within this object, relative to the object’s left edge.

    Returns the x coordinate of the anchoring point within this object, relative to the object’s left edge.

    Definition Classes
    HasAnchor
  30. def internalAnchorY: Double

    Returns the y coordinate of the anchoring point within this object, relative to the object’s top edge.

    Returns the y coordinate of the anchoring point within this object, relative to the object’s top edge.

    Definition Classes
    HasAnchor
  31. def isBoundFor(direction: Direction): Boolean

    Determines whether this objectis bound for roughly the given direction, as per Direction.sharesQuadrant.

    Determines whether this objectis bound for roughly the given direction, as per Direction.sharesQuadrant.

    Definition Classes
    HasVelocity
  32. def isDownbound: Boolean

    Determines whether this objecthas a downward velocity, as per Direction.isDownward.

    Determines whether this objecthas a downward velocity, as per Direction.isDownward.

    Definition Classes
    HasVelocity
  33. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  34. def isLeftbound: Boolean

    Determines whether this objecthas a leftward velocity, as per Direction.isLeftward.

    Determines whether this objecthas a leftward velocity, as per Direction.isLeftward.

    Definition Classes
    HasVelocity
  35. def isRightbound: Boolean

    Determines whether this objecthas a rightward velocity, as per Direction.isRightward.

    Determines whether this objecthas a rightward velocity, as per Direction.isRightward.

    Definition Classes
    HasVelocity
  36. def isUpbound: Boolean

    Determines whether this objecthas an upward velocity, as per Direction.isUpward.

    Determines whether this objecthas an upward velocity, as per Direction.isUpward.

    Definition Classes
    HasVelocity
  37. def left: Double

    Returns the x coordinate of this object’s left edge.

    Returns the x coordinate of this object’s left edge.

    Definition Classes
    HasEdges
  38. def moveFreely(): Unit

    Causes the object’s pos to change: the object moves from its current location at its current velocity for one unit of time.

    Causes the object’s pos to change: the object moves from its current location at its current velocity for one unit of time. That is, the dx and dy components of the velocity are added to the object’s pos.

  39. def moveWithinContainer(): Unit

    Causes the object’s pos to change: the object moves from its current location at its current velocity for one unit of time (as per moveFreely) and is then immediately clamped to the object’s container (as per bringToContainer).

  40. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  41. def nextPos: Pos

    Returns the Pos that this object, moving from its current location at its current velocity, reaches in one unit of time.

    Returns the Pos that this object, moving from its current location at its current velocity, reaches in one unit of time. That is, adds the dx and dy components of the velocity to the current Pos and returns the result.

    Definition Classes
    HasVelocity
  42. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  43. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  44. def right: Double

    Returns the x coordinate of the right edge.

    Returns the x coordinate of the right edge.

    Definition Classes
    HasEdges
  45. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  46. def toString: String
    Definition Classes
    AnyRef → Any
  47. def top: Double

    Returns the y coordinate of the top edge.

    Returns the y coordinate of the top edge.

    Definition Classes
    HasEdges
  48. def topLeft: Pos

    Returns the coordinates of this object’s top left-hand corner.

    Returns the coordinates of this object’s top left-hand corner.

    Definition Classes
    HasEdges
  49. def topRight: Pos

    Returns the coordinates of this object’s top right-hand corner.

    Returns the coordinates of this object’s top right-hand corner.

    Definition Classes
    HasEdges
  50. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  51. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  52. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from HasVelocity

Inherited from ContainedObject

Inherited from HasContainer

Inherited from HasEdges

Inherited from HasAnchor

Inherited from HasSize

Inherited from MutablePos

Inherited from HasPos

Inherited from AnyRef

Inherited from Any

Ungrouped