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 grid

    This package contains tools for working with grid-like two-dimensional structures.

    This package contains tools for working with grid-like two-dimensional structures.

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

    Definition Classes
    o1
  • CompassDir
  • Grid
  • GridPos
c

o1.grid

GridPos

case class GridPos(x: Int, y: Int) extends Product with Serializable

An object of type GridPos represents a pair of integer coordinates on two axes named x and y. Such a pair can be used to reference a point on a Grid.

In this coordinate system, x increases "eastwards" and y increases "southwards".

GridPos objecta are immutable.

This class has an alias in the top-level package o1, so it’s accessible to students simply via import o1._.

x

an x coordinate

y

a y coordinate

Linear Supertypes
Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. GridPos
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new GridPos(x: Int, y: Int)

    x

    an x coordinate

    y

    a y coordinate

Value Members

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

    Determines whether this grid position equals the given one.

    Determines whether this grid position equals the given one. This is the case if the two have identical x and y coordinates.

  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  7. def diff(another: GridPos): (Int, Int)

    Returns the xDiff and yDiff between this GridPos and the given one as a pair.

  8. def distance(another: GridPos): Int

    Returns the "grid distance" between this GridPos and the given one.

    Returns the "grid distance" between this GridPos and the given one. The grid distance between a and b equals a.xDiff(b).abs + a.yDiff(b).abs.

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. def neighbor(direction: CompassDir): GridPos

    Returns a grid position that "neighbors" this one in the given direction.

    Returns a grid position that "neighbors" this one in the given direction. For instance, if this position has an x of 10 and a y of 20, and the direction parameter is given the value CompassDir.South, then the result has an x of 10 and a y of 21. Calling this method is essentially the same as calling relative with a distance of one.

  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  16. def pathTowards(direction: CompassDir): LazyList[GridPos]

    Returns an infinite lazy-list of locations at increasing distances from this GridPos in the given direction.

    Returns an infinite lazy-list of locations at increasing distances from this GridPos in the given direction. For example, if this GridPos is (10,1), and the direction is South, returns a list of (10,2), (10,3), (10,4), etc.

  17. def productElementNames: Iterator[String]
    Definition Classes
    Product
  18. def relative(direction: CompassDir, distance: Int): GridPos

    Returns another grid position that is in the given direction from this one and at a given distance.

    Returns another grid position that is in the given direction from this one and at a given distance.

    For instance, say this position has an x of 10 and a y of 20. If direction is CompassDir.North and distance is 3, then the result has an x of 10 and a y of 17.

    See also

    CompassDir.xStep, CompassDir.yStep

  19. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  20. def toString: String

    Returns a textual description of this position.

    Returns a textual description of this position. The description is of the form "(x,y)".

    Definition Classes
    GridPos → AnyRef → Any
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  24. val x: Int
  25. def xDiff(another: GridPos): Int

    Returns the difference between the x coordinate of this GridPos and that of the given GridPos.

    Returns the difference between the x coordinate of this GridPos and that of the given GridPos. The result is negative if the x coordinate of this GridPos is greater.

  26. def xDirectionOf(another: GridPos): Option[CompassDir]

    Determines if the given GridPos is west or east of this one.

    Determines if the given GridPos is west or east of this one. Returns East if this GridPos’s x coordinate is less than another’s and West if the opposite is true. Wraps that return value in an Option; None means that the x coordinates are equal.

  27. val y: Int
  28. def yDiff(another: GridPos): Int

    Returns the difference between the y coordinate of this GridPos and that of the given GridPos.

    Returns the difference between the y coordinate of this GridPos and that of the given GridPos. The result is negative if the y coordinate of this GridPos is greater.

  29. def yDirectionOf(another: GridPos): Option[CompassDir]

    Determines if the given GridPos is north or south of this one.

    Determines if the given GridPos is north or south of this one. Returns South if this GridPos’s y coordinate is less than another’s and North if the opposite is true. Wraps that direction in an Option; None means that the y coordinates are equal.

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 Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped