• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Marko T

Hitbox on irregular objects

10 posts in this topic

Depends if you want a bounding box (find max/min x and y extents of the object), or if you want an irregular shaped region, in which case you want a point in polygon test, here's one in Java

 

http://stackoverflow.com/questions/8721406/how-to-determine-if-a-point-is-inside-a-2d-convex-polygon

 

and that also mentions this:

 

The java.awt.Polygon class has a number of contains(...) methods if you use Polygon objects to represent your polygon.

Edited by Paradigm Shifter
0

Share this post


Link to post
Share on other sites

Vastrolorde, you will need to provide more information as to what you are trying to accomplish, what you have tried and how you are hoping to solve your problem.  Perhaps try to define what you mean by irregular objects, what engines and or libraries are you using?

0

Share this post


Link to post
Share on other sites

Im using the standard JDK. and ima lasousing java swing. Im trying to accoplish thet i can shoot through the tenticles to hit the eye. Atm it jsut hit the rectangle edge that surrounds the creature.

[sharedmedia=gallery:images:3637]

Hitbox for this
0

Share this post


Link to post
Share on other sites

You're probably going to be better off if you split the enemy up into 3 sections... top bit, eye part and bottom bit, with separate collision for each bit (presumably it only takes damage if you hit the eye). You can probably just use rectangle collision for the 3 parts then.

0

Share this post


Link to post
Share on other sites

If you want to use rectangles, yes. You could also use a hierarchy of rectangles that fits the shape better. I suggest different objects since the collision is probably handled differently for the eye vs. rest of the enemy.

 

Or you could use a polygon collision method, I linked to some code for that in my first post.

0

Share this post


Link to post
Share on other sites

OK. i think i can use the polygon. is there a way to automatically get the X and Y coordinates for my shape or do i have to get em manually?

0

Share this post


Link to post
Share on other sites

Or do you have a better suggestion for getting the x and Y coords, cause manually getting em would be quite hard and my monster also moves around

0

Share this post


Link to post
Share on other sites

You mean the texture animates?

 

You could do pixel perfect collision if you looked up the texture at the bullet hit position, read the source texture x,y after mapping the bullet position into it and if it isn't the background colour it has hit. You could also use another separate texture with colour coded "what have you hit" info as well (so you could use one colour for "tentacle" and another for "eyeball", say).

 

It's easiest to have a single "hit position" for the bullet since you only have to do 1 lookup on the texture rather than read a whole bunch of pixels from the enemy texture.

 

Someone asked a question about computing the 2D concave hull of an image in the maths & physics forum, you may want to look at that thread in case something relevant to your problem pops up.

0

Share this post


Link to post
Share on other sites

Can i do pixel perect collision with imageicon or do i need to use buffered image?

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0