Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to implement AOE2 obscured sprite outlines?  (Read 4881 times)
0 Members and 1 Guest are viewing this topic.
Offline Themroc

Junior Devvie





« Posted 2002-11-22 07:05:39 »

If you don't know: Age Of Empires 2 is a 2D game with an isometric view.  Some buildings are quite large, so unit-sprites can be obscured by them. If a unit is obscured it will be shown only with its outline on the building image, the outline has the player color.
Interesting is, that if a unit is only half obscured, then only that part that is obscured is represented by an outline.  This seems to work pixel-perfect.
I think that is a nice solution that no units are forgotten behing buildings and it looks good.

Now I asked myself how to implement his. I would draw units and bulings according to their depth-position. Whenever a building is drawn I would check if it obscures some units. Then i would draw the outline of the units, but masked by the building image, so the outline is not drawn on the visible part of the unit.
But as far as I can see java has no drawImage() with masking.
I tested Graphics.setClip(), but that is not what I wanted. It only works with shapes  and gets real slow for complex shapes. A setClip(Image) would be cool.

So is there a way to do quick masking draImage()? Or is there another way to implement this outline drawing?
Offline Pops

Senior Newbie




I love YaBB 1G - SP1!


« Reply #1 - Posted 2002-11-22 13:40:12 »

Just an idea - why not draw in this order (this assumes the outline is part of the sprite itself):
1) Sprite
2) Building
3) Outline of sprite

The sprite get's painted, then may get overlaid by the building if obscured then the building is overlaid by the outline (and the fills out the visible sprite).
Offline Themroc

Junior Devvie





« Reply #2 - Posted 2002-11-22 14:50:02 »

Quote
Just an idea - why not draw in this order (this assumes the outline is part of the sprite itself):


Welll, I have not yet decided if the outline should be part of the sprite itself.  That would make things easy, but I think  it would look less good. At least in AOE2 outlines are not part of the sprite, and I would prefer if I could avoid making the outline part of the sprite, too.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
8: Undefined index: online
File: /home/jgo/public_html/Themes/default/Display.template.php (main sub template - eval?)
Line: 161