Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: fast trig....thumb....rand   Message List  
Reply | Forward Message #11212 of 15019 |
Re: [gbadev] Re: fast trig....thumb....rand

Hello colinraybrown,

Monday, April 29, 2002, 9:34:45 PM, you wrote:

> --- In gbadev@y..., Phil Stroffolino <pstroffo@y...> wrote:
>> >First off, does anyone have a free fast arctan algorithm, I've
> been
>>
>> No, but if you are simply looking to steer bullets, you can just
>> normalize the deltas.
>>
>> dx = pEnemy->x - pPlayer->x;
>> dy = pEnemy->y - pPlayer->y;
>> dx = dx*dx;
>> dy = dy*dy;
>> distance = dx+dy; /* make sure to account for distance==0 */
>> dx = (dx<<8)/distance; /* #.8 fixed point */
>> dy = (dy<<8)/distance;
> yeah, this would work ok and was my first thought as well, but there
> are 2 divides which aint so cool for gba :(
You can try to convert this to one divide and two multiplications
(calculte reciprocal). This was faster on old PCs and I guess this
rule also holds for GBA. Also, if you know that your distances are
limited you can try to use look-up table and avoid division (I do it
this way in my texture-mapper, no divisions at all).

--
cheers,
-Maciej







Tue Apr 30, 2002 10:22 am

yarpen2002
Offline Offline
Send Email Send Email

Forward
Message #11212 of 15019 |
Expand Messages Author Sort by Date

... No, but if you are simply looking to steer bullets, you can just normalize the deltas. dx = pEnemy->x - pPlayer->x; dy = pEnemy->y - pPlayer->y; dx =...
Phil Stroffolino
pstroffo
Offline Send Email
Apr 29, 2002
2:14 pm

... Hmm, if you ignore the lsb bits yeah, but this method is really not that "random looking". LCGs are just too regular to be that usefull. Tom ...
tom st denis
tomstdenis
Offline Send Email
Apr 29, 2002
4:44 pm

... been ... yeah, this would work ok and was my first thought as well, but there are 2 divides which aint so cool for gba :( At a guess I could probably get a...
colinraybrown
Offline Send Email
Apr 29, 2002
8:53 pm

Hello colinraybrown, ... You can try to convert this to one divide and two multiplications (calculte reciprocal). This was faster on old PCs and I guess this ...
Maciej Sinilo
yarpen2002
Offline Send Email
May 2, 2002
9:24 am

... Why would you ignore the lsb bits? The msb bits overflow into the lsb bits each iteration. There's nothing "less random" about the msb bits. As for the...
Phil Stroffolino
pstroffo
Offline Send Email
Apr 29, 2002
11:10 pm

... First off no, the msb bits do not flow into the lsb bits. In fact a bit at position I will not affect a bit at position I-1. Multiplications modulo 2^k...
tom st denis
tomstdenis
Offline Send Email
Apr 30, 2002
11:26 am

From: "tom st denis" <tomstdenis@...> ... The output of an LCG needs to be taken as a whole, not as individual bits. Using the value obtained as a...
John Seghers
johnse98072
Offline Send Email
Apr 29, 2002
11:17 pm

From: "Phil Stroffolino" <pstroffo@...> ... I did a quick search about this... All the LCG's I found using a multiplier of 16807 used a modulo of...
John Seghers
johnse98072
Offline Send Email
Apr 29, 2002
11:47 pm

... well, i just tried it out and without >>16 the results aren't random whatsoever :) and to increase randomness you can call it once every time the player ...
Markus Glanzer
vampy2000.geo
Offline Send Email
Apr 30, 2002
11:43 am

Hello Markus, ... MG> well, i just tried it out and without >>16 the results aren't random MG> whatsoever :) MG> and to increase randomness you can call it...
groepaz
groepaz2000
Offline Send Email
Apr 30, 2002
1:16 pm

... Umm? No? This is known as a Linear Feedback Shift Register or LFSR and the normal course of operation is to take the LSB [or MSB depending on how you...
tom st denis
tomstdenis
Offline Send Email
Apr 30, 2002
2:59 pm

Hello tom, Tuesday, April 30, 2002, 4:43:46 PM, you wrote: tsd> Don't get me wrong guys, alot of your suggestions will work such as the tsd> LCG or this LFSR....
groepaz
groepaz2000
Offline Send Email
Apr 30, 2002
3:31 pm

... Er. They can? That seems kind of ghetto. Is there a reasonable way to implement a class for PRNGs that can intercept bad initialization sequences and...
Fatty diZilla
johnisaheadcase
Online Now Send Email
Apr 30, 2002
11:53 pm

or you can read state of player button in rand function xoring or something like in your seed value, this work for me. Keywiz [cropped by mod]...
Pablo Testa
pablo_testa@...
Send Email
Apr 30, 2002
3:27 pm

... He wasn't saying that it was an LSB. He was just saying that it was good enough for him. ... I'm tempted to go into a crypto newsgroup and start telling...
Fatty diZilla
johnisaheadcase
Online Now Send Email
Apr 30, 2002
11:52 pm

... well, I searched the archives carefully and didn't find RNG code like this :-| do you have a note of the eor-constant for 32bit (any other too) pretty...
colinraybrown
Offline Send Email
May 2, 2002
8:36 am

Hello colinraybrown, Wednesday, May 01, 2002, 3:54:40 AM, you wrote: c> --- In gbadev@y..., groepaz <groepaz@g...> wrote: c> well, I searched the archives...
groepaz
groepaz2000
Offline Send Email
May 2, 2002
9:53 am

... Or just use a decent PRNG. I mean if you are going to use a LCG then at least use one with a C constant... e.g. of the form rnd = rnd * B + C Personally...
tom st denis
tomstdenis
Offline Send Email
Apr 30, 2002
1:25 pm

dx = pEnemy->>x - pPlayer->x; dy = pEnemy->>y - pPlayer->y; PS> dx = dx*dx; PS> dy = dy*dy; PS> distance = dx+dy; /* make sure to account for distance==0 */ ...
porneL
pornelkurna
Offline Send Email
Apr 30, 2002
1:26 pm

... ?isn't there still a divide in that atan2 function? ... gives a little variation in bullet speed - very nice. (another "now why didn't I think of that?"...
colinraybrown
Offline Send Email
May 1, 2002
12:39 am

... c> ?isn't there still a divide in that atan2 function? Yes, there is one. But its the fastest method to calculate (accurate) unit vector I know. ... c> :)...
porneL
pornelkurna
Offline Send Email
May 3, 2002
8:29 am

... Thanks might try this, but for just aiming bullets the cheap and dirty one is great. ... as long as the compiler uses an asr (arithmetic shift right), is ...
colinraybrown
Offline Send Email
May 3, 2002
9:30 pm

Hello colinraybrown, ... From my experiences it seems that this depends on variable type (signed/unsigned). -- cheers, -Maciej...
Maciej Sinilo
yarpen2002
Offline Send Email
May 4, 2002
3:23 pm

... The old cliche "horses for courses" comes to mind. Not to disparage your crypto background but, realistically, we're talking about a games console here -...
Andrew Scott
dingthasucka
Offline Send Email
Apr 30, 2002
11:50 pm

... I can imagine quite a few other uses for the GBA. For example, a portable packet radio terminal :-) ... Yeah, I have to agree here. Going over board is...
tom st denis
tomstdenis
Offline Send Email
May 1, 2002
12:09 am

... There's a typo which Tom pointed out - the correct expression is: gSeed = (16807*gSeed)%0x7fffffff Which unfortunately isn't fast at all on a GBA. ...
Phil Stroffolino
pstroffo
Offline Send Email
May 2, 2002
3:37 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help