[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] a bit #ot: design for a game board supporting user facing different directions?




On Nov 2, 2011 4:11 PM, "Alex Hall" <mehgcap@xxxxxxxxx> wrote:
> Moving 2 steps, facing 90 degrees. Starting at (0.0, 0.0)
> Now at (2.0, 1.2246468525851679e-16)
>
> What happened to make the second coordinate so far off? TIA.

This is not a very large number, but a very *small* number. Note the negative exponent. This is due to inevitable rounding errors in floating point maths: it's not possible to represent the angle PI/2 perfectly without a tiny amount of rounding. Depending on what you're doing, you can probably ignore it, but you might need to think about margins of error when comparing floating point numbers, and you might want to think about how much precision you want to keep when printing them out.

>
>
> On 10/30/11, DR0ID <dr0id@xxxxxxxxxx> wrote:
> > On 30.10.2011 04:29, Alex Hall wrote:
> >> It is real-time. I don't want it as accurate as movement acceleration
> >> for stepping, at least not yet, but I am not sure how I would manage a
> >> map without a grid. How, for instance, will the computer know where
> >> the player is in relation to objects? If the player fires a weapon,
> >> how can the computer calculate if the projectile will hit a target?
> >> Currently I am planning to manage targeting by getting the slope of
> >> the line and the point of the player, then extending the line to the
> >> weapon's range and seeing if it intersects a point on which there is
> >> an object.
> >> For my game creation I am using the Blastbay Game Toolkit, which is a
> >> subset of C++ but written specifically for use with audio games and
> >> run sort of as a scripting language through an interpreter. For
> >> instance, there is a sound class, a tts class for speaking text,
> >> sound_pool (sort of like a "world" that manages sound positioning
> >> relative to the player), a timer, and so on. Sound_pool, which I
> >> subclass for my Map class, relies on a grid to properly position
> >> sounds, which is the other reason I am using grid-based positioning. I
> >> can't imagine how it would work with no grid. Is there a way?
> >>
> >> On 10/29/11, René Dudfield<renesd@xxxxxxxxx>  wrote:
> >>> Hi,
> >>>
> >>> a few notes, and questions...
> >>>
> >>> Is your game turn based?  Or is it real time?
> >>>
> >>> If you don't have realistic 3d sound, then using a grid is probably
> >>> easier
> >>> for players.
> >>>
> >>> Instead of frame rate, think about it like the update rate of your main
> >>> loop.
> >>>
> >>> Before the player takes a step they are standing.  When standing, speed
> >>> is
> >>> zero.  When stepping, the person gets some acceleration and moves.  Then
> >>> they get some deceleration and stop.
> >>>
> >>> It's more complicated than that, but the more physically accurate you
> >>> want
> >>> it, then more complex your code will be.  If you're more interested in
> >>> making the game, than a physics engine, you might want to consider
> >>> looking
> >>> at one of the physics engines available.
> >>>
> >>> Keeping the game movement to grids might make it easier to play as well
> >>> as
> >>> program.
> >>>
> >>>
> >>> cheers,
> >>>
> >>
> >
> > Hi Alex
> >
> > Do you know about coordinates and vectors (vector math)? This is how it
> > is done in most games. If you make your game grid based, I have not
> > understand if you want just go from one grid cell to another or if you
> > want to allow arbitrary positions in between cells. According to your
> > example it looks to me as if you want to go from one cell to another, so
> > going diagonal would just move you to the next cell diagonally. Of
> > course this means you travel faster because you cover a longer distance
> > (diagonal is sqrt(2) longer) than moving orthogonal. You could restrict
> > movement to just up/down and left/right and not allow diagonal movement
> > at all. If you want to allow diagonal movement then you need to decide
> > if you want to move from cell to cell (where diagonal movement is faster
> > then) or if you want to allow arbitrary positions.
> >
> > I hope it helps.
> >
> > ~DR0ID
> >
>
>
> --
> Have a great day,
> Alex (msg sent from GMail website)
> mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap