Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 mousewhere in a target shooting game
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheGuardian001




PostPosted: Thu Jan 13, 2011 8:06 am   Post subject: Re: mousewhere in a target shooting game

Mouse.ButtonWait and buttonwait are the same command.
The point Tony was making is that that command waits until there is input before continuing. When your program gets to that line, it waits until it sees the "down" event before continuing. You need a different command.
Sponsor
Sponsor
Sponsor
sponsor
nightfeng2




PostPosted: Thu Jan 13, 2011 8:47 am   Post subject: RE:mousewhere in a target shooting game

ive tried mousewhere but its not working properly
nightfeng2




PostPosted: Thu Jan 13, 2011 2:59 pm   Post subject: RE:mousewhere in a target shooting game

Maybe i'll delete this function in the game if it still doesn't work
Tony




PostPosted: Thu Jan 13, 2011 3:06 pm   Post subject: Re: RE:mousewhere in a target shooting game

nightfeng2 @ Thu Jan 13, 2011 8:47 am wrote:
ive tried mousewhere but its not working properly

I am fairly certain that the command is working exactly as it's expected to work Smile
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
nightfeng2




PostPosted: Thu Jan 13, 2011 3:59 pm   Post subject: RE:mousewhere in a target shooting game

ok maybe the command itself is working properly but its not wat i want it to be.
The one i want is like down-buttonwait, but then the whole program will wait until mouse is clicked, so i really dont know wat to do.
TerranceN




PostPosted: Thu Jan 13, 2011 4:30 pm   Post subject: Re: mousewhere in a target shooting game

Look at the following table,

code:

mouse button now        previous mouse button
       0                         1
       1                         1
       0                         0
       1                         0



Now try to match these descriptions to each row
-mouse is being held down
-mouse has just been released
-mouse has just been pressed
-mouse is not being pressed
nightfeng2




PostPosted: Thu Jan 13, 2011 5:10 pm   Post subject: RE:mousewhere in a target shooting game

-mouse is being held down 1 1
-mouse has just been released 0 1
-mouse has just been pressed 1 0
-mouse is not being pressed 0 0
TerranceN




PostPosted: Thu Jan 13, 2011 5:19 pm   Post subject: RE:mousewhere in a target shooting game

Ok, since you want to register a click when the mouse is just pressed, before you call Mouse.Where, store the previous mouse button value. Then just change your if statement to make sure the mouse button is down now, but was not last frame.
Sponsor
Sponsor
Sponsor
sponsor
nightfeng2




PostPosted: Thu Jan 13, 2011 10:04 pm   Post subject: RE:mousewhere in a target shooting game

Sounds so complicated, i want to try what you are saying, but what do you mean by store the previous mouse button value before calling mousewhere. Can you gimme an example of that ?
Tony




PostPosted: Thu Jan 13, 2011 10:09 pm   Post subject: Re: RE:mousewhere in a target shooting game

nightfeng2 @ Thu Jan 13, 2011 10:04 pm wrote:
store ... value

usually suggests that you might want to use some variable.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
nightfeng2




PostPosted: Thu Jan 13, 2011 10:16 pm   Post subject: RE:mousewhere in a target shooting game

The previous button value should be 0 since the mouse is not pressed, that means I store 0 into a variable. If this part is right, the next part is giving me a headache cause i really dont understand it.
Tony




PostPosted: Thu Jan 13, 2011 10:25 pm   Post subject: RE:mousewhere in a target shooting game

Not quite. You can only know what the value of the mouse is _right now_. For it to become a previous value, you would have to wait some time.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
nightfeng2




PostPosted: Thu Jan 13, 2011 10:33 pm   Post subject: RE:mousewhere in a target shooting game

ah, here comes the complicated stuff xD
nightfeng2




PostPosted: Thu Jan 13, 2011 11:13 pm   Post subject: RE:mousewhere in a target shooting game

instead of the bullet system and -1 score, ill change it to a timer instead.
Tony




PostPosted: Thu Jan 13, 2011 11:23 pm   Post subject: RE:mousewhere in a target shooting game

You could do better than that, come on:

You have a loop, it looks something like this
code:

loop
   read_the_mouse
   ...
   do_some_stuff
end loop

And it has two variables we've already discussed: mouse_now and mouse_previous. They had some values. Going forward, you know that you want mouse_now to be... what it is now. And you want mouse_previous to remember what happened in the previous loop.

How do you make this happen?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 33 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: