From 7f4640b727da2d92dcf5cab29e78bfe14f4d2f7d Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 6 Jul 2019 18:30:03 -0700 Subject: [PATCH] Add Switches, Fire/Water Collision and Play Menu * New doodads: Switches. * They come in four varieties: wall switch (background element, with "ON/OFF" text) and three side-profile switches for the floor, left or right walls. * On collision with the player, they flip their state from "OFF" to "ON" or vice versa. If the player walks away and then collides again, the switch flips again. * Can be used to open/close Electric Doors when turned on/off. Their default state is "off" * If a switch receives a power signal from another linked switch, it sets its own state to match. So, two "on/off" switches that are connected to a door AND to each other will both flip on/off when one of them flips. * Update the Level Collision logic to support Decoration, Fire and Water pixel collisions. * Previously, ALL pixels in the level were acting as though solid. * Non-solid pixels don't count for collision detection, but their attributes (fire and water) are collected and returned. * Updated the MenuScene to support loading a map file in Play Mode instead of Edit Mode. Updated the title screen menu to add a button for playing levels instead of editing them. * Wrote some documentation. --- color.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/color.go b/color.go index 3ec3ac5..e6b045d 100644 --- a/color.go +++ b/color.go @@ -211,6 +211,11 @@ func (c Color) DecodeMsgpack(dec *msgpack.Decoder) error { // return nil // } +// IsZero returns if the color is all zeroes (invisible). +func (c Color) IsZero() bool { + return c.Red+c.Green+c.Blue+c.Alpha == 0 +} + // Add a relative color value to the color. func (c Color) Add(r, g, b, a int) Color { var ( @@ -237,6 +242,16 @@ func (c Color) Add(r, g, b, a int) Color { } } +// AddColor adds another Color to your Color. +func (c Color) AddColor(other Color) Color { + return c.Add( + int(other.Red), + int(other.Green), + int(other.Blue), + int(other.Alpha), + ) +} + // Lighten a color value. func (c Color) Lighten(v int) Color { return c.Add(v, v, v, 0)