TransWikia.com

How do I detect image clicks in Dark GDK?

Game Development Asked by BobMan on February 2, 2021

I am trying to determine if an image has been clicked, using the Dark GDK game engine. I’ve found no methods in the engine that do this.

I would rather not brute force this with a large nested if/else structure. I was thinking of setting up a container that takes an object which records the mouse position when clicked, as well as a bool value to determine if the image has already been clicked.

I apologize for not adding any example code here; I don’t know how I would go about setting something like that up.

One Answer

The way I would do it is detect the mousex and mousey position when it is clicked and then use something like the following:

if (xmouse > something AND xmouse < something_else) 
  AND (ymouse > whatever AND ymouse < whatever_else) 
THEN 
  pic_clicked = True

something, something_else, whatever and whatever_else would be the x and y top, bottom, left and right co-ordinates of the image.

This is just pseudo code and not GDK specific.

Answered by Mike Atkinson on February 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP