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

Username:   Password: 
 RegisterRegister   
 Mouse cache
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DiamondDev




PostPosted: Tue Mar 02, 2004 8:47 pm   Post subject: Mouse cache

Hello anyone reading this.

I'm making a hunting type game where you click with the mouse and I can't seem to figure this out. I have the shooting and everything fine, what I was wondering if there is some way you can clear the cache of the buttonmoved feature? What's happening is that when you click the mouse, you only have a certain amount of shots. After the time expires and the new round starts it keeps a cached event of how many times the mouse was clicked. So when the next round starts and you clicked more than what the bullets fired....it will keep wasting the ammo even though you didn't click.

Any help would be appriciated.

Thanks
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Tue Mar 02, 2004 8:52 pm   Post subject: (No subject)

does Input.Flush do anything for the mouse? not sure.

I don't know why you need to keep a cached event of how any times its been clicked though, just keep it as a variable. every time you click the var increases by 1.
jonos




PostPosted: Tue Mar 02, 2004 8:55 pm   Post subject: (No subject)

i don't really know what you mean. do you want to clear the cache?

this seems stupid because you probably know this but you could:

mouseCache:=0

i don't really know what you mean. if you want the shooting action to stop after the bullets are used up, just make a loop and when the bullets are used up exit.
DiamondDev




PostPosted: Tue Mar 02, 2004 9:29 pm   Post subject: (No subject)

Sorry... Embarassed
I thought i might be a bit confusing. Whats happening is after the bullets are used it, and you keep clicking it seems to keep a memory of that. When the next round starts, it just fires

I was using the buttonmove command
DiamondDev




PostPosted: Tue Mar 02, 2004 9:35 pm   Post subject: (No subject)

oh...i am also trying it using the buttonwhere command...and that sholves the "caching" problem...however it is now like semiauto duck hunt hehehe
any way i can program it so it will not fire more than once if the button is held?
jonos




PostPosted: Tue Mar 02, 2004 9:53 pm   Post subject: (No subject)

well, if you need help i made a shooting game. with a little help from cervantes this is what i did, using a delay to prevent auto style shooting:

code:

mousewhere (mousex, mousey, button)
%     if button = 1 then
%         drawline (mousex - 10, mousey, mousex + 10, mousey, red)
%         drawline (mousex, mousey - 10, mousex, mousey + 10, red)
%         if whatdotcolour (mousex + 4, mousey + 4) = 91 then
%             fleshShot := fleshShot + 1
%         elsif whatdotcolour (mousex + 4, mousey + 4) = brightred then
%             eyeShot := eyeShot + 1
%         elsif whatdotcolour (mousex + 4, mousey + 4) = red then
%             mouthShot := mouthShot + 1
%         elsif whatdotcolour (mousex + 4, mousey + 4) = blue then
%             bodyShot := bodyShot + 1
%         elsif whatdotcolour (mousex + 4, mousey + 4) = 188 then
%             bodyShot := bodyShot + 1
%         end if
%         fork gun_shoot
%         ammo := ammo - 1
%         if ammo = 0 then
%             clips := clips - 1
%             ammo := 7
%         end if
%         delay (115)
%     elsif button = 0 then
%         drawline (mousex - 10, mousey, mousex + 10, mousey, brightred)
%         drawline (mousex, mousey - 10, mousex, mousey + 10, brightred)
%     end if
%     exit when clips = -1
%     delay (10)
% end loop


just get right of the comments, and the extra stuff and it should work fine.
DiamondDev




PostPosted: Tue Mar 02, 2004 10:07 pm   Post subject: (No subject)

Thanks for the help
I didn't think of a delay lol. Im a idiot...seeing i did the same thing when i made a side scrolling game for my jump comand.

Just for reference..all I did was make a timer that counted down, so that there was a delay before it would allow a shot again Smile
Thanks for all the help guys.....no more hunting with machine guns Twisted Evil
jonos




PostPosted: Tue Mar 02, 2004 10:10 pm   Post subject: (No subject)

what!!!! it would be more fun with fricking ak-47s shotting at dear and rabbits and whatnot, but i guess old boltaction rifles are ok... Crying or Very sad

anyways, im glad i helped you, cervantes helped me with that code a bit, and i think shorthair did also. have fun
DiamondDev




PostPosted: Tue Mar 02, 2004 10:22 pm   Post subject: (No subject)

yeah...i was having fun pumping 32 rounds into one duck....... but it got old lol
maybe that will be a cheat Razz

Thanks again
Cervantes




PostPosted: Wed Mar 03, 2004 5:26 pm   Post subject: (No subject)

just make sure to have the delay inside the if statements asking whether the button is clicked or not. Jono's has two delays in there, I'm talking about the delay (115) one.

This kind of problem comes up again when you are making a menu from scratch and you are using the keys to select which option. Same thing, have a delay in the if keys (KEY_DOWN_ARROW) section.
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 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: