1. quad tree

hi everyone I’m writing a rts game and need a quad tree written in euphoria can anyone help?

i'm asking if anyone would write a quad tree in euphoria for me with a demo.

information on a quad tree http://en.wikipedia.org/wiki/Quadtree

new topic     » topic index » view message » categorize

2. Re: quad tree

Perhaps you should begin with stating to yourself what it is you actually need the tree for. It wasn't very clear from your previous post at least. A tree is just a data structure, but what kind of data do you want to store in each node, and what are the operations you want to perform on the tree? After you've decided on that maybe the implementation will become obvious to you.

new topic     » goto parent     » topic index » view message » categorize

3. Re: quad tree

Perhaps you should begin with stating to yourself what it is you actually need the tree for. It wasn't very clear from your previous post at least. A tree is just a data structure, but what kind of data do you want to store in each node, and what are the operations you want to perform on the tree? After you've decided on that maybe the implementation will become obvious to you.

new topic     » goto parent     » topic index » view message » categorize

4. Re: quad tree

I need the quad tree for speeding up collision detection because at the moment when I’m doing collision checking I have to check one object at a time for collision with all objects and then I have to repeat that process for all objects in the game like trees units etc and it slows the game down to much.

new topic     » goto parent     » topic index » view message » categorize

5. Re: quad tree

Hi, Gaz

Forgive me if I'm talking out of turn here, but it sounds to me like your code is doing too much work. Surely one only needs to check if a collision has happened when and with something that has just moved. Would there be any need to check whether one tree just collided with another? Perhaps it is not the kind of game I am thinking of.

Cheers,

Nick.

new topic     » goto parent     » topic index » view message » categorize

6. Re: quad tree

A simple recursive depth-first traversal..

constant T = { 
{2,3,4,5, 1}, 
{0,6,0,0, 2}, 
{0,0,0,0, 3}, 
{0,0,0,0, 4}, 
{0,0,0,0, 5}, 
{0,0,0,0, 6} 
} 
 
 
procedure visit(sequence node) 
	printf(1, "Visiting node %d\n", node[5]) 
end procedure 
 
 
procedure traverse(sequence tree, integer root, integer proc_id) 
	for i = 1 to 4 do 
		if tree[root][i] then 
                        -- Visit the i:th child node 
			call_proc(proc_id, {tree[tree[root][i]]}) 
                        -- Traverse the subtree that begins with the child 
			traverse(tree, tree[root][i], proc_id) 
		end if 
	end for 
end procedure 
 
 
 
traverse(T, 1, routine_id("visit")) 
 

Not exactly optimal, but you get the idea.

new topic     » goto parent     » topic index » view message » categorize

7. Re: quad tree

I don't think I’m explaining things properly
trees do not check for collision with other trees
only the things that move in the game check for collisions with the trees.

i'm uploading my rts game project to the archive so you can take a look for your self
with the name "starcraft beta" it might take some time for it to be visible in the archive.

new topic     » goto parent     » topic index » view message » categorize

8. Re: quad tree

Hello gaz,

I don't know much about games or collisions. I ran your program but didn't study the code.

It looks to me like the bitmap is bigger than the screen.

So you have to move it around to see it all. The truck or man whatever appears to be moving around but

is stationary so you know it's screen X,Y Position. In the default mode (when the game starts)

the left side of a rectangle is showing on the right side of the screen.

You the pixels position with getRect(). If the rectangle is moved 1 pixel toward the left side

of the screen then the X pixels = X pixels-1 and so on. If the rectangle gets too close to the

truck then there's a crash Same with up and down Y pixels. You have to keep track of all the rectangles

you don't want to run into. I don't think you need any complicated math to do this.

Just my observation.

Don Cole

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu