Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Mouseclick detection code on sprites!

Author
Message
hubby
20
Years of Service
User Offline
Joined: 29th Jun 2006
Location:
Posted: 29th Jun 2006 17:20
Hello

I am a complete beginner on DarkBasic and coding!!
I have been given the task of making Tic Tac Toe. So far i have a background image and have sprites of "0" and a "X". I have placed one of each in position in each area in the grid!
I have hid all the sprites!

I need some code that will detect a mouseclick on the sprite and if the area the sprite is in is clicked then the sprite shows!

Something like

If Mouseclick() = 1 ON SPRITE 1
show sprite 1
endif

something like that i dont know??

PLEASE HELP ASAP!!!!
flock
20
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 29th Jun 2006 19:17
Rather, I'd use images. If mousex()>50 and mousey()>50 and mousex()<100 and mousex()<100:if mouseclick() = 1:paste image 1,50,50,0:endif:endif. Now this will place a 50x50 (supposedly) image at 50x and 50y if the mouse is within the parameters. The "0" on the paste image command makes the image transparent just like a sprite (black is null). This should work.

a.k.a. "flockhound"
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 29th Jun 2006 19:37 Edited at: 29th Jun 2006 19:44
If you made a cursor from sprite 200 position it at the Mousex() Mousey() then do something like this after a mouse click...


If mouseclick() = 1 then gosub Collision


Collision:
`9 tiles on Tic Tac Toe = 9 sprites 1 to 9

for n = 1 to 9
if sprite collision(200,n)>0

show sprite n

endif
next n

Return

Login to post a reply

Server time is: 2026-07-06 18:37:45
Your offset time is: 2026-07-06 18:37:45