Computer Science Canada Grid collision |
Author: | Flikerator [ Tue Mar 15, 2005 3:19 pm ] | ||||
Post subject: | Grid collision | ||||
Alright I was working on it before, but I droped it due to the competition. If anyone knows how to do grid collision could you help me out? My game will have you charcter and he moves around. There is an invisible grid. When he is in a certain section then he is "in" that part of the grid. If and object is "in" a grid he is about to enter then he is stopped and cannot move there. This will help me because I can make "red" areas (places with buildings) in each area. If he is going to step into a red area, he won't be able to. This will help make the program smoother with green areas (Creatures) that move around and change there grid. I know it can be down, I just don't know how to do it
That is kinda what it looks like (You won't see it when you play though, so no whatdotcolour).
And for an example of squares filled. Just cause im that bored If anyone wants to see the movement just say so and ill post it. |
Author: | ssr [ Tue Mar 15, 2005 6:38 pm ] |
Post subject: | |
well I think u should post ur code... anyway I would make an array and record the position of the squares, and then if a dot is in that area, it will stop... 8) |
Author: | ssr [ Tue Mar 15, 2005 7:06 pm ] | ||
Post subject: | |||
hopefully this is what u r looking for just one square, but u can increase the # of squares, and restrictions u can see the square if u delte teh "%" in the code 8) |
Author: | Cervantes [ Wed Mar 16, 2005 7:50 am ] |
Post subject: | |
ssr: You can go inside the yellow box if you approach it from one of it's corners. And, that's not what he's looking for. He's looking to do this. Flikerator: First, try to decide which way you're going to store the block's information. Do you have a finite number of things that can be in any one grid, or do you not know how many could be in any one grid square? Actually, on that note: how does one make a linked list? |
Author: | Flikerator [ Wed Mar 16, 2005 11:41 am ] | ||||
Post subject: | |||||
ssr wrote:
hopefully this is what u r looking for just one square, but u can increase the # of squares, and restrictions u can see the square if u delte teh "%" in the code 8) Thats not what I was looking for, but thanks anyway ^^; Quote: ssr: You can go inside the yellow box if you approach it from one of it's corners.
And, that's not what he's looking for. He's looking to do this. Flikerator: First, try to decide which way you're going to store the block's information. Do you have a finite number of things that can be in any one grid, or do you not know how many could be in any one grid square? Actually, on that note: how does one make a linked list? I guess I could do each block has a space of 100. If a certain colour is there it adds a certain amount to the block. If it is 101 or greater then it cannot be done][Movement stopped. But really everything will either take up 100 or 0. Fire will take up 0 but will cause damage if you step on it. I have other ideas for fire too but that will wait.. In each square (or block) 100 units can fit in it. If its over 100 then it cannot go there. Im not sure how I would do that, ill read that link and edit this post.. What do you mean by a linked list? string+string? EDIT; I read that. You sent me there last time lolz. How would I do that in Turing though? Make the invisible grid and if you are in it then the unit of that grid goes up 100 (thats your unit size) if something else is there then you cannot go there. Here is a prog, all you need to do is make the grid invisible and have a value of each block
|
Author: | ssr [ Wed Mar 16, 2005 1:50 pm ] |
Post subject: | |
lololol ok then anyway ya I know that u can go in,is there any way to pervent it? I mean it happens in whatdotcolor, I know y, but dont want to calculate the distance adn all that, ok now, is there another way to make collusion detection |
Author: | Flikerator [ Wed Mar 16, 2005 2:16 pm ] |
Post subject: | |
ssr wrote: lololol
ok then anyway ya I know that u can go in,is there any way to pervent it? I mean it happens in whatdotcolor, I know y, but dont want to calculate the distance adn all that, ok now, is there another way to make collusion detection Read collision detection in tutorials |
Author: | Cervantes [ Wed Mar 16, 2005 6:54 pm ] |
Post subject: | |
Flikerator: You're missing one part of the grid collision idea. If two circles are determined to both be at least partially in the same grid square, they MIGHT be touching. Or they might not. If, in fact, the two circles are both determined to be in the same square (partially, at least), then use whatever method of collision detection to determine if they have collided. If you're using circles (or somehing closely resembling a circle) use the distance formula and the sum of the two radii. The whole point of this is to save the processor from doing thousands of distance formulas, or worse if you were using, say, irregular 3D entities. As for linked lists, I can only guess that it's a bunch of information linked together in a linear fashion (using pointers?). But that's just a guess. Silly me, I can't help but think of it as a chain. Or, if we add another dimension, it becomes chain mail armour! Aah, someone save me! |
Author: | Flikerator [ Wed Mar 16, 2005 7:36 pm ] |
Post subject: | |
But you still havn't showed me how to do it in Turing >< |