1
General discussions / How to know what button being pressed with a procedural style
« on: November 23, 2021, 04:37:26 am »
I'm coding a minesweeper game, and in the game, there are 2 types of buttons: the cells of the board and the utility buttons like restart and save game.
I coded the game in a procedural programming style, I wanna know how do I check which kind of button is pressed and thereby trigger different actions for those buttons elegantly. Because since we only have the mouse X and Y coordinates from the mouse event, the way I tended to do it is to check whether a button has the mouse cursor in it or not when the mouse is being pressed. But this way of doing it is very clumsy and it starts being tedious when I have to do it for each of the scenes in the game.
I know you can use OOP and check every type of "clickable" object every scene but I coded mine in console in a procedural style and I don't wanna waste time changing it into OOP style.
I coded the game in a procedural programming style, I wanna know how do I check which kind of button is pressed and thereby trigger different actions for those buttons elegantly. Because since we only have the mouse X and Y coordinates from the mouse event, the way I tended to do it is to check whether a button has the mouse cursor in it or not when the mouse is being pressed. But this way of doing it is very clumsy and it starts being tedious when I have to do it for each of the scenes in the game.
I know you can use OOP and check every type of "clickable" object every scene but I coded mine in console in a procedural style and I don't wanna waste time changing it into OOP style.