My First Game Jam --> Part 4


        Today I started by creating a sprite for when something is locked or unavailable. I made it using inkscape, I almost went with gimp as I am more familiar with gimp than inkscape but Id like to learn it. I think it went well I only spent maybe half an hour tinkering in the program and I made it, 


The sprite I made earlier

Shows my new sprite in action


       After making that sprite and setting it to on_ready for each icon I took a break. When I came back I decided to tackle the issue I have been putting off, the code. for the past few days of this project I have kept all the logic in one script. It was beginning to get very cluttered and hard to work on so I chose to rewire my project. I now have all the popup menus re scripted in a more manageable way and started to re-work the logic. I dont really mind having to code it again as I do need some proper practice  (I made a backup of the file before I nuked the original code)


My project test run with new code (works so far)

       Im really happy with where this project is so far as it shows how much I have learned this past year. 


My original "main.gd" script is here below......  (It does run I just know that it is "bad practice" and getting hard to work on now lol)

extends Control
onready var Money_label = $Money
var total_clicks = 0
var cost = 10
var money_total = 0
#iron ore variables###########################
var ore = 0
var ore_A_sec #ore generated a second
var ore_A_click = .5 # Ore generated a click
var ore_multi = 1
var ore_value = 1
onready var ore_popup = $iron_ore/ore_Popup
onready var ore_label = $iron_ore/ore_label
onready var ore_value_label = $iron_ore/ore_Popup/VScrollBar/Value_num
#iron bar variables##########################
var bar = 0
var bar_A_sec = 0 #bar generates from ore
var bar_A_click = 0
var bar_multi = 1
var bar_value = 20
onready var bar_popup = $iron_bar/Popup
onready var bar_label = $iron_bar/bar_label
onready var bar_value_label = $iron_bar/Popup/ColorRect/value_num
#lock variables#############################
var lock = 0  # lock generates from bar
var lock_A_click = 0
var lock_A_sec = 0
var lock_value = 1000
onready var lock_pop_up = $lock/Popup
onready var lock_label = $lock/lock_label
onready var lock_value_label = $lock/Popup/ColorRect/value_num
func _physics_process(delta):
    ore_A_sec = 1 * delta * ore_multi
    ore += ore_A_sec
    print(money_total)
    update_ui()
    
    
func _input(event):
    if event is InputEventMouseButton:
        total_clicks += .5
        ore += ore_A_click
        bar += bar_A_click
        #cant get entire click to be 1 so on up and down click +.5
func update_ui():
    bar_label.text = str(int(bar))
    bar_value_label.text = str(int(bar_value))
    
    ore_label.text = str(int(ore))
    ore_value_label.text = str(ore_value)
    Money_label.text = str(money_total)
    
func _on_iron_ore_pressed():
    if ore_popup.visible == false:
        ore_popup.visible = true
    else:
        ore_popup.visible = false
    pass # Replace with function body.
func _on_upgrade_Ores_pressed():
    ore_multi *= 2
    pass # Replace with function body.
func _on_Upgrade_ore_click_pressed():
    ore_A_click *= 2
    pass # Replace with function body.
func _on_Sell_pressed():
    money_total += int(ore_value*ore)
    money_total += int(bar_value*bar)
    ore = 0
    bar = 0
    pass # Replace with function body.
func _on_iron_bar_pressed():
    bar_popup.rect_position.y = 130
    if bar_popup.visible == false:
        bar_popup.visible = true
    else:
        bar_popup.visible = false
func _on_Upgrade_bar_click_pressed():
    var clicks = 0
    var upgrade_cost_barAclick = 100000
    if ore >= upgrade_cost_barAclick:
        ore -= upgrade_cost_barAclick
        bar_A_click += 1
        clicks += 1
    pass # Replace with function body.
func _on_Upgrade_bar_sec_pressed():
    var upgrade_barsec_cost_label = $iron_bar/Popup/ColorRect/Upgrade_bar_sec/Label
    var words = "Craft Iron x1 \n Cost"
    var upgrade_cost = 20
    upgrade_barsec_cost_label.text += words + str(upgrade_cost)
    pass # Replace with function body.
func _on_lock_pressed():
    lock_pop_up.rect_position.y = 260
    if lock_pop_up.visible == false:
        lock_pop_up.visible = true
    else:
        lock_pop_up.visible = false

Leave a comment

Log in with itch.io to leave a comment.