TNT Basic Forums > Programming Q&A
Mouse Up
< Last Thread     Next Thread >
Thread        Post A Reply

12-03-2002 00:58

Posted by:
Brian Jones

Click Here to Email Brian Jones   Find more posts by Brian Jones

In my game, blocks are placed by clicking the mouse while a ball is rolling around. Right now, by getting clicks by testing 'mouse button' each time through the game loop, you can simply click and drag across the whole board and place blocks without any real discretion. Not exactly the game experience I'm going for.

Anyways, I've noticed 'wait mouse up' (or whatever it's called), but I don't want the program to stop executing because I want the ball to keep rolling around.

Is there any way to respond to a mouse up event without pausing execution between the mouse down and up?

12-09-2002 21:16

Posted by:
Mark Tully

Find more posts by Mark Tully

Mouse events

Hi Brian,

You can get the mouse event without pausing the game, but you have to do it yourself. To do this, each frame you must store whether or not the mouse button is pressed. Then next frame, you see if the button is pressed on the frame, but wasn't pressed on the previous frame. If it is, it's a new click!


int waspressed=0,pressednow
pressednow=mouse button
if pressednow and not waspressed
else if waspressed and not pressednow
end if

draw frame

' new mouse click this frame
procedure HandleNewClick()
' handle mouse click, get mouse x and y with 'mouse x' and 'mouse y' functions
' you could store the x and y of the click location so you can use it later - for example in the click release procedure?
end proc

' mouse was being held, just been released
procedure HandleClickRelease()
' do stuff now the mouse is released
end proc

Hope this helps!


All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.