module Mineshift::Window

Overview

Window information

Defined in:

mineshift.cr

Constant Summary

ALL = [->(layer : UInt8, x : Float32, y : Float32, w : Float32, h : Float32) do padding = w * PADDING_RATIO if Mineshift.perlin.prng_item(x.to_i, y.to_i, layer.to_i, [true, false], Seeds::OUTER_WINDOW) Rl.draw_circle(x + (w / 2.0), y + (h / 2.0), (w / 2.0) - padding, Rl::BLACK) else r = Rl::Rectangle.new(x: x + padding, y: y + padding, width: w - (padding * 2.0), height: h - (padding * 2.0)) Rl.draw_rectangle_rec(r, Rl::BLACK) end type = Mineshift.perlin.prng_item(x.to_i, y.to_i, CIRCLE_TYPES, Seeds::CIRCLE_WINDOW_TYPE) window_color = Rl::WHITE thickness = w * 0.1 if type == (:center) Rl.draw_circle(x + (w / 2.0), y + (h / 2.0), (w / 3.0) - padding, window_color) else if (type == (:strut)) && (layer != 1) parts = [->(x : Float32, y : Float32, r : Float32) do Rl.draw_line_ex(Rl::Vector2.new(x: x, y: y), Rl::Vector2.new(x: x + r, y: y), thickness, window_color) end, ->(x : Float32, y : Float32, r : Float32) do Rl.draw_line_ex(Rl::Vector2.new(x: x, y: y), Rl::Vector2.new(x: x - r, y: y), thickness, window_color) end, ->(x : Float32, y : Float32, r : Float32) do Rl.draw_line_ex(Rl::Vector2.new(x: x, y: y), Rl::Vector2.new(x: x, y: y + r), thickness, window_color) end, ->(x : Float32, y : Float32, r : Float32) do Rl.draw_line_ex(Rl::Vector2.new(x: x, y: y), Rl::Vector2.new(x: x, y: y - r), thickness, window_color) end, ->(x : Float32, y : Float32, r : Float32) do Rl.draw_circle_v(Rl::Vector2.new(x: x, y: y), r * 0.3, window_color) end] of Proc(Float32, Float32, Float32, Nil) number_of_parts = Mineshift.perlin.prng_int(x.to_i, y.to_i, Window::CIRCLE_MIN_PARTS.to_i, Window::CIRCLE_MAX_PARTS.to_i + 1, Seeds::CIRCLE_WINDOW_STRUT_PARTS_NUMBER) number_of_parts.times do |z| part_index = Mineshift.perlin.prng_int(x.to_i, y.to_i, z, 0, parts.size, Seeds::CIRCLE_WINDOW_STRUT_PARTS) parts[part_index].call(x + (w / 2.0), y + (h / 2.0), (w / 2.0).to_f32) parts.delete_at(part_index) end end end end] of Proc(UInt8, Float32, Float32, Float32, Float32, Nil)

All the windows made into procs that take a x, y, w, h value and fits the window in that rectangle.

CHANCE = 1

Chance to spawn a window

CIRCLE_MAX_PARTS = 5

Maximum circle parts for :strut

CIRCLE_MIN_PARTS = 4

Minimum circle parts for :strut

CIRCLE_TYPES = [:plain, :center, :strut]

What types the circle window can have

OUT_OF = 3

Chance to spawn a window out of how many total?

PADDING_RATIO = 0.2
RATIO = 2.0