Computer Science Canada Character fails to interact properly with two faces of a wall |
Author: | Legion [ Sun Mar 23, 2014 3:49 pm ] | ||
Post subject: | Character fails to interact properly with two faces of a wall | ||
What is it you are trying to achieve? I want the character to be unable to pass through a square. What is the problem you are having? My character only behaves the way he is supposed to for 2 sides of the wall. Describe what you have tried to solve this problem I do not know what I am doing wrong. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1 |
Author: | Insectoid [ Sun Mar 23, 2014 5:00 pm ] |
Post subject: | RE:Character fails to interact properly with two faces of a wall |
Your character is a 5x5 square. In your collision detection you are treating it as a point at (x, y). What does the screen look like when y = box1_y1? Draw it on paper if you have to in order to see it. |
Author: | Legion [ Sun Mar 23, 2014 5:47 pm ] |
Post subject: | RE:Character fails to interact properly with two faces of a wall |
Hey Insectoid, thanks for the reply! Anyway, correct me if I am wrong but wouldn't that just be a horizontal line at box1_y1 running infinitely? If so, I do not really see what you are trying to point out. Also, how do you think I can change the collision detection to treat the interaction as one between the two entities rather than as points. Or perhaps there is another easier way? |
Author: | Dreadnought [ Sun Mar 23, 2014 6:07 pm ] |
Post subject: | Re: Character fails to interact properly with two faces of a wall |
Legion wrote: Hey Insectoid, thanks for the reply! Anyway, correct me if I am wrong but wouldn't that just be a horizontal line at box1_y1 running infinitely? If so, I do not really see what you are trying to point out. Also, how do you think I can change the collision detection to treat the interaction as one between the two entities rather than as points. Or perhaps there is another easier way? He means what does your program look like when the variable y is equal to box1_y1. |
Author: | Legion [ Sun Mar 23, 2014 6:20 pm ] |
Post subject: | RE:Character fails to interact properly with two faces of a wall |
I do sincerely apologize for my incompetence. Nonetheless, if y is equal to box1_y1 then am I not just changing the starting location of the character, as that is what I had created the variable to do; store the coordinates of the character. Again, I really do apologize for not following what the two of you are trying to say, as I know what I just said is wrong but I don't know what else to think. I should, however, thank the two of you for attempting to help me. |
Author: | Dreadnought [ Sun Mar 23, 2014 6:24 pm ] |
Post subject: | Re: Character fails to interact properly with two faces of a wall |
The point is that the variables x and y represent the lower left corner of your character, so when y = box1_y1 your character is drawn with its lower left corner outside the box (which doesn't guarantee that your entire character is outside the box). |
Author: | Legion [ Sun Mar 23, 2014 7:17 pm ] | ||
Post subject: | Re: Character fails to interact properly with two faces of a wall | ||
But of course! That explains why the bottom wall and left wall did not function properly! I think that the fixed code will be this:
Sorry for not using the syntax code, but for some reason it was not working. The top right and bottom left corners don't work properly this way, but I doubt that my teacher will notice. Anyway, thank you so much Dreadnought! |
Author: | Dreadnought [ Sun Mar 23, 2014 7:51 pm ] |
Post subject: | Re: Character fails to interact properly with two faces of a wall |
Here's a link to a post on collision detection in Turing that might interest you http://compsci.ca/v3/viewtopic.php?t=13661 |