Computer Science Canada Very Important!!!!!!!!!!!!!! |
Author: | Paper*Mate [ Wed Jun 01, 2005 11:21 am ] |
Post subject: | Very Important!!!!!!!!!!!!!! |
I am having trouble with the collisions for my bullet... My charcter in the game is red. when u move the circle around it doesn't go through the wals (black rectangles). But when i shoot the bullet goes through the walls....please tell me why it is doing this and how i can fix it. --------------------- setscreen ("offscreenonly") var x, y : int var x2, x3, y2, y3 : int := 200 var shot : boolean := false var bulletx, bullety : int := 0 x := 100 y := 100 var chars : array char of boolean loop drawfillbox (50, 110, 40, 280, black) drawfillbox (590, 110, 600, 280, black) drawfillbox (490, 0, 500, 25, black) drawfillbox (490, 375, 500, maxy, black) drawfillbox (125, 375, 135, maxy, black) drawfillbox (125, 0, 135, 25, black) drawfilloval (320, 190, 50, 50, black) drawfillbox (maxx, maxy, 637, 0, black) drawfillbox (0, 0, maxx, 2, black) drawfillbox (0, 0, 2, maxy, black) drawfillbox (0, 397, maxx, maxy, black) drawfilloval (x, y, 6, 6, 12) Input.KeyDown (chars) if chars (KEY_UP_ARROW) then if whatdotcolor (x, y + 9) = 0 then y := y + 5 end if end if if chars (KEY_RIGHT_ARROW) then if whatdotcolor (x + 9, y) = 0 then x := x + 5 end if end if if chars (KEY_LEFT_ARROW) then if whatdotcolor (x - 9, y) = 0 then x := x - 5 end if end if if chars (KEY_DOWN_ARROW) then if whatdotcolor (x, y - 9) = 0 then y := y - 5 end if end if if chars (KEY_CTRL) and shot = false then if whatdotcolor (x, y + 9) = 0 then shot := true bulletx := x bullety := y end if end if if bulletx < maxx and shot then bulletx += 10 drawfilloval (bulletx, bullety, 2, 2, brightred) elsif bulletx >= maxx then shot := false end if View.Update delay (10) cls drawfilloval (500, 150, 9, 9, 50) end loop |
Author: | fahQall [ Wed Jun 01, 2005 11:22 am ] |
Post subject: | help with collision |
you have a vagina |
Author: | Paper*Mate [ Wed Jun 01, 2005 11:37 am ] |
Post subject: | REAL HELP |
I NEED REAL HELP..NOT SOME BULLSHIT |
Author: | DudeYouHaveToWait [ Wed Jun 01, 2005 11:44 am ] |
Post subject: | ... |
they're doing it for a school project don't help them |
Author: | Paper*Mate [ Wed Jun 01, 2005 11:48 am ] |
Post subject: | U idiot |
First of all, we can use help on compsci. This is my first time using it. I tried for 2 days fixing the problem and couldn't so therefore i posted the help i needed on compsci. |
Author: | Bacchus [ Wed Jun 01, 2005 11:52 am ] |
Post subject: | |
It doesn't matter if he needs it for a school project. He's asking for help, not for direct code and thats good enouph for me. Telling people not to help someone is quite mean of you DudeYouHaveToWait. @fah: Hopefully a Mod will soon edit your post to get rid of that disgustful comment, and as for you.. you may end up being banned or if your lucky, warned. @Paper*Mate: Paper*Mate wrote: if bulletx < maxx and shot then
This is where you're updating the bullets placement, you don't have a check here to determine if the bullet is going into a wall, only if it will go off the screen.
bulletx += 10 drawfilloval (bulletx, bullety, 2, 2, brightred) elsif bulletx >= maxx then shot := false *EDIT* Ah you posted while I did, kudos to you for standing up. |
Author: | Paper*Mate [ Wed Jun 01, 2005 11:54 am ] |
Post subject: | |
THANKS |
Author: | Bacchus [ Wed Jun 01, 2005 11:55 am ] |
Post subject: | |
You're quite Welcome ![]() |
Author: | staticlike [ Wed Jun 01, 2005 11:57 am ] | ||||
Post subject: | |||||
lets see...
x and y are the player variables, you should use bulletx and bullety, plus it's checking 9 pixels above where it's going, which works when the bullet is going up, but it's going to the right so...
also, i don't see any collision check. add something to check if it's going to hit an object somewhere. just remember that it has to check in the direction that the bullet is going, and you need to use different checks depending on which way you are going. I'm pretty sure that something about this is posted in tutorials, but i'm not sure, i don't visit often enough. make sure you check the tutorials forum and search the turing boards for information before you post! ![]() fah: That language isn't really appreciated here. if you are going to post, post something relevant, or actually help the person. thanks ![]() DudeYou: why would that make any difference? he asked for help so i'm giving it to him. he can't do something he doesn't learn about. EDIT: wow, i'm slow! ![]() |
Author: | Delos [ Wed Jun 01, 2005 12:55 pm ] |
Post subject: | |
As a final note to this all... In the future, more descriptive topic titles would be appreciated. As well as the use of [code] tags for your code. And bolding everything is just as bad as putting it all CAPS. Thanks for listening! Oh yeah, if you're collision detection still lacks...check out the Tutorials section. Good stuff there. |
Author: | [Gandalf] [ Wed Jun 01, 2005 1:14 pm ] |
Post subject: | |
Another perfect example of: [Gandalf] wrote: why is it that these people who come from the same school/class (not just the people in this topic) feel like they have to flame and put down each other? Does everyone hate each other? Or are you competing for marks?
There will always be some idiots, which is why I suggest not using compsci.ca at school. Just wait till you get home, then post your topics/questions. Everyone from this school, I suggest you read the rules closely and follow them. If you need more help, this is where to find it: http://www.compsci.ca/v2/viewtopic.php?t=8808 |
Author: | Paper*Mate [ Wed Jun 01, 2005 4:08 pm ] |
Post subject: | |
Wow....it works..thanks everyone |