• 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
tracegame

how to write a game like worm reloaded

9 posts in this topic

well,right now i can write some physical movement for bullet,that's easy.

but i have no idea for map collision,it seems to perform like pixel collision?maybe not,just my opition.

how can i judge my bullet collide with map?i think i can use brute force to loop my bullet shape pixel with map shape pixel every frame

but that seems too expensive.what should i do to get a nice and effective way?
0

Share this post


Link to post
Share on other sites
Depends on the platform. I'm not sure about Worms, but in most artillery games, you can do simple pixel color check. I did this for a Scorched Earth clone.

You can even have a screen size buffer, so that your collision check becomes simply this:

[font=courier new,courier,monospace]if( ScrnBuffer[x][y] != EMPTY )[/font]
[font=courier new,courier,monospace]{[/font]
[font=courier new,courier,monospace] Explosion!!![/font]
[font=courier new,courier,monospace]}[/font]

Maybe this can be another texture, and you draw to it in a different pass than the actual rendering. then you can lok up the pixel/texel's color.


Please give some more details about the platform, graphics API, etc so that we can give you better ideas. Edited by szecs
0

Share this post


Link to post
Share on other sites
[quote name='BeerNutts' timestamp='1340593256' post='4952527']
Look into a 2d physics engine. I use chipmunk-physics, but others use box2d. Google 'em
[/quote]

They don't have any collision routines for a pixel map.


[quote name='szecs' timestamp='1340541746' post='4952298']
You can even have a screen size buffer, so that your collision check becomes simply this:

if( ScrnBuffer[x][y] != EMPTY )
{
Explosion!!!
}
...
[/quote]

The direct sampling approach is also no good because of tunneling. Projectiles will be on one side of a thin barrier on one frame, and the other on the next.

What you need is to cast a line into the grid, from the previous position of the projectile to its calculated next position. The point of collision is the first pixel that it hits along (the one with the smallest T value). Bresenhams line is one way to do this. Test each pixel that the line passes through until you get a hit.

[url="http://en.wikipedia.org/wiki/Bresenham"]http://en.wikipedia.org/wiki/Bresenham's_line_algorithm[/url]

When an explosion occurs, you can remove pixels from your pixel sized grid to damage the level. For characters walking, a ray cast downward will suffice. Let them fall through gaps of 1px (these will be rare though, if you are blowing holes in the terrain with explosions). You can do a brute force iteration over a square area that covers your circle, doing a distance-from-centre test to ensure you don't fill out the corners. Performance here is acceptable, don't try to optimise that yet.

The last thing you need to remember is to use a grid of smaller textures, don't try to do it with a single huge texture, because you have to modify textures when they get holes blown in them. Textures that stayed intact can be left unmodified. For a basic implementation, this is the only optimisation you really need.
1

Share this post


Link to post
Share on other sites
[quote name='speciesUnknown' timestamp='1340625854' post='4952624']
[quote name='BeerNutts' timestamp='1340593256' post='4952527']
Look into a 2d physics engine. I use chipmunk-physics, but others use box2d. Google 'em
[/quote]

They don't have any collision routines for a pixel map.


[quote name='szecs' timestamp='1340541746' post='4952298']
You can even have a screen size buffer, so that your collision check becomes simply this:

if( ScrnBuffer[x][y] != EMPTY )
{
Explosion!!!
}
...
[/quote]

The direct sampling approach is also no good because of tunneling. Projectiles will be on one side of a thin barrier on one frame, and the other on the next.

What you need is to cast a line into the grid, from the previous position of the projectile to its calculated next position. The point of collision is the first pixel that it hits along (the one with the smallest T value). Bresenhams line is one way to do this. Test each pixel that the line passes through until you get a hit.

[url="http://en.wikipedia.org/wiki/Bresenham"]http://en.wikipedia...._line_algorithm[/url]

When an explosion occurs, you can remove pixels from your pixel sized grid to damage the level. For characters walking, a ray cast downward will suffice. Let them fall through gaps of 1px (these will be rare though, if you are blowing holes in the terrain with explosions). You can do a brute force iteration over a square area that covers your circle, doing a distance-from-centre test to ensure you don't fill out the corners. Performance here is acceptable, don't try to optimise that yet.

The last thing you need to remember is to use a grid of smaller textures, don't try to do it with a single huge texture, because you have to modify textures when they get holes blown in them. Textures that stayed intact can be left unmodified. For a basic implementation, this is the only optimisation you really need.
[/quote]

That's correct, but you can generate the lines under the map to match almost perfectly. And, what you'll gain from the physics library is immense time and brain saving.

The implementation you suggest has many difficulties, whereas the physics engine will handle everything movable for you (walking, shooting, colliding, etc.). The main difficulty with a physics engine is handling creating the craters from explosions. But, I'd say even that can be modified via small line-segments. That's how I'd do it at least.
0

Share this post


Link to post
Share on other sites
[quote name='BeerNutts' timestamp='1340631354' post='4952654']
[quote name='speciesUnknown' timestamp='1340625854' post='4952624']
[quote name='BeerNutts' timestamp='1340593256' post='4952527']
Look into a 2d physics engine. I use chipmunk-physics, but others use box2d. Google 'em
[/quote]

They don't have any collision routines for a pixel map.


[quote name='szecs' timestamp='1340541746' post='4952298']
You can even have a screen size buffer, so that your collision check becomes simply this:

if( ScrnBuffer[x][y] != EMPTY )
{
Explosion!!!
}
...
[/quote]

The direct sampling approach is also no good because of tunneling. Projectiles will be on one side of a thin barrier on one frame, and the other on the next.

What you need is to cast a line into the grid, from the previous position of the projectile to its calculated next position. The point of collision is the first pixel that it hits along (the one with the smallest T value). Bresenhams line is one way to do this. Test each pixel that the line passes through until you get a hit.

[url="http://en.wikipedia.org/wiki/Bresenham"]http://en.wikipedia...._line_algorithm[/url]

When an explosion occurs, you can remove pixels from your pixel sized grid to damage the level. For characters walking, a ray cast downward will suffice. Let them fall through gaps of 1px (these will be rare though, if you are blowing holes in the terrain with explosions). You can do a brute force iteration over a square area that covers your circle, doing a distance-from-centre test to ensure you don't fill out the corners. Performance here is acceptable, don't try to optimise that yet.

The last thing you need to remember is to use a grid of smaller textures, don't try to do it with a single huge texture, because you have to modify textures when they get holes blown in them. Textures that stayed intact can be left unmodified. For a basic implementation, this is the only optimisation you really need.
[/quote]

That's correct, but you can generate the lines under the map to match almost perfectly. And, what you'll gain from the physics library is immense time and brain saving.

The implementation you suggest has many difficulties, whereas the physics engine will handle everything movable for you (walking, shooting, colliding, etc.). The main difficulty with a physics engine is handling creating the craters from explosions. But, I'd say even that can be modified via small line-segments. That's how I'd do it at least.
[/quote]

Physics engines are designed to do one thing well - rigid bodies. If you don't have rigid bodies, attempting to force them to use a different paradigm is not worth the time they will save you. Box2d does not have built in character controllers, and even if it did they would be for use in a rigid body simulation. There is a fine line between sensible code resuse and trying to force a tool to do something it cannot do.

You will spend more time on your line segment hack, and making that support terrain destruction via explosions, than you will save by using the physics engine. You will still have to implement you character controller manually, and you will still need to write the projectile system yourself, to use line segment queries (if you use rigid bodies to simulate projectiles, they will tunnel) Edited by speciesUnknown
0

Share this post


Link to post
Share on other sites
Direct sampling is okay if you have small steps. Of course you can have more sophisticated algorithms, but I was just showing the basic idea.

A bit of context may be useful from the OP. Since small steps could be sufficient enough but could not.
0

Share this post


Link to post
Share on other sites
thank you,i just get the line cast idea this morning when i still in my dream i guess...but still get a problem.
this line cast can check collision only for a single pixel,i mean my bullet or say projectile has a volume,unregular shape,
like grenade,missile, sheep maybe...if i only use a line,consider a thin tunnel,i can pass the line test,but actually my
missile or sheep may be blocked by his shape.

so i think maybe i could cast three lines,one for the center,the other for the edges.just like a box.
but what if there is a nasty map just breaks my rule,which can just pass the three line test,but some small or some fuzzy area between the lines can still block my sheep....

then i have to cast more rays,do i have to?

by the way:the platform is Windows,API is DX9 or FlashPlayer11,i think they're not really different for pixel algorithm Edited by tracegame
0

Share this post


Link to post
Share on other sites
I believe there are techniques where you cast a line that has a thickness equal to the frontal area of the projectile, I've not tried raycasting at all before so couldn't tell you how its done.
0

Share this post


Link to post
Share on other sites
[url="http://www.emanueleferonato.com/2012/05/24/the-guide-to-implementing-2d-platformers/"]http://www.emanueleferonato.com/2012/05/24/the-guide-to-implementing-2d-platformers/[/url]

scroll down to the bitmask section
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