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 Discussion / A new set of questions (|:|)

Author
Message
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 13th Jul 2005 06:17
~Ray Casting for a Bullet~
1. I was told by NanoBrain that to make bullet sequence, you need to do some raycasting. Now I have my shooting animation that is played well. I also have the gun sound. Can someone please explain how I can add the raycasting to do the bullet sequence? What is the coding for the raycasting?

2. How do I have the ray that is casted so when it hits a X file object from DarkMatter, it jumps to a part in the game that makes the X file play an animation file to make it die? (I know how to do every thing after the comma)

~Keyboard Input~
1. I have the character move when you press the upkey, downkey, right key, and left key. How do I change those keys to the letters W, S, D,
and A? (In the order they where typed)

~Other~
1. Can someone make a gunshot blast effect? How do I position it in front of the gun?

Thanks everyone, Please reply!

Enjoy Life while your still alive.
Enjoy a recees anytime!
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 13th Jul 2005 06:49
GreenFox,

It is not that you need to do raycasting to create a bullet sequence. But, that raycasting needs to be coded within the bullet sequence.

Raycasting is quite simple, so don't overthink it. It is a method used to check at every point between two points. In 2d, on the x axis(left to right), let us say that point a = 0 and point b = 10. Let us also say that point a represents a bullet before it was shot, and point b represents how far it will travel in one program loop(specifically where it will end up after one program loop). How can we check every point between point a and point b for an reason, mainly collision?

First of all, we need to define how large a point will be. This can be any real or integer number. For this lesson, we will define a point to be 1 screen pixel in size. Therefore, there are 10 points all together. So, we need to check 10 points.

Remember, that the bullet is traveling at 10 pixels per game loop, and so we will need to check between 10 points each game loop for any collision. So, let us start at point 0. Make sure that you cast a ray before the bullet's location is updated. Use a for next loop(a for next loop will be completed before any game loop continues), which increments by one pixel each loop, starting at the bullet's last location. In this scenario, the bullet's last location is at point a, or 0, and it's new location will be at point b, or 10. So, we need to count from 0 to 10 in the for next loop.



After the for next loop, the bullet's location will be set to 10. Then, on the next loop, the for next loop will need to check from the new point a, which is the old point b, to the new point b, which is ten more pixels away, and so on.

This may be a bit confusing, due to me being rushed for time at the moment. Remember, this lesson is basing the ray on only 1 dimension, left to right. It is a bit different to do this on more than one dimension. I will explain later.


+NanoBrain+
Metrion
19
Years of Service
User Offline
Joined: 8th Jul 2005
Location: In the darkest cave
Posted: 13th Jul 2005 07:31
You could also use Sparky's DLL for collision
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 13th Jul 2005 08:57
~Keyboard Input~



Your signature has been erased by a mod because it's larger than 600x120...
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 13th Jul 2005 09:52
Thanks Everyone!

Nano brain, I get the For Next loop... But I have no clue how to do object collision with a ray and a X file loaded object.

Enjoy Life while your still alive.
Enjoy a recees anytime!
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 13th Jul 2005 18:38
GreenFox,

Each point within the for next loop needs to be used within object collision detection. Check to see if that point is within an object. Unfortunately, collision detection is not my strong point.


+NanoBrain+
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 14th Jul 2005 00:14
That's ok NanoBrain, I'll try my best on it. Thanks alot!

Enjoy Life while your still alive.
Enjoy a recees anytime!

Login to post a reply

Server time is: 2025-05-22 21:48:50
Your offset time is: 2025-05-22 21:48:50