mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-24 16:20:08 +01:00
Cards have an energy value
This commit is contained in:
parent
8e49efe906
commit
3c19740994
4 changed files with 104 additions and 17 deletions
21
card.gd
21
card.gd
|
@ -7,15 +7,25 @@ var drag_offset
|
||||||
export var arg_number = 0
|
export var arg_number = 0
|
||||||
export var command = "" setget set_command
|
export var command = "" setget set_command
|
||||||
export var description = "" setget set_description
|
export var description = "" setget set_description
|
||||||
|
export var energy = 0 setget set_energy
|
||||||
|
|
||||||
var _first_argument = null
|
var _first_argument = null
|
||||||
var _home_position = null
|
var _home_position = null
|
||||||
var _home_rotation = null
|
var _home_rotation = null
|
||||||
|
|
||||||
|
onready var energy_label = $Sprite/Energy
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
set_process_unhandled_input(true)
|
set_process_unhandled_input(true)
|
||||||
|
set_energy(energy)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
if game.energy >= energy:
|
||||||
|
energy_label.modulate = Color(0.5, 1, 0.5)
|
||||||
|
else:
|
||||||
|
energy_label.modulate = Color(1, 1, 1)
|
||||||
|
modulate = Color(1, 0.5, 0.5)
|
||||||
|
|
||||||
if dragged:
|
if dragged:
|
||||||
var mousepos = get_viewport().get_mouse_position()
|
var mousepos = get_viewport().get_mouse_position()
|
||||||
global_position = mousepos - drag_offset
|
global_position = mousepos - drag_offset
|
||||||
|
@ -78,6 +88,11 @@ func set_description(new_description):
|
||||||
description = new_description
|
description = new_description
|
||||||
$Description.text = description
|
$Description.text = description
|
||||||
|
|
||||||
|
func set_energy(new_energy):
|
||||||
|
energy = new_energy
|
||||||
|
if energy_label:
|
||||||
|
energy_label.text = str(energy)
|
||||||
|
|
||||||
func move_back():
|
func move_back():
|
||||||
position = _home_position
|
position = _home_position
|
||||||
rotation_degrees = _home_rotation
|
rotation_degrees = _home_rotation
|
||||||
|
@ -104,9 +119,3 @@ func dropped_on(other):
|
||||||
# buuurn()
|
# buuurn()
|
||||||
# else:
|
# else:
|
||||||
# _first_argument = other.id
|
# _first_argument = other.id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
22
card.tscn
22
card.tscn
|
@ -1,7 +1,8 @@
|
||||||
[gd_scene load_steps=6 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://card.gd" type="Script" id=1]
|
[ext_resource path="res://card.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2]
|
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2]
|
||||||
|
[ext_resource path="res://nodes/blob.svg" type="Texture" id=3]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id=1]
|
[sub_resource type="StyleBoxFlat" id=1]
|
||||||
bg_color = Color( 0.45098, 0.584314, 0.843137, 1 )
|
bg_color = Color( 0.45098, 0.584314, 0.843137, 1 )
|
||||||
|
@ -96,5 +97,24 @@ autowrap = true
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
position = Vector2( -103.288, -287.778 )
|
||||||
|
scale = Vector2( 0.542341, 0.542341 )
|
||||||
|
texture = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="Energy" type="Label" parent="Sprite"]
|
||||||
|
margin_left = -51.1637
|
||||||
|
margin_top = -47.4558
|
||||||
|
margin_right = -17.1637
|
||||||
|
margin_bottom = -16.4558
|
||||||
|
rect_scale = Vector2( 3, 3 )
|
||||||
|
custom_fonts/font = ExtResource( 2 )
|
||||||
|
text = "0"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
[connection signal="mouse_entered" from="Area2D" to="." method="_mouse_entered"]
|
[connection signal="mouse_entered" from="Area2D" to="." method="_mouse_entered"]
|
||||||
[connection signal="mouse_exited" from="Area2D" to="." method="_mouse_exited"]
|
[connection signal="mouse_exited" from="Area2D" to="." method="_mouse_exited"]
|
||||||
|
|
77
cardgame.gd
77
cardgame.gd
|
@ -1,16 +1,72 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
var cards = [
|
var cards = [
|
||||||
{"command": 'git add .', "arg_number": 0, "description": "Add all files in the working directory to the index."},
|
{
|
||||||
{"command": 'git checkout', "arg_number": 1, "description": "Point HEAD to a branch or commit, and update the index and the working directory."},
|
"command": 'git add .',
|
||||||
{"command": 'touch "file$RANDOM"', "arg_number": 0, "description": "Create a new file."},
|
"arg_number": 0,
|
||||||
{"command": 'git commit --allow-empty -m "$RANDOM"', "arg_number": 0, "description": "Add a new commit under HEAD."},
|
"description": "Add all files in the working directory to the index.",
|
||||||
{"command": 'git checkout -b "$RANDOM"', "arg_number": 0, "description": "Create a new branch and switch to it."},
|
"energy": 1
|
||||||
{"command": 'git merge', "arg_number": 1, "description": "Merge specified commit into HEAD."},
|
},
|
||||||
{"command": 'git update-ref -d', "arg_number": 1, "description": "Delete a ref."},
|
{
|
||||||
{"command": 'git reflog expire --expire=now --all; git prune', "arg_number": 0, "description": "Delete all unreferenced objects."},
|
"command": 'git checkout',
|
||||||
{"command": 'git rebase', "arg_number": 1, "description": "Rebase current branch on top of specified commit."},
|
"arg_number": 1,
|
||||||
{"command": 'git push -f', "arg_number": 0, "description": "Push current branch to the remote. Will make everyone angry."},
|
"description": "Point HEAD to a branch or commit, and update the index and the working directory.",
|
||||||
|
"energy": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": 'touch "file$RANDOM"',
|
||||||
|
"arg_number": 0,
|
||||||
|
"description": "Create a new file.",
|
||||||
|
"energy": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": 'git commit --allow-empty -m "$RANDOM"',
|
||||||
|
"arg_number": 0,
|
||||||
|
"description": "Add a new commit under HEAD.",
|
||||||
|
"energy": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": 'git checkout -b "$RANDOM"',
|
||||||
|
"arg_number": 0,
|
||||||
|
"description": "Create a new branch and switch to it.",
|
||||||
|
"energy": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": 'git merge',
|
||||||
|
"arg_number": 1,
|
||||||
|
"description": "Merge specified commit into HEAD.",
|
||||||
|
"energy": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": 'git update-ref -d',
|
||||||
|
"arg_number": 1,
|
||||||
|
"description": "Delete a ref.",
|
||||||
|
"energy": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": 'git reflog expire --expire=now --all; git prune',
|
||||||
|
"arg_number": 0,
|
||||||
|
"description": "Delete all unreferenced objects.",
|
||||||
|
"energy": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": 'git rebase',
|
||||||
|
"arg_number": 1,
|
||||||
|
"description": "Rebase current branch on top of specified commit.",
|
||||||
|
"energy": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": 'git push -f',
|
||||||
|
"arg_number": 0,
|
||||||
|
"description": "Push current branch to the remote, overwriting existing commits. Will make everyone angry.",
|
||||||
|
"energy": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": 'git pull',
|
||||||
|
"arg_number": 0,
|
||||||
|
"description": "Pull current branch from the remote.",
|
||||||
|
"energy": 2
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
@ -46,6 +102,7 @@ func draw_rand_card():
|
||||||
new_card.command = card.command
|
new_card.command = card.command
|
||||||
new_card.arg_number = card.arg_number
|
new_card.arg_number = card.arg_number
|
||||||
new_card.description = card.description
|
new_card.description = card.description
|
||||||
|
new_card.energy = card.energy
|
||||||
new_card.position = Vector2(rect_size.x, rect_size.y*2)
|
new_card.position = Vector2(rect_size.x, rect_size.y*2)
|
||||||
add_child(new_card)
|
add_child(new_card)
|
||||||
arrange_cards()
|
arrange_cards()
|
||||||
|
|
1
game.gd
1
game.gd
|
@ -6,6 +6,7 @@ var global_shell
|
||||||
var fake_editor
|
var fake_editor
|
||||||
|
|
||||||
var dragged_object
|
var dragged_object
|
||||||
|
var energy = 2
|
||||||
|
|
||||||
var _file = "user://savegame.json"
|
var _file = "user://savegame.json"
|
||||||
var state = {}
|
var state = {}
|
||||||
|
|
Loading…
Reference in a new issue