forms - C# - I need to figure out how to make GUI that listens for buttons being pressed in a IF statement -
so currently, writing little text adventure game in c# , using visual studio express 2013. in forms method, have button "buttoncontinue" method called when press button; pretty simple. have button "buttona", "buttonb", "buttonc" controls game.
now. how game working press buttoncontinue progress through game , when press go on button, have random chance of coming across event such coming across monster, finding npc, or coming across "event" (event not of import @ moment). of now, buttona , buttonb beingness used eat apple might pick during game or drink water might carrying.
here problem: want create buttona , buttonb function differently when in battle or event. want buttona button fighting monster, buttonb seek hide monster, buttonc create effort run. of solution i'v come create while loop checks if buttona, b, or c has been pressed when encountered monster -but- gui not pause or hear buttona, b, or c beingness pressed if statement.
here little part of code game:
attributes.monsterdead = false; while (attributes.monsterdead == false) { if (buttonaclicked == true) { goblin.goblinattack(); buttonaclicked = false; } if (buttonbclicked == true) { } if (buttoncclicked == true) { } } now while statement called, since there nil waits , listens these if statements true, goes on infinite loop no time limit causing programme freeze.
i not skilled in c# yet still learning , taking class it. furthermore, first post in website. please help me prepare problem, can give more info if needed! give thanks you!
edit: decided include source-code can problem fixed faster. form1.cs - pastebin(dot)com/idjar20v goblin.cs - pastebin(dot)com/ti1l4xzn attrivutes.cs - pastebin(dot)com/gfjaj1u5
i'm still inexperienced c# programming , it's functions possible run both buttoncontinue , buttona method @ same time? create buttoncontinue disabled when encountered monster , have buttona, b, c have functions while buttoncontinue still running? :/
if initiate method while different method running, wouldn't 1 of method stop working , pop out data/progress in? i'm not sure.
create 3 different buttons x, y, z. set wanted functionality battle in 3 buttons in onclick functionality.
when in event a, b, c visible. in case x, y, z not visible.
when in battle x, y, z visibile. in case a, b, c not.
c# forms button user-interface
No comments:
Post a Comment