
-----------------------------------
Foxhunter
Tue Apr 27, 2010 9:41 am

Assistance Needed - Button not working correctly for RPG style game.
-----------------------------------
What is it you are trying to achieve?
My friend and I are making a game for Gr. 10 Computer Science, and we decided to make an RPG kind of game. The objective is that you click a button to deal a random integer of damage to a monster, and when their 'Health' reaches >0 the screen is cleared or the actual monster is cleared, and you move on to the next monster unitl you hit the final boss.


What is the problem you are having?
The button on the code labeled 'Attack' doesn't work. The button itself is there, however when you click on it, nothing happens. It doesn't even register that you clicked.


Describe what you have tried to solve this problem
I've tried removing the picture, no results, and I really have no other clue what to do to solve the problem.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
CODE IS BELOW - 



import GUI
setscreen("graphics:700;725") 
var Saphiron := Pic.FileNew ("Saphiron.jpg")
var Health : int
var Damage : int
Health := 100
Damage := Rand.Int (10, 30)

procedure attack
    locate (1, 1)
    put "You have dealt ", Damage, " to Saphiron!"
    Health := Health - Damage
end attack

var Attack : int := GUI.CreateButton (20, 10, 30, "Attack", attack)

loop
Pic.Draw (Saphiron, 150, 70, picMerge)
end loop

if Health >= 0 then
    cls
end if

loop
    exit when GUI.ProcessEvent
end loop




Please specify what version of Turing you are using
4.1.1

Thank you very much for any assistance you can lend!

~Foxhunter

-----------------------------------
TheGuardian001
Tue Apr 27, 2010 10:46 am

Re: Assistance Needed - Button not working correctly for RPG style game.
-----------------------------------


loop
Pic.Draw (Saphiron, 150, 70, picMerge)
end loop



That is an infinite loop. When a Turing program executes, each line is run in the order in which they appear in the file. This means any code appearing after an infinite loop will never be run. Since you put GUI.ProcessEvent in its own loop which comes after this infinite loop, it will never be run. Either put both inside of the same loop, or don't use an infinite loop.

-----------------------------------
USEC_OFFICER
Tue Apr 27, 2010 11:37 am

RE:Assistance Needed - Button not working correctly for RPG style game.
-----------------------------------
I don't even see the need for two loops. One mega loop should work just fine.

-----------------------------------
chrisbrown
Tue Apr 27, 2010 11:39 am

RE:Assistance Needed - Button not working correctly for RPG style game.
-----------------------------------
Also check your comparisons. You want Health 