mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-11 19:04:50 +01:00
Automatically draw new cards
This commit is contained in:
parent
92c6dce691
commit
0d5c78d2a4
2 changed files with 27 additions and 12 deletions
20
card.gd
20
card.gd
|
@ -30,10 +30,16 @@ func _unhandled_input(event):
|
|||
dragged = false
|
||||
game.dragged_object = null
|
||||
modulate.a = 1
|
||||
move_back()
|
||||
|
||||
if arg_number == 0 and get_viewport().get_mouse_position().y < get_viewport().size.y/2 :
|
||||
$"../Terminal".send_command($Label.text)
|
||||
|
||||
|
||||
if get_viewport().get_mouse_position().y < get_viewport().size.y/2:
|
||||
if arg_number == 0 :
|
||||
$"../Terminal".send_command($Label.text)
|
||||
buuurn()
|
||||
else:
|
||||
move_back()
|
||||
else:
|
||||
_home_position = get_viewport().get_mouse_position() + drag_offset
|
||||
|
||||
func _mouse_entered():
|
||||
hovered = true
|
||||
|
@ -47,6 +53,10 @@ func set_command(new_command):
|
|||
|
||||
func move_back():
|
||||
position = _home_position
|
||||
|
||||
func buuurn():
|
||||
queue_free()
|
||||
$"..".draw_rand_card()
|
||||
|
||||
func dropped_on(other):
|
||||
#print("I have been dropped on "+str(other.id))
|
||||
|
@ -55,10 +65,12 @@ func dropped_on(other):
|
|||
1:
|
||||
full_command = $Label.text + " " + other.id
|
||||
$"../Terminal".send_command(full_command)
|
||||
buuurn()
|
||||
2:
|
||||
if _first_argument:
|
||||
full_command = $Label.text + " " + _first_argument + " " + other.id
|
||||
$"../Terminal".send_command(full_command)
|
||||
buuurn()
|
||||
else:
|
||||
_first_argument = other.id
|
||||
|
||||
|
|
19
cardgame.gd
19
cardgame.gd
|
@ -24,14 +24,17 @@ func _ready():
|
|||
|
||||
$Terminal.repository = $Repository
|
||||
|
||||
var pos_x = 100
|
||||
for card in cards:
|
||||
var new_card = preload("res://card.tscn").instance()
|
||||
new_card.command = card.command
|
||||
new_card.arg_number = card.arg_number
|
||||
new_card.position = Vector2(pos_x, get_viewport().size.y*3/4)
|
||||
pos_x += 250
|
||||
add_child(new_card)
|
||||
for i in range(4):
|
||||
draw_rand_card()
|
||||
|
||||
func _update_repo():
|
||||
$Repository.update_everything()
|
||||
|
||||
func draw_rand_card():
|
||||
var new_card = preload("res://card.tscn").instance()
|
||||
var card = cards[randi() % cards.size()]
|
||||
new_card.command = card.command
|
||||
new_card.arg_number = card.arg_number
|
||||
new_card.position = Vector2(rand_range(200, get_viewport().size.x - 200), get_viewport().size.y*3/4 + rand_range(-200,200))
|
||||
add_child(new_card)
|
||||
|
||||
|
|
Loading…
Reference in a new issue