Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion moon.mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firefly/firefly",
"version": "0.7.0",
"version": "0.8.0",
"deps": {
"applejag/micromath": "0.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/audio/freq.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(all) enum Pitch {
A
As
B
} derive(Show, Eq, Compare, Hash)
} derive(Debug, Eq, Compare, Hash)

///|
pub fn Pitch::from_char(char : Char) -> Pitch? {
Expand Down
2 changes: 1 addition & 1 deletion src/audio/time.mbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///|
pub struct Time(UInt) derive(Show, Eq, Compare, Hash, Default)
pub struct Time(UInt) derive(Debug, Eq, Compare, Hash, Default)

///|
/// Create a `Time` value of 0.
Expand Down
8 changes: 7 additions & 1 deletion src/graphics_angle.mbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
///|
/// An angle between two vectors, internally represented as radians.
struct Angle(Float) derive(Show, Eq, Compare, Hash, Default)
struct Angle(Float) derive(Debug, Eq, Compare, Hash, Default)

///|
pub impl Show for Angle with output(self : Angle, logger : &Logger) -> Unit {
self.to_deg().to_int().output(logger)
logger.write_char('°')
}

///|
/// Define an Angle in radians (0-2π).
Expand Down
30 changes: 29 additions & 1 deletion src/graphics_color.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,35 @@ pub(all) enum Color {
Gray
/// Dark gray color: #333C57.
DarkGray
} derive(Show, Eq, Compare, Hash)
} derive(Debug, Eq, Compare, Hash)

///|
pub impl Show for Color with output(self : Color, logger : &Logger) -> Unit {
logger.write_string(self.to_string())
}

///|
pub impl Show for Color with to_string(self : Color) -> String {
match self {
None => "none"
Black => "black"
Purple => "purple"
Red => "red"
Orange => "orange"
Yellow => "yellow"
LightGreen => "light green"
Green => "green"
DarkGreen => "dark green"
DarkBlue => "dark blue"
Blue => "blue"
LightBlue => "light blue"
Cyan => "cyan"
White => "white"
LightGray => "light gray"
Gray => "gray"
DarkGray => "dark gray"
}
}

///|
pub impl Default for Color with default() -> Color {
Expand Down
7 changes: 6 additions & 1 deletion src/graphics_image.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ pub fn Image::new(size : Size) -> Image {

///|
test "new image has correct size" {
inspect(Image::new(Size::new(20, 10)).size(), content="{w: 20, h: 10}")
debug_inspect(
Image::new(Size::new(20, 10)).size(),
content=(
#|{ w: 20, h: 10 }
),
)
}

///|
Expand Down
2 changes: 1 addition & 1 deletion src/graphics_linestyle.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pub(all) struct LineStyle {
color : Color
width : Int
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Shorthand for creating a new LineStyle.
Expand Down
50 changes: 33 additions & 17 deletions src/graphics_point.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pub(all) struct Point {
x : Int
y : Int
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Shortcut for creating a `Point`.
Expand Down Expand Up @@ -69,21 +69,29 @@ pub fn Point::component_min(self : Point, other : Point) -> Point {

///|
test "Point.component_min" {
inspect(
debug_inspect(
Point::new(20, 30).component_min(Point::new(0, 10)),
content="{x: 0, y: 10}",
content=(
#|{ x: 0, y: 10 }
),
)
inspect(
debug_inspect(
Point::new(20, 30).component_min(Point::new(10, 40)),
content="{x: 10, y: 30}",
content=(
#|{ x: 10, y: 30 }
),
)
inspect(
debug_inspect(
Point::new(20, 30).component_min(Point::new(50, 10)),
content="{x: 20, y: 10}",
content=(
#|{ x: 20, y: 10 }
),
)
inspect(
debug_inspect(
Point::new(20, 30).component_min(Point::new(50, 40)),
content="{x: 20, y: 30}",
content=(
#|{ x: 20, y: 30 }
),
)
}

Expand All @@ -96,21 +104,29 @@ pub fn Point::component_max(self : Point, other : Point) -> Point {

///|
test "Point.component_max" {
inspect(
debug_inspect(
Point::new(20, 30).component_max(Point::new(0, 10)),
content="{x: 20, y: 30}",
content=(
#|{ x: 20, y: 30 }
),
)
inspect(
debug_inspect(
Point::new(20, 30).component_max(Point::new(10, 40)),
content="{x: 20, y: 40}",
content=(
#|{ x: 20, y: 40 }
),
)
inspect(
debug_inspect(
Point::new(20, 30).component_max(Point::new(50, 10)),
content="{x: 50, y: 30}",
content=(
#|{ x: 50, y: 30 }
),
)
inspect(
debug_inspect(
Point::new(20, 30).component_max(Point::new(50, 40)),
content="{x: 50, y: 40}",
content=(
#|{ x: 50, y: 40 }
),
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/graphics_rgb.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(all) struct RGB {
r : Byte
g : Byte
b : Byte
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Shorthand for creating a new RGB.
Expand Down
50 changes: 33 additions & 17 deletions src/graphics_size.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub const SCREEN_HEIGHT : Int = 160
pub(all) struct Size {
w : Int
h : Int
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Shortcut for creating a Size.
Expand Down Expand Up @@ -44,21 +44,29 @@ pub fn Size::component_min(self : Size, other : Size) -> Size {

///|
test "Size.component_min" {
inspect(
debug_inspect(
Size::new(20, 30).component_min(Size::new(0, 10)),
content="{w: 0, h: 10}",
content=(
#|{ w: 0, h: 10 }
),
)
inspect(
debug_inspect(
Size::new(20, 30).component_min(Size::new(10, 40)),
content="{w: 10, h: 30}",
content=(
#|{ w: 10, h: 30 }
),
)
inspect(
debug_inspect(
Size::new(20, 30).component_min(Size::new(50, 10)),
content="{w: 20, h: 10}",
content=(
#|{ w: 20, h: 10 }
),
)
inspect(
debug_inspect(
Size::new(20, 30).component_min(Size::new(50, 40)),
content="{w: 20, h: 30}",
content=(
#|{ w: 20, h: 30 }
),
)
}

Expand All @@ -71,21 +79,29 @@ pub fn Size::component_max(self : Size, other : Size) -> Size {

///|
test "Size.component_max" {
inspect(
debug_inspect(
Size::new(20, 30).component_max(Size::new(0, 10)),
content="{w: 20, h: 30}",
content=(
#|{ w: 20, h: 30 }
),
)
inspect(
debug_inspect(
Size::new(20, 30).component_max(Size::new(10, 40)),
content="{w: 20, h: 40}",
content=(
#|{ w: 20, h: 40 }
),
)
inspect(
debug_inspect(
Size::new(20, 30).component_max(Size::new(50, 10)),
content="{w: 50, h: 30}",
content=(
#|{ w: 50, h: 30 }
),
)
inspect(
debug_inspect(
Size::new(20, 30).component_max(Size::new(50, 40)),
content="{w: 50, h: 40}",
content=(
#|{ w: 50, h: 40 }
),
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/graphics_style.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(all) struct Style {
fill : Color
stroke : Color
stroke_width : Int
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Create a new style transparent and empty style.
Expand Down
2 changes: 1 addition & 1 deletion src/input_buttons.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(all) struct Buttons {
/// Therefore, you may never detect when this button is pressed, as the
/// console will instead pause the game or exit to the console's main menu.
menu : Bool
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Get the currently pressed buttons.
Expand Down
2 changes: 1 addition & 1 deletion src/input_dpad4.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(all) enum DPad4 {
Right
Up
Down
} derive(Show, Eq, Compare, Hash)
} derive(Debug, Eq, Compare, Hash)

///|
/// Given the old state, get directions that were not pressed previously but are
Expand Down
2 changes: 1 addition & 1 deletion src/input_dpad8.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(all) struct DPad8 {
right : Bool
up : Bool
down : Bool
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Shorthand function for reading the pad input and converting it into a `DPad`.
Expand Down
2 changes: 1 addition & 1 deletion src/input_pad.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const DPAD4_THRESHOLD = 300
pub(all) struct Pad {
x : Int
y : Int
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Shorthand for creating a new `Pad`.
Expand Down
2 changes: 1 addition & 1 deletion src/misc_language.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(all) enum Language {
Ukrainian
/// tp 🇨🇦 🙂
TokiPona
} derive(Show, Eq, Hash)
} derive(Debug, Eq, Hash)

///|
pub impl Default for Language with default() -> Language {
Expand Down
2 changes: 1 addition & 1 deletion src/misc_settings.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pub(all) struct Settings {
contrast : Bool
/// If true, the player wants to see easter eggs, holiday effects, and weird jokes.
easter_eggs : Bool
} derive(Show, Eq)
} derive(Debug, Eq)
2 changes: 1 addition & 1 deletion src/misc_theme.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub(all) struct Theme {
accent : Color
/// The background color, the most contrast color to primary.
bg : Color
} derive(Show, Eq)
} derive(Debug, Eq)

///|
pub impl Default for Theme with default() -> Theme {
Expand Down
8 changes: 4 additions & 4 deletions src/random/top.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn uint64(limit? : UInt64) -> UInt64 {
}

match limit {
Some(lim) if lim <= @uint.max_value.to_uint64() =>
Some(lim) if lim <= @uint.MAX_VALUE.to_uint64() =>
@firefly.get_random().to_uint64() % lim
Some(lim) => rand() % lim
None => rand()
Expand All @@ -43,7 +43,7 @@ pub fn uint64(limit? : UInt64) -> UInt64 {
/// Returns a random 32-bit `Int` in the range `[0, 2^31)`,
/// or `[0, limit)` if limit is provided.
pub fn int(limit? : Int) -> Int {
let res = (@firefly.get_random() & @int.max_value.reinterpret_as_uint()).reinterpret_as_int()
let res = (@firefly.get_random() & @int.MAX_VALUE.reinterpret_as_uint()).reinterpret_as_int()
match limit {
Some(lim) => res % lim
None => res
Expand All @@ -57,11 +57,11 @@ pub fn int64(limit? : Int64) -> Int64 {
fn rand() -> Int64 {
let hi = @firefly.get_random()
let lo = @firefly.get_random()
(((hi.to_uint64() & @int.max_value.to_uint64()) << 32) | lo.to_uint64()).reinterpret_as_int64()
(((hi.to_uint64() & @int.MAX_VALUE.to_uint64()) << 32) | lo.to_uint64()).reinterpret_as_int64()
}

match limit {
Some(lim) if lim <= @uint.max_value.to_int64() =>
Some(lim) if lim <= @uint.MAX_VALUE.to_int64() =>
@firefly.get_random().to_uint64().reinterpret_as_int64() % lim
Some(lim) => rand() % lim
None => rand()
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/arc.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(all) struct Arc {
start : Angle
sweep : Angle
style : Style
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Draw this arc to the screen (or the current canvas, if one is set).
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/circle.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub(all) struct Circle {
point : Point
diameter : Int
style : Style
} derive(Show, Eq, Compare, Hash, Default)
} derive(Debug, Eq, Compare, Hash, Default)

///|
/// Draw this circle to the screen (or the current canvas, if one is set).
Expand Down
Loading
Loading