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 / Just A quick question with endif sections

Author
Message
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 9th Dec 2013 01:13
Hi I'm trying to make something only happen if the case is correct and have got requirements which are quiet vague slowly narrowing it from a large field to a low field of possibles to make less checks happen each loop and in turn make the game run quicker. The issue is that only one have gone slightly wrong and I would love somebody to fix it as I can't see why it isn't working. I've used this method quite a lot in the past and never had a issue. Any help would be much appreciated!


Thanks in advance!

Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 9th Dec 2013 01:35
To look at all this code for one issue without being able to test it and not having a clue where this one issue is and what most of the variables are or do is asking far too much!

Before continuing any further you first need to look at this and think... surely this could be optimized? If you've got a lot of repeat code then it definitely can be optimized. All this code can be shrunk down a ton via functions and arrays.

So let's dissect this...

So... explain what's going on here and what the variable C1R1 is and relates to?
Quote: "If C1R1=0 and timer()-GameTimer >400 then C1R1=1 : GameTimer=timer()"


Also you do a lot of repeat checks, for instance, if the mouse is at a certain position over I'm guessing a button then it can't be over any other button so it's not necessary to check that. So you need a way of checking until over a button becomes valid and not check again.

"Get in the Van!" - Van B
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 10th Dec 2013 17:57
hi, I have since fixed the issue I had, I don't really see how im doing too many check either? I would love to learn how though.

Thanks and sorry for such a slow reply
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Dec 2013 21:45
Quote: " I don't really see how im doing too many check either?"


If a number lies between 0 and 1 why then, in the next line, check to see whether it lies between 1.1 and 2? It's not the number of checks written in your code, it's the number actually being executed that's the issue I suspect.

However, the way you've written it is easy to follow and easier to code, if somewhat laborious. For instance, a simple for/next loop would be shorter using the different values stored in an array - but then you lose some instant readability.

But far better than any of those would be a "pick object" solution using simple plains for your buttons.



Powered by Free Banners
Flamertor
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location:
Posted: 12th Dec 2013 13:49
Ah okay but I need to have the 1.1 checks and things like that as it's dividing the screen and it isn't accurate enough if I round it too much.

Another thing is doesn't the pick object method not work at different resolutions? If that isn't the case how does it work and also does it lower the performance slightly or am I completely wrong?

Thanks
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 12th Dec 2013 14:52
Quote: "Ah okay but I need to have the 1.1 checks and things like that as it's dividing the screen and it isn't accurate enough if I round it too much."


It's all about optimization and efficiency and believe me, you can cut this down immensely and get rid of all the divisions going on every frame! I would write an example or port of that code to show you but I don't know how it's structured or what relates to what!

"Get in the Van!" - Van B

Login to post a reply

Server time is: 2025-05-17 14:21:07
Your offset time is: 2025-05-17 14:21:07