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 / Sparkys help for collision and gravity

Author
Message
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 7th Jun 2009 09:17
Hi everybody.

This is a game i have been working on for a very long time. All this time i tryed to add gravity and collision but nothign has worked out the way i wanted it too. IN the code the sphere or object 152 is the main player. i want it so the sphere is right above the floor (the cubes) and when there is no floor under the sphere for it to fall down. i know this can be done with sparkys but i tryed it already and it didnt work. so can someone please tell me how ot code it using sparkys so the sphere will fall and it can jump to higher cubes and everythign. i will include media.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....

Attachments

Login to view attachments
Monk
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 7th Jun 2009 15:26


try that. I commented the bits that are needed for collision, so you can understand it and learn how to use it.

kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 7th Jun 2009 16:19
OMG MONk thank you so much.Your a life saver. i just have 1 question what does the delete memlock 1 at the end do.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 7th Jun 2009 17:07 Edited at: 7th Jun 2009 17:08
You just have to include at least one memblock command in your code whenever you use Sparky's because Sparky's uses the memblock commands. DarkBASIC won't include them in your finished EXE for Sparky's to use unless you use them.

I usually find it's safer to use null=memblock exist(1) because it won't cause an error if the program somehow gets to it.



Diggsey: I have a spine and memory, but one memorable guy says he hates me. What am I?
kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 7th Jun 2009 21:49 Edited at: 7th Jun 2009 21:54
Thanks for all the replys. Right now i cant get the player to jump. Can anyone tell me how to get it to jump. This is the code im using to try and get it to jump right now.

Also can i do osmehting like
IF object height 152>200 position object bla bla

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
Monk
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 7th Jun 2009 22:23 Edited at: 7th Jun 2009 22:32
Quote: "Also can i do osmehting like
IF object height 152>200 position object bla bla"


Depends what you're trying to do as to whether you can do it.

BTW, Object height is a command that will tell you the size of the object in the y plane, what I think you mean is object position y(152).

As for the jumping code, that line wont do anything. The move object (if vy# = vy#+3.0 is allowed as a value) would only move it forwards not up. And even then, the object wont come down again.

Im struggling with the jumping code though, every so often, you just fall through the maze...

Edit:
I had to fiddle the collision a little bit, but I managed to get some jumping for you.



kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 8th Jun 2009 02:47 Edited at: 8th Jun 2009 07:40
Hey monk,
Thanks so much. I actually wanted the player to fall through the gaps in the maze so you pretty much solved another promblem of mine. THanks to everyone i really appreciated it and i hope this post helps others as well. i jsut have like 1 or 2 more questions. lets say i load the maze as a 3d object would i use set up collision and gravity the same way as this. Also the collision is not working for objects on the second floor. LIke the player goes right through object 5 whose y value is 4 and it is on the second floor. Do you know what the promblem is Monk? Also is there any way i can make the sphere fall down slower. would i set the sync rate lower or is there a way to make the player fall down slower?

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
Monk
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 8th Jun 2009 19:13
Have you got a copy of the code with the 2nd level? I reckon its falling through because either; you need to call sc_setupobject for the new objects, you need to make the objects all in the same group (see the syntax for the sc_setupobject command), or its because i put in a number like ten when I should have put in object position y + 10 or something.

Ill take a look later when Im not so busy.

kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 8th Jun 2009 20:44
Hey monk, i dont mean like 2nd level i meant 2nd floor. like all these cubes y posiitons are 0, but if i have a object with y posiiton of 4 then collision doesnt work the sphere goes right through.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
Monk
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 10th Jun 2009 00:47


I think the problem is with that section.
Try this code instead.



kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 10th Jun 2009 03:31 Edited at: 10th Jun 2009 08:06
Hey monk that code complely removes gravity and collision. any other ideas. thanks for the rreplys though. also lets say i make the maze in 3d world studio. how would i use sparkys to set up collision and gravity for that.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
Monk
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 10th Jun 2009 09:36
Change:


to:


I just put the +5 on the wrong line

kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 10th Jun 2009 18:24
Still the same. NO collision for objects that have y position of 4.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....
Monk
16
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 10th Jun 2009 18:48
Are you trying to stop yourself from walking into objects that have y position 4? If so, doing a collision check below the sphere to test for gravity will not help. Youll need to do a second collision check, but using the positions before the WASD movement, and then after it to check if you walked into an object.

To check for collision if you walked into the object, try this:


Hope thats what you were looking for.

kuljot
15
Years of Service
User Offline
Joined: 2nd Jan 2009
Location: sacramneto, ca united states
Posted: 11th Jun 2009 07:35
Hey monk,
what i want is to be able to walk on and jump on objeects with y position of 4. that code you posted puts the sphere way high up i nthe air., thanks.

Gateway GT5628 Quad Core Desktop Intel Core 2 Q6600 2.4GHz Quad Core 3072MB RAM / 500GB 7200 SATA II Hard drive DVD RW 18X multi dual NVIDIA GeForce 8500GT ....

Login to post a reply

Server time is: 2024-11-24 05:26:11
Your offset time is: 2024-11-24 05:26:11