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 / Ramps or Jumping?? Help Needed!! =S

Author
Message
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 29th Jul 2010 15:45
Quote: "And I have the problem where if you go to far left (or right i think) on a cube off an edge you will partially go through it (though you sort of fixed that but still looks wierd)"

I spoke about that several posts ago. When you do a INTERSECT OBJECT() check, you are looking at what the "ray" in intersecting. Look at the RED arrow. It will not detect the purple box because the ray is not going to come into contact with it. What you CAN do is make 4 INTERSECT OBJECT() checks in the DOWN direction near each edge of the box (refer to the bottom half of the image. It's a top-down view of your BOX 1). Notice the black circles? That's where the 4 down intersects need to be. You don't have to have them right on the edge, but you may want them to be about 1/4 of the way there. You can use the collision info to "tip" the box over if it gets too far to the edge of another. I want to be sure you understand me. Each of the 4 dots represent the DOWN direction. It doesn't matter what orientation the box is in. When only ONE of the DOWN direction collisions occur, the box will go into a "tip-over" sequence-- the player has no or little control at that time. The box rotates slowly until it reaches a maximum rotation that you decide and THEN actually falls to the next floor. You could bypass the "tipping" and put the collisions on the edge of the box so that as long as there is the tinyest amount of the box colliding, it will stay up.... Whatever you want your game to do, you will need the 4 DOWN direction INTERSECT OBJECT() checks.

The fastest code is the code never written.
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 29th Jul 2010 18:28 Edited at: 29th Jul 2010 18:30


how do I position the down direction intersect objects then?
and yeah I want so the tiniest bit is on the box will stay on.
(I think i solved the first one)

My code so far:


I want coke, not Pepsi!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 29th Jul 2010 18:40
You gave me crap. Here is the code I was talking about:


The fastest code is the code never written.
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 29th Jul 2010 19:17
Thank you so much, it works, but can you explain what you changed?



I want coke, not Pepsi!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 29th Jul 2010 20:43
Here is the relavent chage:

Notice the 4 different D#=INTERSECT OBJECT() statements? Each one represents one of the 4 points I showed you on the picture.

The fastest code is the code never written.
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 29th Jul 2010 21:23
so the first 3 x y and z (object position x,y,z) is the posiiton of the points and the other ones are the depths of the points?

I want coke, not Pepsi!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 29th Jul 2010 21:53
Not exactly... You can look at it that way, but think of it more like a line segment. There are two points for a line segment each with it's own xyz coordinate. The INTERSECT OBJECT() checks the object listed in the first parameter to see if the line segment intersects it at any point.

The fastest code is the code never written.
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 29th Jul 2010 22:35
oh ok, can this also be used for 2d collision? just with X and Y no Z?

I want coke, not Pepsi!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 30th Jul 2010 00:25
Sure. You CAN use it for 2D, but if you are doing 2D with boxes, you should simply use an x/y exclusion:
the player box is at x,y and is 10x10
each block is also 10x10 at coordinate x,y
if abs(playerX-box(?).x)<20 and abs(playerY-box(?).y)<20 then the player is inside that box....


Understand?

The fastest code is the code never written.
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 30th Jul 2010 00:26
not really, but what if I had a player sprite then what would I do?

I want coke, not Pepsi!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 30th Jul 2010 00:32
Sprites would be done with the same logic except you would use sprite collisions. If you are unfamiliar with sprite collisions, look in the help
Commands->Sprite Commands

SPRITE HIT : Return Integer=SPRITE HIT(Sprite Number, Target Sprite Number)
SPRITE COLLISION : Return Integer=SPRITE COLLISION(Sprite Number, Target Sprite Number)

Those would be what you want to use for collision detection..... Read up on sprites before you start playing with them.
You need to know how to create, hide/show, and the collision detection part. You may also want to do some rotation with it.... Check it out, it's a good place to start for a beginner to graphics.

The fastest code is the code never written.
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 30th Jul 2010 01:03 Edited at: 30th Jul 2010 01:03
would this work?


I want coke, not Pepsi!
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 30th Jul 2010 03:07
Yes. If you have a valid "Sprite Number" and a valid "Target Sprite Number".

You first need to make the sprite:
Load an image (or make one). or multiple images for different sprite images
declare all the sprites with
SPRITE Sprite Number, XPos, YPos, Image Number

if you have one sprite that moves (the player), then do a loop like I showed you before with the boxes and find the collisions like:
record your player position
do a for-next loop and:
if SPRITE HIT(Sprite Number, Target Sprite Number)
position the player sprite back at it's recorded coordinates
endif
next

The fastest code is the code never written.
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 30th Jul 2010 05:35 Edited at: 30th Jul 2010 08:57
ok thanks, you've been VERY helpful.
edit: never mind i'll start a thread in dbpro newbies

I want coke, not Pepsi!
Pandora beads
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: Pandora beads
Posted: 30th Jul 2010 11:29
Is there any erro code? you can post it at here.

I love game and create game and Pandora beads
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 30th Jul 2010 19:51
Quote: "Is there any erro code? you can post it at here."

what? if you mean if there is any error there wasnt my question was off topic.

I want coke, not Pepsi!
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 31st Jul 2010 08:02
can you please look at this topic hawkblood?


I want coke, not Pepsi!

Login to post a reply

Server time is: 2026-07-25 08:29:51
Your offset time is: 2026-07-25 08:29:51