Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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  
  Sniper Scope view (no zoom)  (Read 2269 times)
0 Members and 1 Guest are viewing this topic.
Offline Swattkidd7

Junior Member





« Posted 2011-07-25 08:09:57 »

Hey guys I was wondering how I could go about making the map only visible through the players "sniper scope" the game is top down, so they would only see through a circle that they can move around, as if they are looking through the scope searching for players.

Any ideas on how to implement this? I just cant figure out how to black out everything outside of the "scope"/circle.

Thanks in advance!
Offline Z-Man
« Reply #1 - Posted 2011-07-25 09:29:37 »

Well if you aren't gonna allow the game window to be resized then you could just have an image that you draw over everything. If you want to allow resizing then you could create the image of the "scope" everytime the window is resized. I'm not entirely sure if either of these are the best way though since I've never tried doing that, and it's about 4am here xD

Good luck, I hope my suggestions at least help you think of something.
Z-Man
Offline Swattkidd7

Junior Member





« Reply #2 - Posted 2011-07-25 09:38:00 »

thanks for the response, I was actually thinking about implementing it the way you are saying but my problem is I dont want the scope to stay in the center of the screen, I want it to move with the mouse you know what I mean? so if I were to just draw an image, the scope would always be in the middle which is not exactly what I am going for..but once again thanks for the idea!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline nsigma
« Reply #3 - Posted 2011-07-25 10:18:19 »

You could try drawing the scope in white on a full-screen black image and then using a multiply blending mode to composite over your background image.  If you're working directly with arrays of pixels you could check out this recent thread http://www.java-gaming.org/topics/some-new-blendmodes-add-multiply-overlay-etc/24529/view.html, or if you're just using Java2D then have a look at http://filthyrichclients.org/ -> Examples -> Chapter 6 which has a lot of additional blend modes for use with Graphics2D.setComposite().  The straight array mode will be faster, but the FRC code might be easier.

You might also try (less sure about this one) drawing your scope on a full screen transparent image and then setting the composite to AlphaComposite.DestIn before drawing it on top of your background.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline kevglass

JGO Kernel


Medals: 159
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #4 - Posted 2011-07-25 10:22:03 »

Or you could create an java.awt.geom.Area, subtract a java.awt.geom.Ellipse and then draw it filled across the screen in black, it'd probably quite cheap.

Kev

Offline nsigma
« Reply #5 - Posted 2011-07-25 10:48:50 »

Or you could create an java.awt.geom.Area, subtract a java.awt.geom.Ellipse and then draw it filled across the screen in black, it'd probably quite cheap.

Kev
Oh yeah!  For some reason I was expecting the scope to be an image rather than just a plain circle, despite the fact the OP distinctly used the word "circle"  Roll Eyes

Depending on the other drawing you're doing it might also be worth clipping the background rendering to the bounding rectangle of the Area / scope as well - seems pointless to draw things that are going to end up black.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Swattkidd7

Junior Member





« Reply #6 - Posted 2011-07-25 11:03:14 »

Or you could create an java.awt.geom.Area, subtract a java.awt.geom.Ellipse and then draw it filled across the screen in black, it'd probably quite cheap.

Kev

Thanks! I was thinking about this but thought it might be too much, however I will definitely take your word for it!

**Implemented it and it worked beautifully! Thank you very much once again to everyone that responded, and to KevGlass for the solution that worked out best for me.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

Nickropheliac (16 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (42 views)
2014-08-19 09:29:53

Tekkerue (41 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (26 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
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!