Computer Science Canada collision detection |
Author: | jonos [ Sun Feb 01, 2004 4:47 pm ] | ||
Post subject: | collision detection | ||
im trying to make a game, but i didn't understand the collision detection tony, dan, and some other people are talking about in tutorials, so i decided to try to make my own. im not sure if this is the right way to go about it, or if this way will cause problems with trying to do some things in the game. it works, but im not sure if it the right way to do it...
if the brevity of the code is not very good, oh well. |
Author: | Paul [ Sun Feb 01, 2004 4:49 pm ] |
Post subject: | |
oh, so you used the size of the walls? I was just thinking about how to do it with whatdotcolor, you know, the only thing I've thought up of is if a color drawn over that doesnt belong there, then change the coords. |
Author: | recneps [ Sun Feb 01, 2004 4:50 pm ] |
Post subject: | |
that works. thats basically the "rectangle" because you've made an invisible rectangle around the whole screen area, eg i show as a drawbox ;p drawbox(0,0,maxx,maxy,7) thats basically your box. and when it hits the edge of that box, its gonna go back one rather than forward, according to your code. |
Author: | Paul [ Sun Feb 01, 2004 4:55 pm ] |
Post subject: | |
Jonos, you won't mind if I leech off your post right? It has to do with the same thing. Can anyone tell me how to do collision detection with whatdotcolor? |
Author: | jonos [ Sun Feb 01, 2004 4:57 pm ] |
Post subject: | |
ill try it with whatdotcolor right now, hold on ten mins. i don't care if you leach off mine, i leached off your title colors |
Author: | recneps [ Sun Feb 01, 2004 5:00 pm ] |
Post subject: | |
have your walls say, black,.... drawbox(x,y,x2,y2,black) and your car, say, red drawoval(x,y,rad,rad,red) and if whatdotcolour(x[car]+rad,y[car]+rad) = black then collision=true end if |
Author: | jonos [ Sun Feb 01, 2004 5:06 pm ] | ||
Post subject: | |||
this is what i got, but it still doesn't work perfectly, i hope no one beat me to it. play around with it paulbian and maybe you can get it to work., |
Author: | Andy [ Sun Feb 01, 2004 5:08 pm ] |
Post subject: | |
your approach only works for mono colored things... what u should do is check to the direction of movement... |
Author: | Paul [ Sun Feb 01, 2004 5:10 pm ] |
Post subject: | |
Im thinking of doing one of those obstacle courses where you have to manuver the ball, which the size you can change, but the the smaller it is the faster it gets, through a tube that has different sized sections. Just to get familiar with collision detection. To me that's where whatdotcolor could be useful. |
Author: | jonos [ Sun Feb 01, 2004 5:10 pm ] |
Post subject: | |
can you help us please, cause what i gave doesn't even work, it stops in a place where it shouldn't. |
Author: | jonos [ Sun Feb 01, 2004 5:17 pm ] | ||
Post subject: | |||
just one small thing to fix cause the circle stops in this one place on the y axis all the time |
Author: | Paul [ Sun Feb 01, 2004 5:21 pm ] | ||
Post subject: | |||
I just made a minor change to the if structure, cause you used elsif, it doesnt move diagonally.
|
Author: | jonos [ Sun Feb 01, 2004 5:24 pm ] | ||
Post subject: | |||
yeah, i was trying some stuff to make it go diagonal, thanks. i got it working, i just had to make the window smaller, which probably isn't the best way to do it, but whatever
maybe someone will know how to do it better. |
Author: | TheXploder [ Sun Feb 01, 2004 5:32 pm ] |
Post subject: | |
it's still wierd somethimes the up button make it move through the wall or the up button makes it move down.. really weird, and I've never see anyone do collisions with whatdotcolour... |
Author: | jonos [ Sun Feb 01, 2004 5:35 pm ] |
Post subject: | |
yeah, i see what you mean, i think it's just turing though, because i don't see how it could be wrong. ive thought it over pretty hard |
Author: | McKenzie [ Sun Feb 01, 2004 5:35 pm ] | ||
Post subject: | |||
your checks are wrong. e.g. you have:
if you are looking left it should be the point (circlex - radius -1, circley) |
Author: | Paul [ Sun Feb 01, 2004 5:36 pm ] | ||
Post subject: | |||
I got my whatdotcolor collision working, it works fine.
Mine grows and shrinks too Edit I deleted the below post because I feared the wrath of AsianSensation. |
Author: | Cervantes [ Sun Feb 01, 2004 5:36 pm ] | ||
Post subject: | |||
collisions with whatdotcolour are the first way I learned to do them.. however, whatdotcolour isn't as good as going it with coords in some instances, in other instances whatdotcolour is the only way to go to make it go diagonal..
the difference being that I got rid of the elsif's and replaces them with if's. before, if the uparrow was being pressed, it would never ask whether any of the other keys were being pressed. this way it will |
Author: | McKenzie [ Sun Feb 01, 2004 5:37 pm ] |
Post subject: | |
I type too slow. |
Author: | Paul [ Sun Feb 01, 2004 5:47 pm ] |
Post subject: | |
I tried to get the growing shrinking thing to be restricted by the wall too, using the same principle, but it didn't work. |
Author: | jonos [ Sun Feb 01, 2004 5:51 pm ] |
Post subject: | |
thanks mckenzie, that really helped, don't know why i didn't see it for the growing circle couldn't you just go: [code] if circlex+radius+1 or circlex -radius-1 or circley+radius +1 or circley -radius -1 = [the wall color] then radius-1 or radius+1 else do nothing end if that may not be right haven't tested it.l |
Author: | Cervantes [ Sun Feb 01, 2004 5:53 pm ] | ||||
Post subject: | |||||
where you have the
you should alter add an if statement in there
do the same thing with y if you want to do collisions with whatdotcolour then you can do that as well, you just have to implement it into the spots in that code up there where I put things like "if y > maxx - 20 then" Cheers |
Author: | Cervantes [ Sun Feb 01, 2004 5:56 pm ] | ||
Post subject: | |||
jonos wrote: if circlex+radius+1 or circlex -radius-1 or circley+radius +1 or circley -radius -1 = [the wall color] then radius-1 or radius+1 else do nothing end if jonos an if statement does not need to have an else. ex of that is your code modified by me so that it can go on a diagonal. sometimes else is useful though, but if its
then just ditch the else. Cheers |
Author: | jonos [ Sun Feb 01, 2004 6:06 pm ] |
Post subject: | |
yeah, i know that, don't know why i put that. i probably though of putting something there but then decided against it. |
Author: | Paul [ Sun Feb 01, 2004 6:07 pm ] | ||
Post subject: | |||
I tried it, using and instead of or and it works!
He didn't delete, I just deleted it, fearing his wrath. |
Author: | jonos [ Sun Feb 01, 2004 6:13 pm ] |
Post subject: | |
there are still things wrong with it, and i can't find it and don't want to spend time doing it. if you blow it up and move it left, then it can still get through, as well as if you keep playing around with it it will do the same for the other walls. ahhhh, this is confusing |
Author: | Cervantes [ Sun Feb 01, 2004 6:14 pm ] |
Post subject: | |
oh lol, I just deleted my post sense i saw your post reappear. (you can delete this and 2 bits if you want Asian ) |
Author: | Paul [ Sun Feb 01, 2004 6:15 pm ] |
Post subject: | |
yea, I noticed that left wall thing to, I fixed that line. |
Author: | Cervantes [ Sun Feb 01, 2004 6:20 pm ] | ||||
Post subject: | |||||
for things like this I prefer to use coordinates rather than whatdotcolour in terms of collision
that's still slightly buggy.. the + 15 or the - 15 in this part
10 because you did drawfilloval (x,y,addx + 10, addy + 10, red) and 5 because that's how much you add every time enter or backspace is hit. the 5 is prevention. Keep playing around with it and we can iron out all the bugs. EDIT: the bug in this code is that it works fine for the first wall that you got to, but then any of the other walls you go to its buggy... |
Author: | Andy [ Sun Feb 01, 2004 6:25 pm ] |
Post subject: | |
Cervantes wrote: however, whatdotcolour isn't as good as going it with coords in some instances, in other instances whatdotcolour is the only way to go
cervantes, how much bits do u want to lose? whatdotcolor is ALWAYS i repeat ALWAYSE the way to go!!!! and not in some instances, nonono, in ALL i repeat ALL instances, whatdotcolor is the only way to not go, LIVE. -5 bits btw |
Author: | Paul [ Sun Feb 01, 2004 6:25 pm ] |
Post subject: | |
crap, I edited the wrong line, I edited it back now. Theres a bug that when you expand while moving, it goes into the wall. |
Author: | Cervantes [ Sun Feb 01, 2004 6:32 pm ] |
Post subject: | |
okay okay dodge I repent I repent! hail whatdotcolour!! whatdotcolour is the way to go! It's the way to live! All hail whatdotcolour!! The Turing command that elevates Turing beyond C++ for gaming and all other purposes! |
Author: | Andy [ Sun Feb 01, 2004 6:34 pm ] |
Post subject: | |
gj, plus another 10 bits lol |
Author: | Paul [ Sun Feb 01, 2004 6:35 pm ] |
Post subject: | |
Yes, whatdotcolor IS the greatest thing ever, it changed my life, otherwise I might not understand collision at all. I'll go and reccommend it to all my friends now. *nudge* |
Author: | Cervantes [ Sun Feb 01, 2004 6:41 pm ] |
Post subject: | |
woot! I'm getting the hang of this religion now Paulbian I'll have my own style of your program up in a bit. |
Author: | shorthair [ Sun Feb 01, 2004 6:46 pm ] |
Post subject: | |
dodge is being sweet talked every way till sunday , i think a labrinth marble game , would be hte best way to put collision detection to the test ,also becuase you would hav etrue phyics involved , wow i jsut bouht 3dsMax and im lost , the book is 790 pages , its insane in the membrane wanna know why......." its the beginers guide " , someone better make a what dot color tutorial , everyone asks aboutit at least once in their compsci life ( well most ) ,dodge this would be cool of you to do since your like the god of it and what not |
Author: | Andy [ Sun Feb 01, 2004 6:50 pm ] |
Post subject: | |
ok well since ccc is coming up, for every problem on there that some one does with whatdotcolor in a cool way, i will award 20 bits*question number s4 counts as 6 s5 as 7 |
Author: | recneps [ Sun Feb 01, 2004 6:53 pm ] |
Post subject: | |
whats CCC? |
Author: | Andy [ Sun Feb 01, 2004 6:57 pm ] |
Post subject: | |
waterloo's canadian computing contest |
Author: | shorthair [ Sun Feb 01, 2004 7:03 pm ] |
Post subject: | |
go look in contests and im sur there is a sticky with everything about it by tony or someone , its really interesting , you ca end up programming overseas for waterloo , well 4 peopel in canada will be |
Author: | recneps [ Sun Feb 01, 2004 7:04 pm ] |
Post subject: | |
Verrrry Interesting |
Author: | Andy [ Sun Feb 01, 2004 7:06 pm ] |
Post subject: | |
4? more like 20 |
Author: | shorthair [ Sun Feb 01, 2004 7:08 pm ] |
Post subject: | |
for the final amount , i htought it was like 4 , wow ther eteam is that big , didnt bugz make round 2 last year the one at waterloo |
Author: | Andy [ Sun Feb 01, 2004 7:10 pm ] |
Post subject: | |
yea so did another massey kid, but he didnt want to go... he's at MIT now |
Author: | Cervantes [ Sun Feb 01, 2004 7:20 pm ] | ||||
Post subject: | |||||
what compsci knowledge should you have for this CCC? full highschool knowledge? Paulbian here's my version of your program, flawless if I might add. and in the spirit of my conversion to whatdotcolour I have utilized whatdotcolour in said program 8)
btw, just to clarify, do you know what this means?
|
Author: | Paul [ Sun Feb 01, 2004 7:21 pm ] | ||
Post subject: | |||
either that or 1+1=3 |
Author: | Paul [ Sun Feb 01, 2004 7:24 pm ] |
Post subject: | |
Do this with your program, run it, at the start hold down 3 keys: up arrow, right arrow, and enter. release the keys when its grown all it can grow then hold up key. flawless? |
Author: | shorthair [ Sun Feb 01, 2004 7:25 pm ] |
Post subject: | |
2 + 2 = 5 , in really big instances of 2 , and about ccc , if your gonna d ojunior ( which stops at het first round , you can do it in turing i did really well ) if your doin senior you need to know another language it costs me 5 $ t oenter the senior just for hte heck of it , i just like the time off school and te chalenge , no where near good enough tomake it out of the school to round 2 , |
Author: | Cervantes [ Sun Feb 01, 2004 7:37 pm ] | ||||||
Post subject: | |||||||
*tapes Paulbian's mouth shut like so --> * flawless indead! also
is the same as
correct the reason that is doing that is because I used whatdotcolour and I am not experienced enough yet... the other way I did it, like so
worked fine for that.. it would work with whatdotcolour too but the boarder doesn't go outside the screen, the boarder is pretty thin. I'm going to need instruction in the ways of whatdotcolour here dodge. |