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 / Help with collisions..

Author
Message
Jamie_Leigh
14
Years of Service
User Offline
Joined: 15th Dec 2011
Location:
Posted: 1st Mar 2012 21:52
Hi I have written this code to try to simulate my cube killing the sphere.

I've set it so if I press space bar and the sphere and cube are touching it should decrease the spheres health by 1.

When I attack it crashes telling me object 3 does not exist when it is right there(the sphere) :S

Anyway here is my code..


Thanks for any help
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 1st Mar 2012 21:56
1) dont use dark basics collision, use Sparks Collision at:
http://forum.thegamecreators.com/?m=forum_view&t=74762&b=5 it will give ya an easy method of setting up the collision, and it works much faster than the original dbp collision commands.
2) dont use luffy avatar, its mine xD

more 3d models .x/.obj and more foramts here:
[href]https://www.turbosquid.com/Search/Index.cfm?keyword=gogetax1&x=0&y=0[href]
DarkDISCUSSION
15
Years of Service
User Offline
Joined: 6th Jul 2011
Location: Ft Madison, IA
Posted: 1st Mar 2012 22:19
personaly i like the nuclearglory dll collisions stuff

Monsters are Ready to spill their Dark Sercrets......
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 1st Mar 2012 22:33
nuclear is awesome too. its even easier to use

more 3d models .x/.obj and more foramts here:
[href]https://www.turbosquid.com/Search/Index.cfm?keyword=gogetax1&x=0&y=0[href]
Jamie_Leigh
14
Years of Service
User Offline
Joined: 15th Dec 2011
Location:
Posted: 1st Mar 2012 22:36
I just had a look at sparks collision seem confusing :S

Can you not see what the problem might be with my code?
WickedX
17
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 1st Mar 2012 23:10
Check if the object exist before checking for a collision.

Jamie_Leigh
14
Years of Service
User Offline
Joined: 15th Dec 2011
Location:
Posted: 1st Mar 2012 23:16 Edited at: 1st Mar 2012 23:26
cool thanks!

Another question though, it seems to register the keypress hundreds of times everytime i click it.

Is there a way to limit the ammount of times it registers?

Thanks

*****EDIT*****
Sorry I made a mistake I have it working now thanks!
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 1st Mar 2012 23:57
you can make event of:
On Key Press
On Key hold
On Key Release

by puting the next commands in loop:
if thiskey = 3 then thiskey = 0
if spacekey()=0 and thiskey = 2 then thiskey = 3
if thiskey = 1 then thiskey = 2
if spacekey()=1 and thiskey = 0 then thiskey = 1

and the result is:
thiskey = 1 - on Key press
thiskey = 2 - on key hold
thiskey = 3 - on key release

so:
if thiskey =1
//i pressed the key
endif

and so on.

more 3d models .x/.obj and more foramts here:
[href]https://www.turbosquid.com/Search/Index.cfm?keyword=gogetax1&x=0&y=0[href]
Ramon156
14
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 11th Mar 2012 01:39 Edited at: 11th Mar 2012 16:52
Edit - I'm sorry this wasn't supposed to be posted, I have misread your question. Here's the correct post.

To avoid pressing a key and then getting it registered 100s of times a second, I have found a really helpfull function somewhere here on the forums.

Here it is :



It works great.
You type KEYS(Keystate,1) to only get it registered once. I can't remember what KEYS(Keystate,0) does exactly.
I'm looking to add this into my mouse also.
As soon as I will solve this I will post it here.

Login to post a reply

Server time is: 2026-07-10 15:30:20
Your offset time is: 2026-07-10 15:30:20