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 / Need some help with collision..

Author
Message
Lucifer
19
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 23rd Dec 2006 21:06 Edited at: 24th Dec 2006 15:43
when i started coding i thought i could do this without asking questions, but i dont know what is wrong, i have tried for over an hour to try and figure this out, this is my last resort to ask here..

I am making a ping pong thingy game. and i am having some issues with collision..

Here is my code so far :


i just started today so keep in mind i have not nearly finished the ball movement and that stuff ... i did not use any tutorials or stuff to make this code so it is noobish..

Well the problem i am having is that the ball only collides on one of the players.

Does anyone know why the ball only collides on one of the boxes, not both of them?

.zip file with all the stuff attached..


i like furry jesus and sódóma just more than anything else..

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th Dec 2006 02:55
Hi L,

Looks like you're planning on using the collision DLL, but for now, your code seems to be using the built in DBC collision. With that in mind, there were a couple of changes that makes the collision work. Why only one paddle worked before and not the other is still a bit of a mystery - but to get them both to work the same way is a minor adjustment or two.

To make sure both paddles were set to box collision I added two lines after the ball is made (I also colored the ball black):



Next, in the _control_ball routine, I changed the angle of the bounce so it would always go in the opposite direction (using wrapvalue to keep the angle within 360 degrees) and i had to change the order of the objects in the object hit(6,5) to object hit(5,6) - I'm not sure why that number reversal is necessary, but it works.



Enjoy your day.
Lucifer
19
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 24th Dec 2006 03:24 Edited at: 24th Dec 2006 03:35
i was planning to use the collision dll but i figured that i am only using dbc primitives and thought that collision wouldnt be much problem...

thanks latch i did set collision to the paddles in the beginning, but that only created similar problems for me. but now when i set the boxes to box collision the ball does bounce of both paddles, but if you test the code it makes the paddle go through the top red box ... this surely is a mystery .

i like you latch you're always very helpfull


i like furry jesus and sódóma just more than anything else..
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 24th Dec 2006 04:12
Take a look at this Massive Collision Resource stickied at the top of the newcommer's board. It might help you.

Lucifer
19
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 24th Dec 2006 04:44
isnt that only dbpro stuff?


i like furry jesus and sódóma just more than anything else..
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Dec 2006 14:49 Edited at: 24th Dec 2006 15:03
Quote: "i did not use any tutorials or stuff to make this code so it is noobish.."


To be perfectly honest with you, I'm sure you don't mean it, but that reads like "I know that tutorials exist which tell me the answer to this problem but I can't be bothered reading them".

This doesn't matter all that much, but I'm sure that a lot of people on here who know what the problem is will just not bother helping you because you've not tried to help yourself before posting.

http://forum.thegamecreators.com/?m=forum_view&t=96010&b=7

Scroll down to the Dark Basic Collision Made Simple post and click on the link.

Or, as Ruccus has already pointed out, there's an excellent collection of collision information in the Massive Collision Resource post.

If after reading them you are still stuck, post back here saying "I've read tutorial X and Y but I don't understand something" and I'm sure everyone will be glad to help.

TDK_Man

Lucifer
19
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 24th Dec 2006 15:34
Quote: "I can't be bothered reading them"


that is far from what i mean. belive me, i can be bothered reading them, i have all the time in the world to do so. i can understand why you would think otherwise but what i was really saying that i wanted to make a game, just once, without having to have to make it after a tutorial.. And the noobish part. i wrote that so people might not point out the things wrong in it because i will fix them later.. And i stumbled uppon this weird thing, i didnt know what to do.. i did look at a pong tutorial (yes, i did search), i couldnt understand much of it, so i posted here asking if someone knew what was wrong.. and dude, i wasnt thinking "oh ill ask a question and stop trying untill someone does all the work for me", no i have been trying and trying to get this to work..


i like furry jesus and sódóma just more than anything else..
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 24th Dec 2006 16:40 Edited at: 24th Dec 2006 16:43
At the "isnt that only for DBPro" comment, nope, sparkys dll works with DBC, but even if you dont want to use sparky's dll, theres other snippets there that use DBC native commands. Theres a link to TDK's tutorial on collision as well, and IIRC TDK tries to always make his work DBC compatabke .

About the tutorials problem. Id recommend to rethink your logic there, we all read tutorials, if you want to get better, theres only 2 things you can do, read tutorials, or experiment. It appears you're trying to experiment, which is fine, but the problem is you're experimenting without any knowledge of what you're experimenting with, which will make you way more confused in the end.

If anything, NOT reading the tutorials would make you sound like more of a "noob". If you dont understand a tutorial, its probably a bit too advanced for you, so try a simpler one. If you dont understand any tutorials... you might have a problem.

Lucifer
19
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 24th Dec 2006 17:33 Edited at: 24th Dec 2006 17:41
EDIT 12/24/2006 4:40 PM:

I managed to figure this out, collision works perfectly now.. I will keep on trying to make this game without having to have to make it after tutorials and asking more questions..


i like furry jesus and sódóma just more than anything else..
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Dec 2006 20:47
You quoted me out of context and judging by your comments, I get the feeling that you misread what I put in my post.

I'd just like to emphasize what I said:

Quote: "I'm sure you don't mean it, but that reads like"


It clearly says to me that you think I'm saying that I think you can't be bothered reading them - which clearly isn't true.

My point was more aimed at the way you asked for help - which might have been misinterpreted by some - and possibly discouraged them from helping you out.

Both Ruccus and I (along with many others) write tutorials - written in the simplest of terms - especially for newcomers, and I'm sure I'm right in thinking that he saw your post in the same way as I did.

It also appeared to me that as you say "just once, without having to have to make it after a tutorial" you might not be entirely familiar the way that some of us write tutorials.

Some take you through a completed game - explaining how each line works. After copying and pasting the lines of code and reading the text you should know what you are doing. I can appreciate that isn't as satisfying as writing your own code.

That's why in my tutorials I introduce the DB commands you need to use and explain how they do what they do - then supply a small example DBC program (which normally works fine in DBP also) showing the commands in action.

None of the supplied code is of any direct use in your game, so you have to use your newly-learnt knowledge to write it yourself rather than just copy and paste lines of code.

What you were struggling with is what happens if you try to use lines of code from a tutorial - or the help files - without understanding what they do.

When you've read a good tutorial, you should have enough knowledge on the subject to be able to fix the problems that you had.

If not, ask on here, but say: "I've read X's tutorial, but I'm not sure why this goes up instead of down" (or whatever). As I said, you'll get a much quicker response if it's obvious you had a bash at fixing it yourself...

TDK_Man

Lucifer
19
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 25th Dec 2006 01:14
oh. hehe, silly me , but i did read your tutorial on collisions, that didnt help me.. but i guess that no tutorial would have had the answer to my problem, the funny thing is, dbc didnt like set object collision on boxes 5 wich is one of the paddles, but before i set collision to boxes 4 wich is the other paddle, nothing worked. when i removed that collision on object 5 it worked like a charm..


i like furry jesus and sódóma just more than anything else..
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Dec 2006 06:04
Glad you sorted the problem in the end!

TDK_Man

Login to post a reply

Server time is: 2025-05-26 02:54:42
Your offset time is: 2025-05-26 02:54:42