C
Callam
Guest
Hi, so i have a game where you can find treasure chests. each chest has its own set of rewards for example
chest1: 1-2xp, 3-5gold
chest2: 2-4xp, 5-7gold, 1-2emeralds
etc
I have a chest object that creates each of the objects (xp etc) , which then shoot off to the hud element and add to the respective counters before disappearing. That all works fine, however upon trying to add more chests and code it in, the xp etc either stops being counted after the collision or counts sporadically. ive tried many different things and cant get it to work so heres my code. hopefully someone will be able to help.
obj_game
create event:
global.chest1 = 0
global.chest2 = 0
obj_chest1
left pressed
global.chest1 = 1
obj_chest2
left pressed
global.chest2 = 1
obj_xp_drop
if global.chest1 = 1
{
global.playerxp += irandom_range(1, 2)
global.chest1 = 0
}
else
if global.chest2 = 1
{
global.playerxp += irandom_range(2, 3)
global.chest2 = 0
}
chest1: 1-2xp, 3-5gold
chest2: 2-4xp, 5-7gold, 1-2emeralds
etc
I have a chest object that creates each of the objects (xp etc) , which then shoot off to the hud element and add to the respective counters before disappearing. That all works fine, however upon trying to add more chests and code it in, the xp etc either stops being counted after the collision or counts sporadically. ive tried many different things and cant get it to work so heres my code. hopefully someone will be able to help.
obj_game
create event:
global.chest1 = 0
global.chest2 = 0
obj_chest1
left pressed
global.chest1 = 1
obj_chest2
left pressed
global.chest2 = 1
obj_xp_drop
if global.chest1 = 1
{
global.playerxp += irandom_range(1, 2)
global.chest1 = 0
}
else
if global.chest2 = 1
{
global.playerxp += irandom_range(2, 3)
global.chest2 = 0
}