Skip to content

Commit

Permalink
Merge pull request #46 from EthannYakabuski/yakabuski_M2
Browse files Browse the repository at this point in the history
Yakabuski m2
  • Loading branch information
EthannYakabuski authored Nov 16, 2024
2 parents 0e9f6b4 + 36eb6ac commit f3c9bb9
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 6 deletions.
Binary file modified animalDash.aab
Binary file not shown.
7 changes: 6 additions & 1 deletion background.gd
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,17 @@ func _ready():
var parsedData = JSON.parse_string(currentData)
#$DebugText.text = $DebugText.text + "h2"
var currentPlayerCoins = parsedData["coins"]
var playerUnlocksArray = parsedData["playerUnlocks"]
if playerUnlocksArray:
pass
else:
playerUnlocksArray = [true, false]
#$DebugText.text = $DebugText.text + "h3"
#$DebugText.text = $DebugText.text + "currentCoins: " + str(currentPlayerCoins)
#$DebugText.text = $DebugText.text + "h4"
var newPlayerCoinsAmount = coinsCollected + int(currentPlayerCoins)
#$DebugText.text = $DebugText.text + "h5"
var saveData = {"coins": newPlayerCoinsAmount}
var saveData = {"coins": newPlayerCoinsAmount, "playerUnlocks": playerUnlocksArray}
var jsonSaveData = JSON.stringify(saveData)
#$DebugText.text = $DebugText.text + "h6"
SnapshotsClient.save_game("playerData", "playerData for Animal Dash", jsonSaveData.to_utf8_buffer())
Expand Down
2 changes: 1 addition & 1 deletion export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
version/code=83
version/code=96
version/name=""
package/unique_name="com.animal.dash"
package/name="Animal Dash"
Expand Down
Binary file added images/lockIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions images/lockIcon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://vhp6t48hdbkn"
path="res://.godot/imported/lockIcon.png-bb603ee74c8658340c96469ef897e4c2.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://images/lockIcon.png"
dest_files=["res://.godot/imported/lockIcon.png-bb603ee74c8658340c96469ef897e4c2.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
57 changes: 54 additions & 3 deletions main_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var currentCharacter = 0
var soundOn = true
var menuMusic
var currentData: String
var savedData = ""

@export var game_scene: PackedScene
@export var menu_scene: PackedScene
Expand All @@ -24,11 +25,16 @@ func _ready():
if !snapshot:
#$DebugLabel.text = $DebugLabel.text + " snap not found"
print("snap shot not found")
SnapshotsClient.save_game("playerData", "player data for Animal Dash", str(0).to_utf8_buffer())
var saveData = {"coins": 0, "playerUnlocks": [true,false]}
updateCoins(0)
var jsonSaveData = JSON.stringify(saveData)
SnapshotsClient.save_game("playerData", "player data for Animal Dash", jsonSaveData.to_utf8_buffer())
#$DebugLabel.text = $DebugLabel.text + "here1"
currentData = snapshot.content.get_string_from_utf8()
var parsedData = JSON.parse_string(currentData)
savedData = parsedData
var currentPlayerCoins = parsedData["coins"]
updateCharacter()
#$DebugLabel.text = $DebugLabel.text + "currentData: " + currentData
$CoinsLabel.text = currentPlayerCoins
)
Expand All @@ -46,8 +52,7 @@ func _ready():
SnapshotsClient.game_saved.connect(
func(is_saved: bool, save_data_name: String, save_data_description: String):
if is_saved:
pass
#$DebugLabel.text = $DebugLabel.text + " game saved"
updateCharacter()
else:
pass
#$DebugLabel.text = $DebugLabel.text + " unable to save game"
Expand Down Expand Up @@ -93,6 +98,8 @@ func _on_button_pressed():
$SoundToggle.visible = false
$CoinLabelSprite.visible = false
$CoinsLabel.visible = false
$LockIcon.visible = false
$UnlockButton.visible = false
#remove_child($CharacterImage)
#remove_child($StartGame)
#remove_child($LeftButton)
Expand All @@ -109,6 +116,9 @@ func _on_coins_collected(amount):
redoMainMenu()
$CoinsLabel.text = amount

func updateCoins(amount):
$CoinsLabel.text = amount

func _on_game_finished():
if soundOn:
$HitSound.play()
Expand All @@ -126,6 +136,29 @@ func redoMainMenu():

func updateCharacter():
print('updating character')
$DebugLabel.text = $DebugLabel.text + " " + str(currentCharacter)
checkCharacterUnlock(currentCharacter)

func checkCharacterUnlock(currentCharacter):
var isCharacterUnlocked = false
print(str(currentCharacter))
if savedData == "":
#$DebugLabel.text = $DebugLabel.text + "sd not loaded"
print("saved data not loaded yet")
pass
else:
print("saved character data is available")
#$DebugLabel.text = $DebugLabel.text + "sd loaded"
isCharacterUnlocked = bool(savedData["playerUnlocks"][currentCharacter])
#$DebugLabel.text = $DebugLabel.text + str(isCharacterUnlocked)
if isCharacterUnlocked == false:
$LockIcon.visible = true
$UnlockButton.visible = true
$StartGame.visible = false
else:
$LockIcon.visible = false
$UnlockButton.visible = false
$StartGame.visible = true
$CharacterImage.texture = load(characters[currentCharacter])

func _on_left_button_pressed():
Expand Down Expand Up @@ -175,3 +208,21 @@ func _on_sound_toggle_pressed() -> void:

func _on_menu_music_finished() -> void:
$MenuMusic.play()


func _on_unlock_button_pressed() -> void:
print("unlocking a new character")
$DebugLabel.text = $DebugLabel.text + "unl new char"
if int(savedData["coins"]) >= 300:
$DebugLabel.text = $DebugLabel.text + " unlocked"
var newCoins = int(savedData["coins"]) - 300
var playerUnlocks = savedData["playerUnlocks"]
playerUnlocks[currentCharacter] = true
var saveData = {"coins": newCoins, "playerUnlocks": playerUnlocks}
var jsonSaveData = JSON.stringify(saveData)
savedData = saveData
updateCoins(newCoins)
AchievementsClient.unlock_achievement("CgkIuuKhlf8BEAIQCg")
SnapshotsClient.save_game("playerData", "player data for Animal Dash", jsonSaveData.to_utf8_buffer())
else:
$DebugLabel.text = $DebugLabel.text + " ins. funds"
20 changes: 19 additions & 1 deletion main_menu.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[gd_scene load_steps=13 format=3 uid="uid://bou780e4w75un"]
[gd_scene load_steps=14 format=3 uid="uid://bou780e4w75un"]

[ext_resource type="Script" path="res://main_menu.gd" id="1_ao6ml"]
[ext_resource type="PackedScene" uid="uid://checsqe14agle" path="res://background.tscn" id="2_32us4"]
[ext_resource type="PackedScene" uid="uid://bdamtbrpkjtu1" path="res://achievements.tscn" id="3_ap3ca"]
[ext_resource type="Texture2D" uid="uid://vhp6t48hdbkn" path="res://images/lockIcon.png" id="4_soimu"]
[ext_resource type="Texture2D" uid="uid://b416mjk6ofs8d" path="res://leftArrowFinal.png" id="4_xmicy"]
[ext_resource type="Texture2D" uid="uid://6m4jdx7gbthh" path="res://rightArrowFinal.png" id="5_krq6j"]
[ext_resource type="Texture2D" uid="uid://pvkextrk6u70" path="res://images/audioOn.png" id="6_rq66x"]
Expand All @@ -25,6 +26,22 @@ offset_right = 564.0
offset_bottom = 436.0
scale = Vector2(0.65, 0.65)

[node name="LockIcon" type="TextureRect" parent="."]
offset_left = 268.0
offset_top = 142.0
offset_right = 1292.0
offset_bottom = 1166.0
scale = Vector2(0.18, 0.18)
texture = ExtResource("4_soimu")

[node name="UnlockButton" type="Button" parent="."]
visible = false
offset_left = 292.0
offset_top = 384.0
offset_right = 440.0
offset_bottom = 443.0
text = "Unlock: 300"

[node name="StartGame" type="Button" parent="."]
offset_left = 292.0
offset_top = 384.0
Expand Down Expand Up @@ -115,6 +132,7 @@ offset_top = 452.0
offset_right = 712.0
offset_bottom = 475.0

[connection signal="pressed" from="UnlockButton" to="." method="_on_unlock_button_pressed"]
[connection signal="pressed" from="StartGame" to="." method="_on_button_pressed"]
[connection signal="pressed" from="LeftButton" to="." method="_on_left_button_pressed"]
[connection signal="pressed" from="RightButton" to="." method="_on_right_button_pressed"]
Expand Down

0 comments on commit f3c9bb9

Please sign in to comment.