Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kevinkore3

Pages: [1] 2 3 4
1
TI-Nspire / Re: Is this forum dead?
« on: April 18, 2016, 08:20:28 pm »
Dead?, No. Slow definitely. It will become a self fulfilling prophecy if people don't contribute though. The only way for their to be activity is for people to work on projects and actively post. And yea, it seems Codewalrus was a large part of our specific drop in activity, though our falling out with TI Planet didn't help either. You will see that most of the members from there don't post here anymore either.

Yeah, it seems like none of the French users visit anymore and all of the English speaking users moved to Codewalrus. What happened with the TI-Planet break anyway? I heard critor got offended or something like that, but I don't know the details. Also, why exactly was Codewalrus created? It just seemed to fracture the community more. I noticed Codewalrus lists TI-Planet as an affiliate but doesn't list omnimaga as on (which is kind of odd, because DJ O founded Codewalrus).

I would program stuff, but I don't really have time to make any big projects, and no one is interested in small projects like maze generators. In addition, Nspire GCC on Windows is pretty buggy and doesn't include stdlib.

2
TI-Nspire / Re: Is this forum dead?
« on: April 18, 2016, 01:01:28 am »
Looking at the post graph, it seems like the activity stayed relatively stable during 2013 (100 posts/day) until the end of 2014, when it nosedived to around 20 posts/day, and now it seems like it's at 10 posts/day. RIP Omnimaga. Any idea on why the post count decreased so rapidly at the end of 2014?
That's when CodeWalrus was born

Even so, at this rate omnimaga is set to have around 250 new posts in 2016, which is considerably less than the amount in 2015.
Even the numbers by month are disappointing:
January: 35
February: 24
March:16
April (over half gone): 8

3
TI-Nspire / Is this forum dead?
« on: April 18, 2016, 12:39:43 am »
It seems like there are pretty much no new projects here. I've looked at the Omnimaga stats for post activity, and it seems like the whole site is getting a lot smaller (people probably would rather play games on a smartphone than a calculator - the decline in activity strongly correlates with the rise of the smartphone). This forum in particular hasn't really had any major projects for a while, even though it used to be relatively active when I joined in 2013.

TI will keep updating the OS and try to block Ndless. From my observations, it seems like it takes a considerable amount of work to find a loophole to install Ndless, and as the amount of people here gets ever smaller, the chance of finding a loophole will decrease. If Ndless isn't available on new calculators, there will be no new members, and C++ projects (which tend to be the most fun because they get the most out of the CPU) won't be usable, so no one will visit anymore. No GBA emulators, no crafti, etc.

In addition, nobody will create projects if nobody will use them. It seems like no one is downloading projects, which doesn't encourage programmers at all.

So can we officially wave goodbye to TI-Nspire programming? There doesn't really seem to be a good solution to revitalize this forum. It seems like TI-Nspire programming is a thing of the past now when smartphones are plentiful. It seems like the whole site, along with all the other calculator programming sites, will die pretty soon when people ditch calculator gaming in favor of smartphones.

Thoughts?

Looking at the post graph, it seems like the activity stayed relatively stable during 2013 (100 posts/day) until the end of 2014, when it nosedived to around 20 posts/day, and now it seems like it's at 10 posts/day. RIP Omnimaga. Any idea on why the post count decreased so rapidly at the end of 2014?

4
Calculator C / Accessing the OS?
« on: May 06, 2015, 10:29:41 pm »
Is there a way to access the OS functions?
E.g. implement non-integer factorials.
Right now I have to type in an integral to get 5.8!
TI-BASIC is too slow, and an Ndless program takes tons of work (well, enough that I haven't really finished any yet).
I also want to add some functions that appear on the Prime and maybe increase the max number limit to above 10^999 (GMP for Nspire? Probably not, we'll see).
Can this be done?
Thanks.

5
Calculator C / Communicating between 2 nspires
« on: April 22, 2015, 10:47:45 am »
Is there a way to send information between 2 nspires that are linked using Ndless?

e.g. transferring variables

6
Calculator C / Re: Key presses
« on: April 04, 2015, 05:45:50 pm »
On another note, is it possible to get fstream working? I'm missing basic_string.tcc (and probably other things) on my Windows machine, and my Linux laptop makes super large bogus a.outs that don't run.

7
Calculator C / Key presses
« on: March 31, 2015, 10:01:47 pm »
There is the isKeyPressed function, but that only detects the state of the key.
Say, for example, open a text editor and hold a key. One character will show up at first, then after half a second or so a bunch will start showing up rapidly.
Is there a function to capture this type of input in the SDK or should I implement one?
I'm curious because in a program I'm making I'm using tabs to loop through things, but it just loops through everyone really fast.

8
TI-Nspire / Mazes
« on: March 04, 2015, 10:52:03 am »
Here's a simple maze generator.
It's still buggy.
Works fine on emu, but haven't tested it on my calculator yet.
n2dlib was the simplest thing around, so I just used it for this project.

2048 included too because I was bored.

9
TI-Nspire / Re: KuroRPG - RPG Maker - Demo released
« on: September 07, 2014, 03:45:11 pm »
Interesting, but it will be sad if a ton of game makers come out for nspire, because then it would become pointless to actually program games.
Not really.
The Nspire's 132MHz CPU can't handle much, and most game makers I know have lots of overhead.

10
Calculator C / Re: good random numbers
« on: June 25, 2014, 09:48:13 pm »
I know my source code kind of sucks. I used getlength because people said logs were lots slower (dunno if that's true, but it had lots of thumbs ups and I'm not taking risks at 132mhz) I know there are lots of bigger things to optimize, but this was an easier one to do
As for the 1* and 1.1*, I was also thinking that it should give the same result, but it didn't. As for the money thingy,  I have no idea why I put it there :P  probably wasn't thinking (do I need any pointers?)
For the cargo thingy, there is no pattern to how much each item costs, so I decided against a loop.
I will clean up the source after I finish.
Anyone have any idea about the weird multiplying glitch? If I do +=40 it gets jerky.
I'm happy that it runs and gets decent fps at least  :D
Thanks for the suggestions

11
Calculator C / Re: good random numbers
« on: June 21, 2014, 02:13:03 pm »
Sorry for all the posts, but I have another problem :L
Code: [Select]
player.position_x=player.position_x_temp-player.drillcount/player.drillmax;
doesn't do anything because drillmax>drillcount, so drillcount/drillmax=0, but
Code: [Select]
player.position_x=player.position_x_temp-20*player.drillcount/player.drillmax;
moves the player 40 pixels to the left (which is very strange because it should be at most 20)

I tested
Code: [Select]
player.position_x=player.position_x_temp-1.1*player.drillcount/player.drillmax;and it also moves the player 40 pixels to the left ???
Code: [Select]
#include <os.h>
#include <SDL/SDL.h>
#include <ctime>
#include <cmath>
#include "blocks.cpp"
#include "player.cpp"
#define score_color 0x8000
#define spacing 12
uint32_t *money=0;
uint16_t tempint;
uint16_t chance[18];//for ore generation
uint8_t getlength(int score)
{
   uint8_t scorelength;
   while(1)
   {
      if(score>9)
      {
         if(score>99)
         {
            if(score>999)
            {
               if(score>9999)
               {
                  if(score>99999)
                  {
                     scorelength=6; //gl reaching 7 digits
                     break;
                  }
                  scorelength=5;
                  break;
               }
               scorelength=4;
               break;
            }
            scorelength=3;
            break;
         }
         scorelength=2;
         break;
      }
      scorelength=1;
      break;
   }
   return scorelength;
}
void shownumber(SDL_Surface *screen,uint32_t score,uint8_t scorelength)
{
   uint8_t tempscore;
   score*=10;
   for(int i=0;i<scorelength;i++)
   {
      score/=10;
      tempscore=score%10;
      switch(tempscore)
      {
         case 0:
            for(int z=0;z<15;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i,z,score_color);
               nSDL_SetPixel(screen,315-spacing*i,z,score_color);
            }
            for(int z=1;z<11;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i+z,0,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,14,score_color);
            }
            break;
         case 1:
            for(int z=0;z<15;z++)
            {
               nSDL_SetPixel(screen,310-spacing*i,z,score_color);
            }
            break;
         case 2:
            for(int z=0;z<11;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i+z,0,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,7,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,14,score_color);
            }
            for(int z=0;z<8;z++)
            {
               nSDL_SetPixel(screen,315-spacing*i,z,score_color);
               nSDL_SetPixel(screen,305-spacing*i,7+z,score_color);
            }
            break;
         case 3:
            for(int z=0;z<15;z++)
            {
               nSDL_SetPixel(screen,315-spacing*i,z,score_color);
            }
            for(int z=0;z<10;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i+z,0,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,7,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,14,score_color);
            }
            break;
         case 4:
            for(int z=0;z<15;z++)
            {
               nSDL_SetPixel(screen,315-spacing*i,z,score_color);
            }
            for(int z=0;z<10;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i+z,7,score_color);
            }
            for(int z=0;z<7;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i,z,score_color);
            }
            break;
         case 5:
            for(int z=0;z<7;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i,z,score_color);
               nSDL_SetPixel(screen,315-spacing*i,7+z,score_color);
            }
            for(int z=0;z<10;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i+z,0,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,7,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,14,score_color);
            }
            break;
         case 6:
            for(int z=0;z<10;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i+z,0,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,7,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,14,score_color);
            }
            for(int z=0;z<15;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i,z,score_color);
            }
            for(int z=0;z<8;z++)
            {
               nSDL_SetPixel(screen,315-spacing*i,7+z,score_color);
            }
            break;
         case 7:
            for(int z=0;z<15;z++)
            {
               nSDL_SetPixel(screen,315-spacing*i,z,score_color);
            }
            for(int z=0;z<10;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i+z,0,score_color);
            }
            break;
         case 8:
            for(int z=0;z<10;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i+z,0,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,7,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,14,score_color);
            }
            for(int z=0;z<15;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i,z,score_color);
               nSDL_SetPixel(screen,315-spacing*i,z,score_color);
            }
            break;
         case 9:
            for(int z=0;z<10;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i+z,0,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,7,score_color);
               nSDL_SetPixel(screen,305-spacing*i+z,14,score_color);
            }
            for(int z=0;z<8;z++)
            {
               nSDL_SetPixel(screen,305-spacing*i,z,score_color);
            }
            for(int z=0;z<15;z++)
            {
               nSDL_SetPixel(screen,315-spacing*i,z,score_color);
            }
            break;
      };
   }
}
enum blocktype
{
   nothing=0,
   dirt=1,
   coal=2,
   iron=3,
   tin=4,
   copper=5,
   silver=6,
   gold=7,
   platinum=8,
   topaz=9,
   sapphire=10,
   emerald=11,
   ruby=12,
   opal=13,
   jade=14,
   diamond=15,
   fossil=16,
   artifact=17,
   sigsegv=18,
   lava=19,//visible but does lots of damage
   rock=20,//you have to blow these up with explosives
   gas=21//invisible and blows up if you run into it
};
blocktype map[600][40];//motherload is something like 12 feet a block-1 block is 20 pixels
//less than 100kB anyway, no point using push_back so often
enum currentdirection
{
   down=0,
   right=1,
   left=2,
   up=3
};
class theplayer
{
public:
   bool is_flying;
   SDL_Rect rect_player_centered;
   SDL_Rect rect_player_animation_source;
   uint16_t drillmax;
   uint16_t drillcount;
   uint8_t animationcount;
   bool is_active;
   currentdirection direction;
   int8_t acceleration;
   int16_t position_x;//in pixels
   int16_t position_x_temp;
   int16_t depth;//in pixels
   int16_t depth_temp;
   uint8_t hull;
   uint8_t hullhealth;
   uint8_t drillspeed;
   uint8_t drill;
   uint16_t fueltank;
   uint16_t fuel;//every loop-1L=100 loops=2 seconds at 50FPS
   uint8_t engine;
   uint8_t enginepower;//max pixels/second lift
   uint8_t cargobay;
   uint16_t cargocapacity;//in cubic feet
   uint8_t cargo[18];//each element represents how many of a certain type
   //for example, element 0 represents coal, which is the second item in the enum
   theplayer()
   {
      acceleration=0;
      depth_temp=0;
      drillmax=0;
      drillcount=0;
      animationcount=0;
      is_active=0;
      direction=right;
      depth=0;
      position_x=100;
      hull=1;
      hullhealth=10;
      drill=1;
      drillspeed=10;
      fueltank=1;
      fuel=150;
      engine=1;
      enginepower=3;
      cargobay=1;
      cargocapacity=10;
      rect_player_centered.x=156;//player's position drawn on the screen, always centered
      rect_player_centered.y=106;
      rect_player_centered.w=28;
      rect_player_centered.h=28;
      rect_player_animation_source.x=0;
      rect_player_animation_source.y=0;
      rect_player_animation_source.w=28;
      rect_player_animation_source.h=28;
      for(int i=0;i<15;i++)
      {
         cargo[i]=0;
      }
   }
   void sell_cargo()
   {
      *money+=30*cargo[0];//coal is worth 30
      *money+=50*cargo[1];//iron is worth 50
      *money+=80*cargo[2];//tin is worth 80
      *money+=120*cargo[3];//copper
      *money+=200*cargo[4];//silver
      *money+=400*cargo[5];//gold
      *money+=750*cargo[6];//platinum
      *money+=1000*cargo[7];//topaz
      *money+=1200*cargo[8];//sapphire
      *money+=2000*cargo[9];//emerald
      *money+=3500*cargo[10];//ruby
      *money+=5000*cargo[11];//opal
      *money+=8000*cargo[12];//jade
      *money+=20000*cargo[13];//diamond
      *money+=10000*cargo[14];//fossils
      *money+=15000*cargo[15];//artifacts
      *money+=100000*cargo[16];//sigsegv lol
      for(int i=0;i<15;i++)
      {
         cargo[i]=0;
      }
   }
};
void newrow(uint16_t row)
{
   chance[0]=1000/(abs(pow(row-10,1.1))+50);//1000/(abs(pow(row-row_where_it_is_most_common,range_of_how_common_it_is))+100/percent_of_blocks_in_most_common_row)
   //coal is found with a frequency of 100/50=2% of blocks in the row in which it is most commonly found
   //coal is most commonly found in row 10 (actually 11 in the array, but 1 more or less doesn't make a huge difference)
   //coal is commonly found in a large range of blocks, note the low exponent
   //note that 0 in this array corresponds to 2 in blocktype
   chance[1]=1000/(abs(pow(row-30,1.1))+60);//iron is found in 1.667% or 16/1000 blocks in the generator at max, and is also very common
   chance[2]=1000/(abs(pow(row-50,1.1))+80);
   chance[3]=1000/(abs(pow(row-80,1.1))+20);
   chance[4]=1000/(abs(pow(row-110,1.3))+100);
   chance[5]=1000/(abs(pow(row-150,1.5))+150);
   for(int i=0;i<40;i++)
   {
      tempint=rand()%1000;
      for(int z=0;z<7;z++)
      {
         if(z==6)
         {
            if(rand()%8)
            {
               map[row][i]=dirt;
               break;
            }
            map[row][i]=nothing;
            break;
         }
         if(chance[z]>tempint)
         {
            map[row][i]=(static_cast<blocktype>(z+2));
            break;
         }
         tempint-=chance[z];
      }   
   }
}
int main()
{
   srand(time(NULL));
   uint8_t intlength;
   SDL_Init(SDL_INIT_VIDEO);
   SDL_Surface *screen=SDL_SetVideoMode(320,240,16,SDL_SWSURFACE);
   nSDL_Font *font=nSDL_LoadFont(NSDL_FONT_VGA,0,64,0);
   SDL_Surface *sprite_blocks=nSDL_LoadImage(image_blocks);
   SDL_Surface *sprite_player=nSDL_LoadImage(image_player);
   SDL_SetColorKey(sprite_blocks,SDL_SRCCOLORKEY,SDL_MapRGB(sprite_blocks->format,0xff,0xff,0xff));
   SDL_SetColorKey(sprite_player,SDL_SRCCOLORKEY,SDL_MapRGB(sprite_blocks->format,0xff,0xff,0xff));
   SDL_Rect rect_fullscreen{0,0,320,240};
   SDL_Rect rect_sky{0,0,320,0};
   theplayer player;
   SDL_Rect sprite_blocks_source{0,0,20,20};
   SDL_Rect rect_blocks;
   rect_blocks.w=20;
   rect_blocks.h=20;
   SDL_Rect rect_hud1{0,0,320,20};
   SDL_Rect rect_hud2{0,20,20,220};
   SDL_Rect rect_blank{0,0,20,20};
   for(int i=0;i<600;i++)
   {
      newrow(i);
   }
   while(1)
   {
      if(!player.is_active)
      {
         if(isKeyPressed(KEY_NSPIRE_UP))
         {
            player.direction=up;
            player.is_active=1;
         }
         else if(isKeyPressed(KEY_NSPIRE_LEFT) && player.position_x>19)
         {
            player.direction=left;
            player.is_active=1;
            player.position_x_temp=player.position_x;
            player.drillmax=player.depth/20+200;
         }
         else if(isKeyPressed(KEY_NSPIRE_DOWN) && player.depth>-1)
         {
            player.depth_temp=player.depth;
            player.direction=down;
            player.is_active=1;
            player.drillmax=player.depth/20+200;
         }
         else if(isKeyPressed(KEY_NSPIRE_RIGHT) && player.position_x<619)
         {
            player.direction=right;
            player.position_x_temp=player.position_x;
            player.is_active=1;
            player.drillmax=player.depth/20+200;
         }
      }
      else
      {
         if(player.direction==down)
         {
            player.depth=player.depth_temp+20*player.drillcount/player.drillmax;
         }
         else if(player.direction==right)
         {
            player.position_x=player.position_x_temp-player.drillcount/player.drillmax;
         }
         else if(player.direction==left)
         {
            player.position_x=player.position_x_temp+20*player.drillcount/player.drillmax;
         }
         player.animationcount++;
         player.animationcount%=4;
         player.rect_player_animation_source.x=static_cast<currentdirection>(player.direction)*112+player.animationcount*28;
         player.drillcount+=player.drillspeed;
         if(player.drillcount>=player.drillmax)
         {
            if(player.direction==left)
            {
               player.position_x=player.position_x_temp-20;
            }
            else if(player.direction==right)
            {
               player.position_x=player.position_x_temp+20;
            }
            map[player.depth_temp/20-1][player.position_x/20+15]=nothing;
            if(player.direction==down)
            {
               player.depth=player.depth_temp+20;
            }
            player.drillcount=0;
            player.is_active=0;
         }
      }
      if(player.direction==up)
      {
         if(!isKeyPressed(KEY_NSPIRE_UP))
         {
            if(player.acceleration!=0)
            {
               player.acceleration--;
            }
            else
            {
               player.is_active=0;
            }
         }
         else if(player.acceleration!=player.enginepower)
         {
            player.acceleration++;
         }
         player.depth-=player.acceleration;
      }
      if(isKeyPressed(KEY_NSPIRE_ESC))
      {
         SDL_Quit();
         return 0;
      }
      SDL_FillRect(screen,&rect_fullscreen,0x7b08);
      if(player.depth<140)
      {
         rect_sky.h=140-player.depth;
         SDL_FillRect(screen,&rect_sky,0x9edd);
      }
      for(int z=0;z<13;z++)
      {
         if(player.depth+20*z<120)
         {
            continue;
         }
         for(int i=0;i<17;i++)
         {
            if(player.position_x/20+i<0)
            {
               continue;
            }
            rect_blocks.y=20*z-player.depth%20+10;
            rect_blocks.x=player.position_x%20+20*i;
            if(static_cast<blocktype>(map[player.depth/20+z-7][player.position_x/20+i+7])>1)
            {
               sprite_blocks_source.x=20;
               SDL_BlitSurface(sprite_blocks,&sprite_blocks_source,screen,&rect_blocks);
            }
            sprite_blocks_source.x=20*(static_cast<blocktype>(map[player.depth/20+z-7][player.position_x/20+i+7]));
            SDL_BlitSurface(sprite_blocks,&sprite_blocks_source,screen,&rect_blocks);
         }
      }
      SDL_BlitSurface(sprite_player,&player.rect_player_animation_source,screen,&player.rect_player_centered);
      //SDL_FillRect(screen,&rect_fullscreen,35362);//brown in case you were wondering-crude graphics for dirt
      SDL_FillRect(screen,&rect_hud1,0xffff);
      SDL_FillRect(screen,&rect_hud2,0xffff);
      intlength=getlength(abs(player.depth));
      shownumber(screen,abs(player.depth),intlength);
      if(player.depth<0)
      {
         for(int i=0;i<10;i++)
         {
            nSDL_SetPixel(screen,305-intlength*12+i,7,score_color);
         }
      }
      SDL_Flip(screen);
   }
   return 0;
}
(code still needs to be cleaned up a lot)
Probably some other derp fail, but was wondering
You can view the glitch in the attachment




(gcc occasionally glitches for me in codeblocks (the exact same code compiles to different things at different times) because my computer is weird, but I've tried this lots of times)

12
Calculator C / Re: good random numbers
« on: June 19, 2014, 11:08:47 pm »


That'd be a really troll map generated by that :D
I was about to say that too.


Otherwise, you can try integrating a library such as this one: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
time is good enough for now
Since this looks a lot like Drillminer (basically motherload with MC block skins), you could ask epic7 for the source so you can get some help with this issue, and engine stuffs.
I'm pretty much trying to make a (bad) clone of motherload :P


Anyway, the blocks are much better now
Thanks for your suggestions


13
Calculator C / Re: good random numbers
« on: June 17, 2014, 05:32:57 pm »
you only set the seed once all at the beginning of your program.
Woops
Epic fail
Looks like I still have much to learn
I spent a long time looking at the code, and just realized I added the line in the wrong place

14
Calculator C / Re: good random numbers
« on: June 17, 2014, 05:26:31 pm »
Shouldn't your language have pseudo-random built-in?
Yes, I used srand(time(NULL)) but that gives me total crap for blocks :(
I was wondering if there was a better thing for generation

15
Calculator C / good random numbers
« on: June 17, 2014, 05:24:21 pm »
I'm trying to make a drilling game. When the player first starts, the program generates some dirt blocks with minerals 50 rows deep and 40 columns wide, or 2000 blocks. However, using time as rand gives me really crappy number generation (all the blocks in a column are the exact same if I use time as rand). I've tried using a couple other things, like using SDL_GetTicks() (which produces the exact same thing every time by itself, so I also need rand) and xoring the int a couple of times, but I still get really poorly generated blocks. Also, I still want it to be simple enough that it doesn't lagg much. Any ideas?




My current block generator:

Code: [Select]

void newrow(uint16_t row)
{
srand(time(NULL));
chance[0]=1000/(abs(pow(row-10,1.1))+50);//1000/(abs(pow(row-row_where_it_is_most_common,range_of_how_common_it_is))+100/percent_of_blocks_in_most_common_row)
//coal is found with a frequency of 100/50=2% of blocks in the row in which it is most commonly found
//coal is most commonly found in row 10 (actually 11 in the array, but 1 more or less doesn't make a huge difference)
//coal is commonly found in a large range of blocks, note the low exponent
//note that 0 in this array corresponds to 2 in blocktype
chance[1]=1000/(abs(pow(row-30,1.1))+60);//iron is found in 1.667% or 16/1000 blocks in the generator at max, and is also very common
chance[2]=1000/(abs(pow(row-50,1.1))+80);
chance[3]=1000/(abs(pow(row-80,1.1))+20);
chance[4]=1000/(abs(pow(row-110,1.3))+100);
chance[5]=1000/(abs(pow(row-150,1.5))+150);
for(int i=0;i<40;i++)
{
tempint=((SDL_GetTicks()+rand()+i)^(row*i))%1000;
sleep(1);
for(int z=0;z<6;z++)
{
if(z==5)
{
if(rand()%8)
{
map[row][i]=dirt;
break;
}
map[row][i]=nothing;
break;
}
if(chance[z]>tempint)
{
map[row][i]=(static_cast<blocktype>(z+2));
break;
}
tempint-=chance[z];
}
}
}

Pages: [1] 2 3 4