GPWiki.org
GPWiki.org
It is currently Sat May 25, 2013 3:42 pm

All times are UTC




Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: What to do next?
PostPosted: Fri Sep 09, 2011 5:52 pm 
Shake'n'Baker
User avatar

Joined: Mon Jun 14, 2010 3:51 pm
Posts: 62
now...lets move to my collision checking problem.

Do you check for collision graphically? I mean by checking if two objects overlap the pixel...

I thought if I have a 2d array keeping record all the objects on the grid, while an object moves the array would be updated accordingly and if an object tries to move to a position which already holds an object, it would detect a collision. Wouldn't this type of collision checking work?


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Fri Sep 09, 2011 6:11 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3810
Location: Ferriday, LA, US
Quack wrote:
Do you check for collision graphically? I mean by checking if two objects overlap the pixel...


It depends -- if you require very precise collision detection, then this would be one option. But, in the situation you describe below...

Quack wrote:
I thought if I have a 2d array keeping record all the objects on the grid, while an object moves the array would be updated accordingly and if an object tries to move to a position which already holds an object, it would detect a collision. Wouldn't this type of collision checking work?


... this would work. If your movements are all strictly grid-based, then grid-based collision detection like you just described would be all you really need.

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Fri Sep 09, 2011 6:13 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6719
Location: Oxford, Englandshire
A simple method for collision detection is bounding boxes.

http://content.gpwiki.org/index.php/VB: ... _Detection

Circular collision is fairly easy too, choose the method that suits your game best.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Thu Sep 22, 2011 4:39 am 
Shake'n'Baker
User avatar

Joined: Mon Jun 14, 2010 3:51 pm
Posts: 62
Well I thought I would use two layers of rendering, first the background map and above it a grid. The background map would have only tiles and no objects, then I would make a grid mimic each tiles height and draw object on grid. A static background and a dynamic grid foreground, but so far there are few problems I got stuck on.

First is the height of the grid tiles. I know tileWidth = 2 * tileHeight, but what about elevated tiles?
I thought if height = 1, I would raise the tile by half of tileHeight and so on. And it gives me this.
Image
Zero height....ignore the rock and the green filled tiles is because the mouse was over it.
Image
height = 1 works fine, mouse picking works.
Image
But height = 2 is bad, it completely overlaps the top-most tile.
That's my first problem.

And because of the two layers I always have to clear two overlapping objects, like
Image
It works fine right? But the clearing algorithm also clears translated objects. Suppose that rock is moving to the next x-index. And visually...
Image
This happens! I think I need to work with pixel clearing algorithm, but how? Height = 1 over laps 3 upper tiles at least.
This here is my second problem.

Or you could question my 2 layered concept, and tell how you folks do it?


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Fri Aug 10, 2012 9:57 am 
The easiest way to do this is to use 3D (OpenGL or DirectX) to do the drawing. You can have an 'isometric' game by using an Orthographic_projection, that way you don't have to worry about tiles overlapping. Also tile 'picking' is relatively simple.


Top
  
 
 Post subject: Re: What to do next?
PostPosted: Mon Sep 10, 2012 3:39 pm 
Cubic Contributor
User avatar

Joined: Sun Aug 05, 2012 9:32 pm
Posts: 72
I am not sure I fully understand whats happening in the last one, but can't you make it so each layer of tiles (layer == height) would be a different array? Then your objects could track which layer are they on, and render based off that. Also if, lets say, the player walks behind a "mountain" (which are bunch of tile layer higher then the player) then every layer above the player would be rendered sami-transparent (example, alpha 35 or so), that would make everything behind the mountain or house or tree visible to the player. This might require you to rewrite some of the code so I am posting it only as an /Idea/. But if you could explain what is the "clearing algorithm" doing exactly, we might be able to help further with your original code.

_________________
Did you ever wonder, how time works?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group