Map navigation with imagebuttons (I need a suggestion)
Posted: Thu Jun 07, 2018 8:53 am
Hello! Firstly, sorry for the question not being so forthright, but if someone with programming experience can help me, I'll appreciate it.
Well, in my game the player can walk around the house from imagebuttons, simplified example below:
So basically the player clicks on the door, or other elements, and is directed to another label similar to this one. Each label represents a room in the house. The original code is more complex, but that's the general idea.
My problem: although this works perfectly for walking around the house, things start to get complex when I start adding events. For example, let's say at one point, the door is locked, or the door leads to an event X now, but after another condition, to an event Y. This will force me to make this code increasingly complex, eg:
Summary: The code to walk the map incorporates several "if" and getting stupidly large (considering there are several rooms and several things to interact in each room). As I have no experience as a programmer, I suspect that I am doing something wrong. Could anyone make any suggestions as to how I can keep it as clean as possible while still being able to check to see if the player has events or something?
Well, in my game the player can walk around the house from imagebuttons, simplified example below:
Code: Select all
label map_house_exterior:
scene house_exterior
call screen map_house_exterior_buttons
screen map_house_exterior_buttons:
# front door
imagebutton:
xpos 660
ypos 650
style "alpha_buttons"
idle "map/house_exterior_zdoor_idle.png"
hover "map/house_exterior_zdoor_hover.png"
action Jump("map_house_dining")
tooltip "{size=24}Enter your home.{/size}"
$ tooltip = GetTooltip()
if GetTooltip() is not None:
text GetTooltip() at pos_tooltipsMy problem: although this works perfectly for walking around the house, things start to get complex when I start adding events. For example, let's say at one point, the door is locked, or the door leads to an event X now, but after another condition, to an event Y. This will force me to make this code increasingly complex, eg:
Code: Select all
label map_house_exterior:
scene house_exterior
call screen map_house_exterior_buttons
screen map_house_exterior_buttons:
if not X:
# front door
imagebutton:
xpos 660
ypos 650
style "alpha_buttons"
idle "map/house_exterior_zdoor_idle.png"
hover "map/house_exterior_zdoor_hover.png"
action Jump("map_house_dining")
tooltip "{size=24}Enter your home.{/size}"
if X and not Y:
# front door is locked
imagebutton:
xpos 660
ypos 650
style "alpha_buttons"
idle "map/house_exterior_zdoor_idle.png"
hover "map/house_exterior_zdoor_hover.png"
action Jump("map_house_dining_event_locked")
tooltip "{size=24}Enter your home.{/size}"
if Y and not Z:
# front door send to event 1
imagebutton:
xpos 660
ypos 650
style "alpha_buttons"
idle "map/house_exterior_zdoor_idle.png"
hover "map/house_exterior_zdoor_hover.png"
action Jump("map_house_dining_event1")
tooltip "{size=24}Enter your home.{/size}"
$ tooltip = GetTooltip()
if GetTooltip() is not None:
text GetTooltip() at pos_tooltips