1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-14 21:15:58 +00:00

Merge branch 'game-logic' of github.com:StatewideInk/Group12 into game-logic

This commit is contained in:
John 2021-11-24 03:08:48 -06:00
commit 3f4b42821b
6 changed files with 82 additions and 15 deletions

View File

@ -0,0 +1,3 @@
source_md5="e860aab5fa3b6ce9c5831b3624861eb0"
dest_md5="a265f8881bf649748bb86076a1059462"

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/HitMissAtlas.png-47e352b9aa0deb2bd08f554355b13c14.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/game/HitMissAtlas.png"
dest_files=[ "res://.import/HitMissAtlas.png-47e352b9aa0deb2bd08f554355b13c14.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -19,7 +19,7 @@ corner_radius_bottom_right = 3
corner_radius_bottom_left = 3 corner_radius_bottom_left = 3
shadow_size = 3 shadow_size = 3
[sub_resource type="DynamicFont" id=4] [sub_resource type="DynamicFont" id=3]
outline_size = 1 outline_size = 1
extra_spacing_top = 5 extra_spacing_top = 5
extra_spacing_bottom = 3 extra_spacing_bottom = 3
@ -27,7 +27,7 @@ extra_spacing_char = 1
font_data = ExtResource( 1 ) font_data = ExtResource( 1 )
[resource] [resource]
default_font = SubResource( 4 ) default_font = SubResource( 3 )
Button/colors/font_color = Color( 0.0784314, 0.0784314, 0.0784314, 1 ) Button/colors/font_color = Color( 0.0784314, 0.0784314, 0.0784314, 1 )
Button/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 ) Button/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
Button/colors/font_color_hover = Color( 0, 0, 0, 1 ) Button/colors/font_color_hover = Color( 0, 0, 0, 1 )

View File

@ -40,7 +40,7 @@ __meta__ = {
pause_mode = 2 pause_mode = 2
margin_right = 83.0 margin_right = 83.0
margin_bottom = 58.0 margin_bottom = 58.0
dialog_text = "You can't fire outside the board" dialog_text = "You must select a valid position"
[connection signal="pressed" from="Fire" to="." method="_on_Fire_pressed"] [connection signal="pressed" from="Fire" to="." method="_on_Fire_pressed"]
[connection signal="confirmed" from="FireDialog" to="." method="_on_FireDialog_confirmed"] [connection signal="confirmed" from="FireDialog" to="." method="_on_FireDialog_confirmed"]

View File

@ -1,5 +1,9 @@
extends Control extends Control
var atlas = preload("res://assets/game/HitMissAtlas.png")
var sprites = []
var hits = []
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
@ -7,22 +11,48 @@ func _ready():
# Signal to pass the fire location back to yet-unknown nodes # Signal to pass the fire location back to yet-unknown nodes
signal fire_at signal fire_at
func _init(topBoard):
hits = topBoard
func _on_Fire_pressed(): func _on_Fire_pressed():
var crosshair = get_node("Crosshair") var crosshair = get_node("Crosshair")
# Check if the crosshair is in a valid position # Check if the crosshair is in a valid position
if crosshair.validate_position(crosshair.position) == true: if crosshair.validate_position(crosshair.position):
var crosshair_pos = crosshair.world_to_board_space(crosshair.position) var crosshair_pos = crosshair.world_to_board_space(crosshair.position)
# fires at position if(hits[crosshair_pos.x][crosshair_pos.y] == 0):
print("Fire at position: ", crosshair_pos) # fires at position
emit_signal("fire_at", crosshair_pos) print("Fire at position: ", crosshair_pos)
# Close the Firing menu emit_signal("fire_at", crosshair_pos)
queue_free() # Close the Firing menu
else: queue_free()
#if invalid position popup appears return
var dialog = get_node("FireDialog") #if invalid position popup appears
dialog.popup_centered() var dialog = get_node("FireDialog")
pass # Replace with function body. dialog.popup_centered()
func _on_FireDialog_confirmed(): func _on_FireDialog_confirmed():
get_node("Crosshair").visible = true get_node("Crosshair").visible = true
pass # Replace with function body.
const OFFSET = Vector2(18, 18)
func texture(index):
if(hits[index.x][index.y] != 0):
var textureSize = 32
# It's okay to create a new texture every time, as resources are refcounted
var t = AtlasTexture.new()
t.set_atlas(atlas)
t.margin = Rect2(0, 0, 0, 0)
t.region = Rect2(
0 if(hits[index.x][index.y] < 0) else textureSize,
0,
textureSize,
textureSize
)
# Create a new Sprite to house the texture, or use the existing sprite
var sprite = Sprite.new()
sprite.texture = t
sprite.position = Vector2(index.x, index.y) * textureSize + OFFSET
printt(t.get_height(), t.get_width())
$board_blue.add_child(sprite)