Author Topic: throwing objects  (Read 8223 times)

RoguelikeGCS

  • Newcomer
  • Posts: 16
  • Karma: +0/-0
    • View Profile
    • Roguelike GCS
throwing objects
« on: May 09, 2011, 02:32:58 PM »
One of the problems I'm faced with in the development of my roguelike engine, is how to limit the distance a thrown-object travels, based on the mass of the object. The force applied is fixed, assuming average muscle development of an average 150 pound human male.

I might be tempted to program a fixed threshold, at which point it becomes impossible to throw an object (say, an 800 pound washing machine for example). I don't like this approach because it is unrealistic.

I do not know much about mathematics or physics. I *am* currently studying maths at university (only introductory level). But that could take ages to finish, and it might not provide the knowledge needed to solve this problem.

I'm not asking people to solve it for me, just to point me in the right direction.

What I'm aming for is a function that takes the mass of the object, the force applied, and returns how far in yards the object travels.

Something like this:

Code: [Select]
function(int mass, int force) // force is always the same, but we shouldn't hardwire it, just provide the value as needed
{
    /* math expression */

    return value;
}

purestrain

  • Rogueliker
  • ***
  • Posts: 172
  • Karma: +0/-0
    • View Profile
Re: throwing objects
« Reply #1 on: May 09, 2011, 03:00:55 PM »
You should take the angle of throwing and possible wind speed / directions into account.... maybe it makes the game more fun  ::)

SCNR

Fenrir

  • Rogueliker
  • ***
  • Posts: 473
  • Karma: +1/-2
  • The Monstrous Wolf
    • View Profile
Re: throwing objects
« Reply #2 on: May 09, 2011, 04:33:58 PM »
NASA has all manner of information about flight. This looks like a good place to start. http://www.grc.nasa.gov/WWW/K-12/airplane/ballflght.html For sake of simplicity, there will likely need to be a few more assumptions, just as you assumed an average 150-pound human male.

purestrain, you may be alarmed to discover that developers don't make games just for you, and so they are not likely to desist in their experiments simply because you don't like it.


Z

  • Rogueliker
  • ***
  • Posts: 905
  • Karma: +0/-0
    • View Profile
    • Z's Roguelike Stuff
Re: throwing objects
« Reply #3 on: May 09, 2011, 05:04:03 PM »
It depends on whether you are throwing in a dungeon or in an open space (in the latter case you can throw it at angle of 45 degrees which makes the distance proportional to the square of the initial speed, and in the former you can only throw it roughly horizontally, which makes the distance only proportional to the initial speed). Of course, you can also have dungeons of different heights.

Anyway, distance proportional to force / (mass + m0) is a very simple rule that also agrees with a very simple physical model for open space. I don't know what value of m0 is realistic.

Darren Grey

  • Rogueliker
  • ***
  • Posts: 2027
  • Karma: +0/-0
  • It is pitch black. You are likely to eat someone.
    • View Profile
    • Games of Grey
Re: throwing objects
« Reply #4 on: May 09, 2011, 08:26:31 PM »
purestrain has an extremely valid point that needs to be carefully considered.  There is no such thing as a truly realistic game - more realism often means less fun.  The primary motivation in implementing a feature shouldn't be realism, it should be to add to the enjoyment of the game.  Sometimes the two align and all is well.

When deciding how far a thrown object should reach you have more important considerations like balance.  If characters in your game can throw javelins as far as they can really be thrown then it will be a very very short game indeed.  The same applies to things like visual range, carrying capacity, food requirements, and so on.  These sort of mechanics were never introduced to games for the purposes of realism - they have real gameplay effects, and are normally carefully balanced to be in tune with the gameplay.  The goal of realism is often a perilous pitfall for developers who could instead be spending their time making cool gameplay.

But in answer to the original question, I suggest looking at some real sport records for objects - javelins, shots (the round heavy balls), archery and caber tossing all come to mind.  Don't bother trying to do a fancy formula - it will be utter nonsense, as there are far too many variables involved and assumptions made.  Things like ability to grip, surface area, shape (think boomerangs), spin, drag, angle thrown, thrower skill and so on can all have huge effects.  A simplified system can produce crazy results, like breaking the speed of sound at high strength and low weight, or being able to pick up an object but only able to throw it a few centimetres, which will equate to it simply landing on the same square.  Instead I'd suggest classifying objects into different range categories (perhaps based on weight for certain items) with bonuses applied for x strength, y dexterity and z skill (or whatever equivalents you have in the game).  Aim for it to not go far beyond sport records when maxed, and take careful consideration of game balance at the same time.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: throwing objects
« Reply #5 on: May 09, 2011, 09:34:50 PM »
and returns how far in yards the object travels.

I think it's easier to work with tiles. How many tiles will it travel. You just need to set an average distance that looks nice and "realistic". Then limit min and max distances so nothing can fly to moon or no distance at all, because that kind of looks silly when you throw something and it doesn't fly anywhere.

In my game material also affects the distance if we're talking about the properties of the flying object. Wind resistance will affect to lighter materials like paper.

Some people might wonder why you need all that. Well, it IS the game system, of course.

corremn

  • Rogueliker
  • ***
  • Posts: 700
  • Karma: +0/-0
  • SewerJack Extraordinaire
    • View Profile
    • Demise RogueLike Games
Re: throwing objects
« Reply #6 on: May 10, 2011, 02:47:17 AM »
Some good points above, but what your formula is missing may be aerodynamics.   A javelin will go much further than a ream of paper, even though the weigh the same or a paper plane compared to a piece of paper.

Add a throwing bonus (-5/+5) and a weight bonus (-5/+5) to items, and have a strength bonus from monsters(-5/+x)
Classify items as  feather weight (+5), ... ,moderate (+0), .... heavy, very heavy, extremely heavy (-5)

Distance = item throwing bonus + monster strength bonus + item weight bonus;
So maximum is (10 + strength bonus) spaces, minimum is 0 spaces. Easy.

This is of course just an example, scale it to however you see fit.
Formulas can lead to trouble and predicable behavior.
« Last Edit: May 10, 2011, 02:49:20 AM by corremn »
corremn's Roguelikes. To admit defeat is to blaspheme against the Emperor.  Warhammer 40000 the Roguelike