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 Professional Discussion / My sprite background is Flicking... why???

Author
Message
Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 19th May 2015 18:55 Edited at: 19th May 2015 21:24
Hi all

i had made a shop, with an "Add" button in, but when i click it with the mouse my background is flicking. i had tryed with sleep and wait command. any other why to have the program wait around 150-200ms

if i not have the sleep or wait command in the "Add Button" loop the program is adding like 10 or 15 pices at the time because of the mouse is = 1 But my background is not flicking.

i just need it to one at the time, for each click on the mouse, without my background is flicking


Thx.


Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 19th May 2015 20:04
i had made a bit simpler code to look at, it still do the flicking thing when i click mouse button, if i use wait or sleep. and if not. it Count fast as hell. i need one click + 1 to label.


Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 19th May 2015 21:09
Two things... can you edit your first post to include code tags round that code please. Just to make this thread better to navigate.

Second thing, I think it's because there's no sync.

Add this to the top of your code or just after the display mode.
Sync On : Sync Rate 60

Add this at the bottom right before loop:
Sync

"Get in the Van!" - Van B
Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 19th May 2015 21:26 Edited at: 19th May 2015 21:27
i had sync on i another file, it sync rate 100, but if i put Down sync rate 6 inside the Mouse click if condision it seems to Work. thx mate. you just pushed me out of the edge
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 19th May 2015 23:54 Edited at: 19th May 2015 23:56
Quote: "but if i put Down sync rate 6 inside the Mouse click if condision it seems to Work"


Wooow! You don't want to do that, your game will be running at like 6 frames a second. What's happening is when you click down the mouse, your processing the loop many times in the time it takes to stop clicking so that bit of code will add alot. The idea is to check to see if it's being click and only excute the action once. The best way to do this is store the old mouseclick and you compare it to the current to work out if the mouse is being held down.

Example:


if mc > 0 and mc <> omc
[if MouseClick > 0 and MouseClick <> OldMouseClick]

What this does is check to see if the mouse is being pressed down (any button = mc > 0) but also check to see if the old mouse is different. If it is then it means the mouseclick has changed state and isn't being held down and it will process our code. If it is being held down then it won't process it.

"Get in the Van!" - Van B
Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 20th May 2015 22:06
Thx i will try that out, tomorrow mate,
Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 23rd May 2015 06:43 Edited at: 23rd May 2015 06:56
hmm cant get it to Work mate nothing happens when i click the mouse button. like it never entering the loop
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 23rd May 2015 09:21
Try this:

Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 23rd May 2015 17:39 Edited at: 23rd May 2015 17:40
Hey, mate it seems to Work out fine. thx a lot. for the help
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 23rd May 2015 18:50
He's an example using my code:


Just note that the Wait command used in Scorpyo's example will pause your entire game for the length it's set. So along as you have nothing else updating then use it.

"Get in the Van!" - Van B
Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 23rd May 2015 19:08 Edited at: 23rd May 2015 19:19
Hey, mate it seems to Work out fine. with the mouse counter one at the time, but my background now flicking Again. the background is a sprite i had pasted inside the do loop. but the funny thing is that all my other pasted sprites do not Flick. only the background.

have not tryed the last one, with your ex. it took some time to update my post

YEAH!! your exampel, was perfekt Sasuke. no flicking background and mouseclick is working perfeck.

thx to you both of you to take time to help. thx

Login to post a reply

Server time is: 2025-08-09 02:29:31
Your offset time is: 2025-08-09 02:29:31