Computer Science Canada

Having collision problems and [why laws of universe r wrong]

Author:  Axarent [ Fri Jun 06, 2003 6:03 pm ]
Post subject:  Having collision problems and [why laws of universe r wrong]

I'm a newb to programming and was wondering if anyone could give me suggestions on how to do collisions for hitting a target that you've shot at. I've been trying and just can't get it to work. Thx

Author:  Tony [ Fri Jun 06, 2003 7:04 pm ]
Post subject: 

we got tutorials on rectangle and circle colision detections available... all depends on what kind of target you're trying to hit and with what.

Author:  Axarent [ Fri Jun 06, 2003 9:46 pm ]
Post subject: 

well I was trying a space shooter with a moving enemy picture that I drew in paint and flys across the screen. i'm using draw line to create the shot should I try to use draw oval and box to make the enemy to make it easier??

Author:  Tony [ Fri Jun 06, 2003 9:58 pm ]
Post subject: 

well you could treat the ships as circles (keep the picture though) and use equations y = mx + b and x^2 + y^2 = radius to see if your lazer line intersects the ship or not.

Author:  Axarent [ Sun Jun 08, 2003 5:47 pm ]
Post subject: 

so would I use the coordinates of my laser line for y and x in y=mx +b and the coordinates of the enemy for x and y in x^2 + y^2 = radius and then check if the line intersects the diameter at anytime right??

Author:  Tony [ Sun Jun 08, 2003 8:57 pm ]
Post subject: 

yeah, but as bugz pointed out in another post, I got forumulas mixed up a bit...

for the line, its better to use Ax+By+C=0 I think...

circle is (x-a)^2 + (y-b)^2 = radius^2 where a/b are x/y of circle's center.

Author:  PaddyLong [ Sun Jun 08, 2003 10:20 pm ]
Post subject: 

radius^2 you mean for the circle Razz

Author:  Andy [ Sun Jun 08, 2003 10:26 pm ]
Post subject: 

uhoh tony, forgetting rade 10 math eh?

Author:  Martin [ Sun Jun 08, 2003 10:40 pm ]
Post subject: 

And rade 9 english, dodge Wink

Author:  Tony [ Sun Jun 08, 2003 10:50 pm ]
Post subject: 

huh? it says
Quote:
= radius ^2


did anyone else read 1984? Great book Twisted Evil

Author:  Andy [ Mon Jun 09, 2003 8:01 am ]
Post subject: 

riiite that's y it says last edited by tony... ya its an awsome book, big brother's watching u...

Author:  Grey_Wolf [ Mon Jun 09, 2003 3:48 pm ]
Post subject: 

1984 is a great book. What does that have to do with anything.

Author:  PaddyLong [ Mon Jun 09, 2003 4:35 pm ]
Post subject: 

1 + 1 is only 2 becuase we've been trained to believe it (or somethign to that effect... haven't read the book for a while)

Author:  Andy [ Mon Jun 09, 2003 5:22 pm ]
Post subject: 

hey man, tony owns the site, he can say any thing he wants.. Wink

Author:  Tony [ Mon Jun 09, 2003 6:05 pm ]
Post subject: 

it was 2+2=5... and those guys are right... here's the math proof behind it (someone had part of this equation as their signature)

assume x = a
x^2 = ax
x^2 - a^2 = ax - a^2
(x+a)(x-a) = a(x-a)
x+a = a
x + x = x
2x = x
2x + x = x + x
3x = 2x
5x - 2x = 2x
5x = 2x + 2x
*divide both sides by x
5 = 2 + 2

So teachnically... the book is telling the truth. 2+2 does equal to 5.

Author:  Catalyst [ Mon Jun 09, 2003 6:10 pm ]
Post subject: 

that is so wrong

Author:  Axarent [ Mon Jun 09, 2003 6:34 pm ]
Post subject: 

Wow now I can tell people that 2+2 does = 5. Anyways I'm using mine as a function and I'm having difficulty getting it to work so would it be easier to just make it an if in the code somewhere else? and cause it's a fcn I've put a for loop so it can get true or false multiple times, is that good? Well here's what I've got for the collision function
code:

var x : int := 150
var y : int := 25
var x1 : int := x + 25
var y1 : int := y + 25
var y2: int := maxy
var x2 : int := 150
var centrex, centrex1, centrey, centrey1 : real

function enemydead : boolean
    centrex := x1 - 7.5
    centrex1 := x2 - 19
    centrey := y1 - 7.5
    centrey1 := y2 - 19
    var enemyradius : real := ((centrex1) * (centrex1) + (centrey1) * (centrey1)) ** 0.5
    var shotradius : real := ((centrex) * (centrex) + (centrey) * (centrey)) ** 0.5
    var distance : real := ((centrex1 - centrex) * (centrex1 - centrex) + (centrey1-centrey) * (centrey1-centrey))**0.5
    for i : 1 .. 21
        if distance < shotradius + enemyradius then
            result true
        end if
    end for
    result false
end enemydead

Author:  Andy [ Mon Jun 09, 2003 7:22 pm ]
Post subject: 

u morons, he divided by 0!!!
when he divided (x-a) on both sides, he divided 0

Author:  Tony [ Mon Jun 09, 2003 8:07 pm ]
Post subject: 

eh... the function will end once it returns a value Confused

dodge -> When you divide by 0, everything is possible Laughing

BTW, read line

X^2 - A^2 = AX - A^2

if you replace A with X (since they equal to each other) you'll get 0 = 0

thats the reason A is in equation, so that people dont notice it.

And easy on the words there...

Author:  Axarent [ Tue Jun 10, 2003 2:41 pm ]
Post subject: 

Would it be easier as a procedure of process? or what's the best possible way I can do this???

Author:  Tony [ Tue Jun 10, 2003 2:56 pm ]
Post subject: 

processes are bad, end of story... so I guess you're better off with a procedure 8)

Author:  octopi [ Tue Jun 10, 2003 4:52 pm ]
Post subject: 

Using what tony wrote you could also say that

3 == 2


code:
x^2 = ax
x^2 - a^2 = ax - a^2
(x+a)(x-a) = a(x-a)
x+a = a
x + x = x
2x = x                   //<----- or even 2 == 1
2x + x = x + x
3x = 2x
--   --
 x    x

3 = 2

Author:  Andy [ Tue Jun 10, 2003 5:08 pm ]
Post subject: 

bascly you can prove anything equals anything once you prove 0=1

Author:  Tony [ Tue Jun 10, 2003 7:42 pm ]
Post subject: 

you could do that... since 2 = 1, you keep on dividing both sides untill the right side would show up as 0. (hey, there got to be a limit on how presise you can get). Now at the point, since left side was larger, then it has to be a value of something larger then 0. Now multiply both sides and you can get

anything = 0.

Another way though, just subtract one from both sides, and multiply by whatever you want.

2 = 1
2 - 1 = 1 - 1
1 = 0
1 * 100 = 0 * 100
100 = 0

Ohhh... All those years, we lived lies in math classes. Lies, all LIES

Author:  Blade [ Tue Jun 10, 2003 7:51 pm ]
Post subject: 

if you start off with 2=1 then anything will = 0... start off with 100=100

Author:  Tony [ Tue Jun 10, 2003 8:01 pm ]
Post subject: 

well it was already proven that 2 does equal to 1 in previous posts.

Author:  AsianSensation [ Tue Jun 10, 2003 8:44 pm ]
Post subject: 

enough about dividing by zero, here is something that's weird and does not divide by 0

let x= 1+2+4+8+16+...(infinite)

x-1 = 2+4+8+16+...
(x-1)/2=1+2+4+8+...
(x-1)/2=x
x-1=2x
-1=x

therefore, -1=1+2+4+8+16+...

hehe

Author:  Mazer [ Tue Jun 10, 2003 9:16 pm ]
Post subject: 

AsianSensation wrote:

(x-1)/2=1+2+4+8+...


wouldn't that mean that you just tried to divide infinite by 2?

Author:  Tony [ Tue Jun 10, 2003 9:58 pm ]
Post subject: 

ya, he did...

though infinity and 0 are right next to each other... they have the same type of relationship as end points of a worm hole Shocked

1/0 = infinity

and infinity * 0 = 1 Shocked

I'm thinking we should make a whole new section on this forum just for things like this...

Author:  Ravage [ Tue Jun 10, 2003 10:04 pm ]
Post subject: 

You guys seem to think you have math all figured out and yet you have forgotten the basic rule of algebra, and thats do unto one side of the equation that of which you do to the other so basically To get 2=1 you must start off with 0=0 and turn it into 0+2=0+1 this is by far the wrong way to do it as you're supposed to keep the equation balanced as the equal sign makes that evident, so in order to get 0=1 or anything means you're a complete dumbass and need to go way back in elementary school and learn basic algebra again

I love being right

Author:  Catalyst [ Tue Jun 10, 2003 10:09 pm ]
Post subject: 

tony wrote:

infinity * 0 = 1


so by that

1+ 0*infinity =2

(1/infinity)+(0/infinity)=2/infinity

since 1/infinity=0 (see the first eq)

0/inf=2/inf

0=2

infinites and zeros are interesting (need to learn some calculus..)

Author:  Tony [ Tue Jun 10, 2003 10:11 pm ]
Post subject: 

Ravage Confused you are just soo wrong. Well no, you're right... but if you notice, we always do same operations to both sides of the equation. Though we might miss some steps that are considered obvious.

such as instead of:
2 = 1
2 + 3 = 1 + 3
5 = 4
5 = 2 + 2

we might simply write
2 = 1
5 = 2 + 2

skip couple of steps... still there though Wink

Author:  Catalyst [ Tue Jun 10, 2003 10:14 pm ]
Post subject: 

just showing how infinites and zeros screw with normal mathmatical perceptions

Author:  Tony [ Tue Jun 10, 2003 10:17 pm ]
Post subject: 

hey, another proof that 2 = 1 Very Happy

Quote:
0 = 2

0/2 = 2/2
0 = 1
1 = 2
Laughing

Hah, I love this kind of math

Author:  Catalyst [ Tue Jun 10, 2003 10:18 pm ]
Post subject: 

ya its great
cant wait till calculus rolls along

Author:  Mazer [ Wed Jun 11, 2003 6:52 am ]
Post subject: 

tony wrote:
hey, another proof that 2 = 1 Very Happy

Quote:
0 = 2

0/2 = 2/2
0 = 1
1 = 2
Laughing

Hah, I love this kind of math


tony, if you can prove to somebody that 0 is indeed equal to 2, i'm sure they won't worry about proof that 2 = 1...

Author:  Ravage [ Wed Jun 11, 2003 12:00 pm ]
Post subject: 

tony wrote:
Ravage Confused you are just soo wrong. Well no, you're right... but if you notice, we always do same operations to both sides of the equation. Though we might miss some steps that are considered obvious.

such as instead of:
2 = 1
2 + 3 = 1 + 3
5 = 4
5 = 2 + 2

we might simply write
2 = 1
5 = 2 + 2

skip couple of steps... still there though Wink


Yes but you once again skipped the most important step, in order to get any equation you must start off with 0=0 and then work your way up by adding subtracting or whatever you must do the same operation on both sides let me show you

everything starts with
0=0
in order to get 2=1 or anything like that you must do
0+2=0+1 which is entirely wrong on you're way of doing it
you have to do unto one side which you do to the other so if you do this
0+2 on the left side you must do 0+2 on the right side of the equation

Man I hate it when people don't know what they are talking about

Author:  Blade [ Wed Jun 11, 2003 12:00 pm ]
Post subject: 

dude, you start off wrong, 2 does not = 1... so you are wrong to begin with, you need to start with numbers that are equal on both sides, and end up with numbers that are equal on both sides, so you start off wrong and you end up wrong at the end... its like paying for a $500 computer and only giving them a loonie and saying that anything = 1

Author:  Andy [ Wed Jun 11, 2003 3:26 pm ]
Post subject: 

don't u ppl have anything better to do? this is supposed to be a help forum, Asok y aren't u moving it?

Author:  Catalyst [ Wed Jun 11, 2003 4:04 pm ]
Post subject: 

the begining is still help related

Author:  Tony [ Wed Jun 11, 2003 4:53 pm ]
Post subject: 

dodge_tomahawk wrote:
don't u ppl have anything better to do?


Laughing This should go to hall of shame Twisted Evil

and Ravage... we're SOLVING equations, not making up questions for math textbook.

there for you start of with what you're given and work down untill it makes sence... which just happens to be 0 = 2 (or 2 = 1)

Author:  Ravage [ Thu Jun 12, 2003 12:08 pm ]
Post subject: 

tony wrote:
dodge_tomahawk wrote:
don't u ppl have anything better to do?


Laughing This should go to hall of shame Twisted Evil

and Ravage... we're SOLVING equations, not making up questions for math textbook.

there for you start of with what you're given and work down untill it makes sence... which just happens to be 0 = 2 (or 2 = 1)


but when you're given an equation such as this it's false therefore meaning you can not solve it as there is no solution or have done something wrong to narrow it down to this

Author:  Andy [ Thu Jun 12, 2003 1:50 pm ]
Post subject: 

lol, you can assume something false is true then use that to prove itself is true, then you anything can be equal to anything

Author:  Catalyst [ Thu Jun 12, 2003 2:33 pm ]
Post subject: 

if something is false and you apply all the correct rules cant be mutated into a new falseness (is that a word) for example, 1=2, can be changed to 2=4,0.5=1 or whatever not 5=4 tho

but

if u try to use the rules with 0s and infinites thats when things get screwy

Author:  Ravage [ Mon Jun 16, 2003 11:52 am ]
Post subject: 

Catalyst wrote:
if something is false and you apply all the correct rules cant be mutated into a new falseness (is that a word) for example, 1=2, can be changed to 2=4,0.5=1 or whatever not 5=4 tho

but

if u try to use the rules with 0s and infinites thats when things get screwy


Well if it's still false that means it's wrong and thereforethis whole thread is pointless, as it's nothing but a constant rambling of how you all think you know math

Author:  Andy [ Mon Jun 16, 2003 2:41 pm ]
Post subject: 

ya asok should lock this

Author:  RaPsCaLLioN [ Wed Aug 06, 2003 12:30 am ]
Post subject: 

Quote:
Well if it's still false that means it's wrong and thereforethis whole thread is pointless, as it's nothing but a constant rambling of how you all think you know math


Ravage dude if it pisses you off that much why do you reply? The point is not to prove that 2=1 is false cuz any idiot (such as yourself) can prove that. The point is to prove the initial equation, seemingly flawless, is wrong.

1. a = b
2. a squared = ab
3. a squared - b squared = ab-b squared
4. (a+b)(a-b) = b(a-b)
5. a+b = b
6. b+b = b
7. 2b = b
8. 2 = 1

The problem is step 4. Since a=b then a-b=0. Hence step 4 cannot take place as a divide by 0 is undefined. Why undefined? Well say 1/0 = x. Then 0*x=1. No real number makes the equation 0*x=1 work so that's why it's undefined.

I know this is an old thread... but then why'd you read it?[/quote]


: