Jump to content
IGNORED

Random value


tonma
 Share

Recommended Posts

This example should randomize between 0 and 15 + 1

result = ((rand() & 0xf) + 1);

Hopefully we will finally get a Lynx port of this fine game :)

 

Btw. I noticed if you put the number really low, say between 0 and 2 + 1 it's not very reliable and will give the same number over and over.

Edited by Turbo Laser Lynx
Link to comment
Share on other sites

There is actually two functions to "randomize" things.

void __fastcall__ srand (unsigned seed);

Ths srand function sets a seed for the rand() function.

int rand (void);

The rand() function will return the next "random" number. The sequence is always the same. If you set srand(1) then the function rand() will always return the same random numbers.

 

What I do to get really random numbers is to call rand() all the time from the main loop. In this way it changes by itself as the time passes.

Link to comment
Share on other sites

Thanks,

 

It's weird, I'm pretty sure I tested rand() this morning. Anyway, it's works. Never programming with big headache.

 

I'll use rand() in main and maybe a srand(clock()) when I die / restart a level. Thanks too for the range between two numbers ;-)

 

 

 

Hopefully we will finally get a Lynx port of this fine game :)

 

You're serious, you really interested by a flappybird version ?

I'm doing it only for testing the devkit, but finish it doesn't take me too much time. Except for a music, maybe only sound effect like a roaring lynx when you die. :-D

Edited by tonma
Link to comment
Share on other sites

You're serious, you really interested by a flappybird version ?

 

Well maybe I was taking it a bit too far when saying it's a *fine game*, but deep inside I've been a bit bummed that there hasn't been a version of it on the Lynx :D I agree with BadPricey that anything new for the Lynx is nice. Flappy Bird can be pretty fun in small doses at least.

Edited by Turbo Laser Lynx
Link to comment
Share on other sites

Thanks, I'll continue the game. At least, a playable version with random columns.

 

I can't test on real hardware now. I'm waiting for the multicard SD by Saint.

 

 

The other thing I need is adding sound effect. Hum hum, because for the music I really doesn't understand anything. I mean I can't create music at all. Can we convert with a tracker music files like mod or midi ? Or maybe can we play digitized sound effect. I'm in love of "Let's play awesome golf".

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...