Skip to content

Commit

Permalink
The egg is back
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrlabs committed Aug 18, 2024
1 parent f51ab59 commit 50f24ef
Show file tree
Hide file tree
Showing 12 changed files with 271 additions and 136 deletions.
2 changes: 1 addition & 1 deletion lorien/Assets/I18n/de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,5 @@ ACTION_copy_strokes Kopieren
ACTION_paste_strokes Einfügen
ACTION_duplicate_strokes Auswahl duplizieren
ACTION_toggle_distraction_free_mode Zen modus aktivieren
ACTION_toggle_player Easteregg
ACTION_toggle_player Toggle Easteregg
ACTION_toggle_fullscreen Vollbildmodus
30 changes: 15 additions & 15 deletions lorien/Assets/I18n/en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,26 @@ DELETE Delete
# Action names
# -----------------------------------------------------------------------------

ACTION_shortcut_save_project Save file
ACTION_shortcut_new_project New file
ACTION_shortcut_open_project Open file
ACTION_shortcut_save_project Save File
ACTION_shortcut_new_project New File
ACTION_shortcut_open_project Open File
ACTION_shortcut_undo Undo
ACTION_shortcut_redo Redo
ACTION_shortcut_brush_tool Brush tool
ACTION_shortcut_line_tool Line tool
ACTION_shortcut_eraser_tool Eraser tool
ACTION_shortcut_select_tool Selection tool
ACTION_shortcut_rectangle_tool Rectangle tool
ACTION_shortcut_circle_tool Circle tool
ACTION_shortcut_export_project Export file
ACTION_deselect_all_strokes Deselect all strokes
ACTION_delete_selected_strokes Delete selected strokes
ACTION_shortcut_brush_tool Brush Tool
ACTION_shortcut_line_tool Line Tool
ACTION_shortcut_eraser_tool Eraser Tool
ACTION_shortcut_select_tool Selection Tool
ACTION_shortcut_rectangle_tool Rectangle Tool
ACTION_shortcut_circle_tool Circle Tool
ACTION_shortcut_export_project Export File
ACTION_deselect_all_strokes Deselect All Strokes
ACTION_delete_selected_strokes Delete Selected Strokes
ACTION_copy_strokes Copy
ACTION_paste_strokes Paste
ACTION_duplicate_strokes Duplicate strokes
ACTION_toggle_distraction_free_mode Toggle distraction free mode
ACTION_toggle_player EFF TWELVE
ACTION_toggle_fullscreen Toggle fullscreen
ACTION_toggle_distraction_free_mode Zen Mode
ACTION_toggle_player Toggle Easteregg
ACTION_toggle_fullscreen Toggle Fullscreen

# -----------------------------------------------------------------------------
# Kebindings dialog messages
Expand Down
2 changes: 1 addition & 1 deletion lorien/Assets/I18n/it.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ ACTION_copy_strokes Copia i tratti
ACTION_paste_strokes Incolla i tratti
ACTION_duplicate_strokes Duplica i tratti
ACTION_toggle_distraction_free_mode Abilita la modalità senza distrazioni
ACTION_toggle_player EFF TWELVE
ACTION_toggle_player Toggle Easteregg
ACTION_toggle_fullscreen Schermo intero

#---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lorien/Assets/I18n/pt-BR.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ ACTION_copy_strokes Copiar traços
ACTION_paste_strokes Colar traços
ACTION_duplicate_strokes Duplicar traços
ACTION_toggle_distraction_free_mode (Des)ativar modo livre de distrações
ACTION_toggle_player (Des)ativar jogador
ACTION_toggle_player Toggle Easteregg
ACTION_toggle_fullscreen (Des)ativar Tela Cheia

# -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lorien/Assets/I18n/tr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ ACTION_copy_strokes Kopyala
ACTION_paste_strokes Yapıştır
ACTION_duplicate_strokes Vuruşlarıkopyala
ACTION_toggle_distraction_free_mode Dikkat dağıtmama modu
ACTION_toggle_player EFF TWELVE
ACTION_toggle_player Toggle Easteregg
ACTION_toggle_fullscreen Tam Ekran

# -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lorien/Assets/I18n/uk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ ACTION_copy_strokes Скопіювати
ACTION_paste_strokes Вставити
ACTION_duplicate_strokes Дублювати штрихи
ACTION_toggle_distraction_free_mode Перемкнути zen-режим
ACTION_toggle_player ЕФФ ДВАНАДЦЯТЬ
ACTION_toggle_player Toggle Easteregg
ACTION_toggle_fullscreen Перемкнути повноекранний режим

# -----------------------------------------------------------------------------
Expand Down
24 changes: 24 additions & 0 deletions lorien/BrushStroke/BrushStroke.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const MAX_POINTS := 1000
const MAX_PRESSURE_VALUE := 255
const MIN_PRESSURE_VALUE := 30
const MAX_PRESSURE_DIFF := 20
const COLLIDER_NODE_NAME := "StrokeCollider"
const GROUP_ONSCREEN := "onscreen_stroke"

const MAX_VECTOR2 := Vector2(2147483647, 2147483647)
Expand Down Expand Up @@ -79,6 +80,29 @@ func remove_all_points() -> void:
_line2d.points = PackedVector2Array()
_line2d.width_curve.clear_points()

# -------------------------------------------------------------------------------------------------
func enable_collider(enable: bool) -> void:
# Remove current collider
var collider = get_node_or_null(COLLIDER_NODE_NAME)
if collider != null:
remove_child(collider)
collider.queue_free()

# Create new collider
if enable:
var body := StaticBody2D.new()
body.name = COLLIDER_NODE_NAME
var idx := 0
while idx < points.size()-1:
var col := CollisionShape2D.new()
var shape := SegmentShape2D.new()
shape.a = points[idx]
shape.b = points[idx + 1]
col.shape = shape
body.add_child(col)
idx += 1
add_child(body)

# ------------------------------------------------------------------------------------------------
func refresh() -> void:
var max_pressure := float(MAX_PRESSURE_VALUE)
Expand Down
24 changes: 24 additions & 0 deletions lorien/InfiniteCanvas/InfiniteCanvas.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class_name InfiniteCanvas

# -------------------------------------------------------------------------------------------------
const BRUSH_STROKE = preload("res://BrushStroke/BrushStroke.tscn")
const PLAYER = preload("res://Misc/Player/Player.tscn")

# -------------------------------------------------------------------------------------------------
@onready var _brush_tool: BrushTool = $BrushTool
Expand Down Expand Up @@ -30,6 +31,8 @@ var _current_stroke: BrushStroke
var _current_project: Project
var _use_optimizer := true
var _optimizer: BrushStrokeOptimizer
var _player: Player = null
var _player_enabled := false

# -------------------------------------------------------------------------------------------------
func _ready():
Expand Down Expand Up @@ -137,6 +140,23 @@ func set_background_color(color: Color) -> void:
RenderingServer.set_default_clear_color(_background_color)
_grid.set_canvas_color(_background_color)

# -------------------------------------------------------------------------------------------------
func enable_player(enable: bool) -> void:
_player_enabled = enable

# colliders
for stroke in _strokes_parent.get_children():
stroke.enable_collider(enable)

# player
if enable:
_player = PLAYER.instantiate()
_player.reset(_active_tool.get_cursor().global_position)
_viewport.add_child(_player)
else:
_viewport.remove_child(_player)
_player = null

# -------------------------------------------------------------------------------------------------
func enable_grid(e: bool) -> void:
_grid.enable(e)
Expand Down Expand Up @@ -226,6 +246,10 @@ func end_stroke() -> void:
# TODO: not sure if needed here
_current_stroke.refresh()

# Colliders for the platformer easter-egg
if _player_enabled:
_current_stroke.enable_collider(true)

# Remove the line temporally from the node tree, so the adding is registered in the undo-redo histrory below
_strokes_parent.remove_child(_current_stroke)

Expand Down
66 changes: 38 additions & 28 deletions lorien/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extends Control
var _ui_visible := true
var _exit_requested := false
var _dirty_project_to_close: Project = null
var _player_enabled := false

# -------------------------------------------------------------------------------------------------
func _ready():
Expand Down Expand Up @@ -141,34 +142,43 @@ func _process(delta):
# -------------------------------------------------------------------------------------------------
func _unhandled_input(event):
if !is_dialog_open():
if Utils.event_pressed_bug_workaround("shortcut_new_project", event):
_on_create_new_project()
elif Utils.event_pressed_bug_workaround("shortcut_open_project", event):
_toolbar._on_OpenFileButton_pressed()
elif Utils.event_pressed_bug_workaround("shortcut_save_project", event):
_on_save_project()
elif Utils.event_pressed_bug_workaround("shortcut_export_project", event):
_export_svg()
elif Utils.event_pressed_bug_workaround("shortcut_undo", event):
_on_undo_action()
elif Utils.event_pressed_bug_workaround("shortcut_redo", event):
_on_redo_action()
elif Utils.event_pressed_bug_workaround("shortcut_brush_tool", event):
_toolbar.enable_tool(Types.Tool.BRUSH)
elif Utils.event_pressed_bug_workaround("shortcut_rectangle_tool", event):
_toolbar.enable_tool(Types.Tool.RECTANGLE)
elif Utils.event_pressed_bug_workaround("shortcut_circle_tool", event):
_toolbar.enable_tool(Types.Tool.CIRCLE)
elif Utils.event_pressed_bug_workaround("shortcut_line_tool", event):
_toolbar.enable_tool(Types.Tool.LINE)
elif Utils.event_pressed_bug_workaround("shortcut_eraser_tool", event):
_toolbar.enable_tool(Types.Tool.ERASER)
elif Utils.event_pressed_bug_workaround("shortcut_select_tool", event):
_toolbar.enable_tool(Types.Tool.SELECT)
elif Utils.event_pressed_bug_workaround("toggle_distraction_free_mode", event):
_toggle_distraction_free_mode()
elif Utils.event_pressed_bug_workaround("toggle_fullscreen", event):
_toggle_fullscreen()
if Utils.event_pressed_bug_workaround("toggle_player", event):
_toggle_player()

if !_player_enabled:
if Utils.event_pressed_bug_workaround("shortcut_new_project", event):
_on_create_new_project()
elif Utils.event_pressed_bug_workaround("shortcut_open_project", event):
_toolbar._on_OpenFileButton_pressed()
elif Utils.event_pressed_bug_workaround("shortcut_save_project", event):
_on_save_project()
elif Utils.event_pressed_bug_workaround("shortcut_export_project", event):
_export_svg()
elif Utils.event_pressed_bug_workaround("shortcut_undo", event):
_on_undo_action()
elif Utils.event_pressed_bug_workaround("shortcut_redo", event):
_on_redo_action()
elif Utils.event_pressed_bug_workaround("shortcut_brush_tool", event):
_toolbar.enable_tool(Types.Tool.BRUSH)
elif Utils.event_pressed_bug_workaround("shortcut_rectangle_tool", event):
_toolbar.enable_tool(Types.Tool.RECTANGLE)
elif Utils.event_pressed_bug_workaround("shortcut_circle_tool", event):
_toolbar.enable_tool(Types.Tool.CIRCLE)
elif Utils.event_pressed_bug_workaround("shortcut_line_tool", event):
_toolbar.enable_tool(Types.Tool.LINE)
elif Utils.event_pressed_bug_workaround("shortcut_eraser_tool", event):
_toolbar.enable_tool(Types.Tool.ERASER)
elif Utils.event_pressed_bug_workaround("shortcut_select_tool", event):
_toolbar.enable_tool(Types.Tool.SELECT)
elif Utils.event_pressed_bug_workaround("toggle_distraction_free_mode", event):
_toggle_distraction_free_mode()
elif Utils.event_pressed_bug_workaround("toggle_fullscreen", event):
_toggle_fullscreen()

# -------------------------------------------------------------------------------------------------
func _toggle_player() -> void:
_player_enabled = !_player_enabled
_canvas.enable_player(_player_enabled)

# -------------------------------------------------------------------------------------------------
func _save_state() -> void:
Expand Down
80 changes: 40 additions & 40 deletions lorien/Misc/Player/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@ class_name Player
extends CharacterBody2D

# -------------------------------------------------------------------------------------------------
#export var speed: float = 400
#export var jump_power: float = 1000
#export var gravity: float = 60
#onready var _sprite: AnimatedSprite = $AnimatedSprite
#onready var _col_shape_normal: CollisionShape2D = $CollisionShapeNormal
#onready var _col_shape_crouching: CollisionShape2D = $CollisionShapeCrouching
#var _velocity: Vector2 = Vector2.ZERO
#
#func _physics_process(delta: float) -> void:
# var is_crouching := false
# _velocity.y += gravity
# if Input.is_action_pressed("player_move_left"):
# _velocity.x = -speed
# _sprite.play("walk")
# _sprite.flip_h = true
# elif Input.is_action_pressed("player_move_right"):
# _velocity.x = speed
# _sprite.play("walk")
# _sprite.flip_h = false
# elif Input.is_action_pressed("player_crouch"):
# is_crouching = true
# _sprite.play("crouch")
# elif is_on_floor():
# _velocity.x = 0
# _sprite.play("idle")
#
# if is_on_floor() && Input.is_action_just_pressed("player_jump"):
# _velocity.y -= jump_power
# _sprite.play("jump")
#
# _col_shape_crouching.disabled = !is_crouching
# _col_shape_normal.disabled = is_crouching
#
#
# _velocity = move_and_slide(_velocity, Vector2.UP, false, 4, PI/4.0, false)
#
## -------------------------------------------------------------------------------------------------
#func reset(global_pos: Vector2) -> void:
# global_position = global_pos
# _velocity = Vector2.ZERO
@export var speed: float = 600
@export var jump_power: float = 1000
@export var gravity: float = 60

@onready var _sprite: AnimatedSprite2D = $AnimatedSprite2D
@onready var _col_shape_normal: CollisionShape2D = $CollisionShapeNormal
@onready var _col_shape_crouching: CollisionShape2D = $CollisionShapeCrouching

# -------------------------------------------------------------------------------------------------
func _physics_process(delta: float) -> void:
var is_crouching := false
velocity.y += gravity
if Input.is_action_pressed("player_crouch"):
is_crouching = true
_sprite.play("crouch")
elif Input.is_action_pressed("player_move_left"):
velocity.x = -speed
_sprite.play("walk")
_sprite.flip_h = true
elif Input.is_action_pressed("player_move_right"):
velocity.x = speed
_sprite.play("walk")
_sprite.flip_h = false
elif is_on_floor():
velocity.x = 0
_sprite.play("idle")

if is_on_floor() && Input.is_action_just_pressed("player_jump"):
velocity.y -= jump_power
_sprite.play("jump")

_col_shape_crouching.disabled = !is_crouching
_col_shape_normal.disabled = is_crouching

move_and_slide()

# -------------------------------------------------------------------------------------------------
func reset(global_pos: Vector2) -> void:
global_position = global_pos
velocity = Vector2.ZERO
Loading

0 comments on commit 50f24ef

Please sign in to comment.