fix/func: added beginnings of turn winning function. Fixed "Card_Container"s not appearing & dissapearing properly
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Hyunjoon Park
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,35 @@
|
||||
# Card Framework
|
||||
|
||||
Professional Godot 4.x addon for creating 2D card games.
|
||||
|
||||
## Overview
|
||||
|
||||
Build Solitaire, TCG, or deck-building roguelikes with:
|
||||
- **Drag & Drop System** - Built-in card interactions
|
||||
- **Flexible Containers** - Pile (stacks) and Hand (fans)
|
||||
- **JSON Card Data** - Metadata-driven card creation
|
||||
- **Extensible Design** - Factory patterns and inheritance
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Add `CardManager` node to your scene
|
||||
2. Configure `JsonCardFactory` with asset directories
|
||||
3. Create JSON card definitions
|
||||
4. Add `Pile` or `Hand` container nodes
|
||||
|
||||
## Documentation & Examples
|
||||
|
||||
**Full Documentation:** https://github.com/chun92/card-framework
|
||||
|
||||
**Download Examples:** https://github.com/chun92/card-framework/releases/latest
|
||||
- Look for `card-framework-vX.X.X-full.zip`
|
||||
- Includes complete example projects (basic demo + FreeCell game)
|
||||
- Full API reference and tutorials included
|
||||
|
||||
## Version
|
||||
|
||||
1.3.2 - Godot 4.6+ compatible
|
||||
|
||||
## License
|
||||
|
||||
MIT License - Copyright (c) 2025 Hyunjoon Park
|
||||
@@ -29,7 +29,7 @@ extends Control
|
||||
|
||||
# Static counter for unique container identification
|
||||
static var next_id: int = 0
|
||||
|
||||
signal played
|
||||
|
||||
@export_group("drop_zone")
|
||||
## Enables or disables the drop zone functionality.
|
||||
@@ -98,6 +98,20 @@ func _ready() -> void:
|
||||
else:
|
||||
drop_zone.sensor_outline.visible = false
|
||||
|
||||
func _redraw_drop_zone():
|
||||
if enable_drop_zone:
|
||||
drop_zone = drop_zone_scene.instantiate()
|
||||
add_child(drop_zone)
|
||||
drop_zone.init(self, [CardManager.CARD_ACCEPT_TYPE])
|
||||
# If sensor_size is not set, they will follow the card size.
|
||||
if sensor_size == Vector2(0, 0):
|
||||
sensor_size = card_manager.card_size
|
||||
drop_zone.set_sensor(sensor_size, sensor_position, sensor_texture, sensor_visibility)
|
||||
if debug_mode:
|
||||
drop_zone.sensor_outline.visible = true
|
||||
else:
|
||||
drop_zone.sensor_outline.visible = false
|
||||
drop_zone.redraw_sensor()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
if card_manager != null:
|
||||
@@ -286,7 +300,7 @@ func get_string() -> String:
|
||||
|
||||
|
||||
func on_card_move_done(_card: Card):
|
||||
pass
|
||||
played.emit()
|
||||
|
||||
|
||||
func on_card_pressed(_card: Card):
|
||||
|
||||
@@ -115,6 +115,30 @@ func init(_parent: Node, accept_types: Array =[]):
|
||||
vertical_partition = []
|
||||
horizontal_partition = []
|
||||
|
||||
func redraw_sensor():
|
||||
# Create invisible sensor for hit detection
|
||||
if sensor == null:
|
||||
sensor = TextureRect.new()
|
||||
sensor.name = "Sensor"
|
||||
sensor.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
sensor.z_index = CardFrameworkSettings.VISUAL_SENSOR_Z_INDEX # Behind everything else
|
||||
add_child(sensor)
|
||||
|
||||
# Create debugging outline (initially hidden)
|
||||
if sensor_outline == null:
|
||||
sensor_outline = ReferenceRect.new()
|
||||
sensor_outline.editor_only = false
|
||||
sensor_outline.name = "SensorOutline"
|
||||
sensor_outline.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
sensor_outline.border_color = CardFrameworkSettings.DEBUG_OUTLINE_COLOR
|
||||
sensor_outline.z_index = CardFrameworkSettings.VISUAL_OUTLINE_Z_INDEX
|
||||
add_child(sensor_outline)
|
||||
|
||||
# Initialize default values
|
||||
stored_sensor_size = Vector2(0, 0)
|
||||
stored_sensor_position = Vector2(0, 0)
|
||||
vertical_partition = []
|
||||
horizontal_partition = []
|
||||
|
||||
## Checks if the mouse cursor is currently within the drop zone sensor area.
|
||||
## @returns: True if mouse is inside the sensor bounds
|
||||
|
||||
@@ -72,6 +72,8 @@ func get_top_cards(n: int) -> Array:
|
||||
|
||||
return result
|
||||
|
||||
#func _process(delta: float) -> void:
|
||||
#play_check()
|
||||
|
||||
## Updates z-index values for all cards to maintain proper layering.
|
||||
## Pressed cards receive elevated z-index to appear above the pile.
|
||||
|
||||
Reference in New Issue
Block a user