Skip to content

Commit

Permalink
Add first robot programming iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
SaturnHafen committed Jan 17, 2024
1 parent 333f2fc commit 67f00f9
Show file tree
Hide file tree
Showing 10 changed files with 450 additions and 1 deletion.
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config_version=5
[application]

config/name="pronto"
run/main_scene="res://prototypes/game-esportsreadymario/game-esportsreadymario.tscn"
run/main_scene="res://prototypes/game-robot-programming/game-robot-programming.tscn"
config/features=PackedStringArray("4.2", "Forward Plus")
run/low_processor_mode=true
config/icon="res://icon.svg"
Expand Down
5 changes: 5 additions & 0 deletions prototypes/game-robot-programming/code1.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends Node2D


func get_code():
return "forward"
14 changes: 14 additions & 0 deletions prototypes/game-robot-programming/code2.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
extends Node2D


func get_code():
return "while"

func get_stmts():
var areas = self.get_parent().get_overlapping_areas()

areas.sort_custom(func (a: Area2D, b: Area2D): return a.position.y < b.position.y)

areas.filter(func(x: Area2D): return x.position.y > self.get_parent().position.y)

return areas
28 changes: 28 additions & 0 deletions prototypes/game-robot-programming/draganddrop.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
extends Area2D

var dragging: bool = false

signal dragsignal


# Called when the node enters the scene tree for the first time.
func _ready():
dragsignal.connect(self._set_drag_pc)


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if dragging:
var mousepos = get_viewport().get_mouse_position()
self.position = mousepos

func _set_drag_pc():
dragging = !dragging

func _on_input_event(viewport, event, shape_idx):
print("Input event")
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
dragsignal.emit()
elif event.button_index == MOUSE_BUTTON_LEFT and !event.pressed:
dragsignal.emit()
7 changes: 7 additions & 0 deletions prototypes/game-robot-programming/enlarge.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends Button

func enlarge():
$"../CollisionShape2D".shape.size.y += 10
$"../CollisionShape2D".position.y += 5
$"../Polygon2D".polygon[0].y += 10
$"../Polygon2D".polygon[3].y += 10
Loading

0 comments on commit 67f00f9

Please sign in to comment.