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 this code

Author
Message
younis12
16
Years of Service
User Offline
Joined: 23rd Feb 2010
Location:
Posted: 9th Feb 2011 19:24
hi guys

i have made a very simple gravity which will help me in my game
but the thing i cant understand it is why when the object collision to floor = 1 and i move the object
it moves -5,+5 up and down
you can see this clearly in the (print object position y) command

check this code
it's whithout any loading object or images


SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 10th Feb 2011 02:29
Try making it stop at 1.1
CodemanV
20
Years of Service
User Offline
Joined: 25th Aug 2005
Location: South Wales Valleys, UK
Posted: 10th Feb 2011 03:11 Edited at: 10th Feb 2011 03:12
Hello

Your code doesn't compile due to the numerous functions prefixed "sc_" so I am unable to run your code ..... if you are using a plug-in such as "Sparky's Collision", you should let us know so we can run your code!

Anyway, here's an observation on your +/-5 problem

gs = 5
if object collision (2,5)=0 then move object down 2, gs
if object collision (2,5)=1 then gs = 0


The variable "gs" is set to be conditionally reset to zero based on an object collision between objects 2 and 5. Maybe that particular collision isn't being triggered and thus "gs" stays at 5.

Also, your code may not be wrong as such but it is a bit messy



could be

younis12
16
Years of Service
User Offline
Joined: 23rd Feb 2010
Location:
Posted: 10th Feb 2011 08:25
yes iam using sparky collision
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 12th Feb 2011 10:59
Hi, had a go at trying to fix your problem but couldn't get sparky's slide collision going.

I've edited your camera handling so you can see the sphere and still move it normally, its just easier to see the problem.



A clever person solves a problem, a wise person avoids it - Albert Einstein
Balid
22
Years of Service
User Offline
Joined: 21st Nov 2003
Location: MI, USA
Posted: 12th Feb 2011 18:35
younis12,

One thing missed was 'Sc_Allowobjectscaling' for object 5. You then would need to move the 'scale object' command after this, followed by 'Sc_UpdateObject'.

I have made several adjustments to the program that helpfully illustrates the gravity effect you are looking for. The adjustments are documented. I just have the floor loaded into Sparky collision. I would suggest loading all of your objects into it rather than mixing between DBPro native and Sparky Collision.




Regards,

Login to post a reply

Server time is: 2026-07-16 04:35:47
Your offset time is: 2026-07-16 04:35:47