Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  Only show overlapping portion of shape (LibGDX)  (Read 266 times)
0 Members and 1 Guest are viewing this topic.
Offline devinjv

Junior Newbie


Exp: 4-6 months



« Posted 2014-04-30 00:16:50 »

So I'm stuck again Hopefully someone can help

I'm working on my first app, a 2d side-scroller. It's a bat in a cave and he will shoot out a Circle shaped sonar. I want this circle to be generally invisible and only show the parts of it that are overlapping my triangular "Polygon" objects (cave spikes). I looked through the LibGDX documentation and had trouble finding a way of locating coordinates of the point where shapes are overlapping. Any quick tips would be awesome to get me in the right direction.
Online UprightPath
« Reply #1 - Posted 2014-04-30 02:10:22 »

You could always do a mask. Basically, you invert the screen-- Locations with triangles become gaps and gaps gain triangles-- then you set up layers such that (From near camera to furtherest): Player/UI (Very top/always visible objects), Mask (As described), the Sonar, the spikes (If you have a reason to draw them at all, I mean.)

This is probably the easiest method. And I use that term lightly. Alternately, you can try something involving polygon clipping (But a circle can be a PITA because it's either not a real polygon or it's a polygon with infinite vertices-- Or just a bunch): http://en.wikipedia.org/wiki/Weiler-Atherton_clipping_algorithm

Offline devinjv

Junior Newbie


Exp: 4-6 months



« Reply #2 - Posted 2014-04-30 04:56:02 »

Thanks for your reply! The way you described masking sounds like exactly what I'm going for. Just having some trouble finding more information on the topic. Will keep looking.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ikovrigin

Senior Newbie





« Reply #3 - Posted 2014-04-30 05:05:49 »

This can be done using shader. Just use center and R of sonar as a parameter. This is if you want use precise calculation. In other hand if it is your first game just simplify this problem.
1. You can calculate distance for each vertex and interpolate values inside triangle.
2. You can draw cave spike if it's center inside a sonar circle.
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (24 views)
2014-09-19 03:14:18

Dwinin (39 views)
2014-09-12 09:08:26

Norakomi (68 views)
2014-09-10 13:57:51

TehJavaDev (93 views)
2014-09-10 06:39:09

Tekkerue (47 views)
2014-09-09 02:24:56

mitcheeb (68 views)
2014-09-08 06:06:29

BurntPizza (51 views)
2014-09-07 01:13:42

Longarmx (38 views)
2014-09-07 01:12:14

Longarmx (44 views)
2014-09-07 01:11:22

Longarmx (40 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!