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.

Newcomers DBPro Corner / variable toggle

Author
Message
fllwthewolves
13
Years of Service
User Offline
Joined: 4th Sep 2011
Location:
Posted: 5th Mar 2012 23:12
how can i make it to where a variable will toggle between 1 and 0 everytime a button is pressed i tried this:




and it goes through the code too fast to use.
Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 6th Mar 2012 00:31
here:


Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 6th Mar 2012 09:17 Edited at: 6th Mar 2012 09:18
Would the above example from Brendy Boy also be a sollution for a weapon firing system?
I made a weapon fire system with a timer so it doesn't shoot each frame. I'm pretty new at DBPro but here's what I made in my code.



There's a tutorial on the main page somewhere but this adds bulletlife to a projectile wich is a flying sphere.
I've read objects aren't to be used as bullets, as they can skip other objects wich won't be good. Ray tracing would be better wich I want to implement into my code when I know how to!
The game will be containing more than 1 weapon, so I'd have 1 timer for each weapon.
IMO there should be an easier way to make this.
Regards,
Millenium7
19
Years of Service
User Offline
Joined: 13th Dec 2004
Location:
Posted: 6th Mar 2012 10:58
doing anything 'per loop' is not a very effective way to code, frame rate drops will result in everything running slower
Instead, think of everything happening according to time elapsed, irrelevant of your frame/loop rate



You can also implement locking/unlocking of states. Something like



This will lock/unlock the weapon according to the left mouse button status. However it also abides by the '4 shots per second' rule, so even if you mash the button you can't make it shoot faster than that

Login to post a reply

Server time is: 2024-11-22 04:39:59
Your offset time is: 2024-11-22 04:39:59