I want to make a 2-D version of Minecraft that will be drawn on the Graph screen, but I am unable to make it look "real." I came across Perlin Noise, but have no idea how I would program this on my TI-84+CE. I do not want to download files or use assembly, as beneficial as that would be. This program would be only for fun, and would probably be a static program that you can't interact with. Could someone help get me started?
Think of standard ideas like this:
- When the user presses the right or left key add a block (pixel) to their location
- When the user is in the air, fall from gravity
- There will be different types of blocks, but not that much since the CE only supports 15 colors.
You probably might need the help of libraries or assembly programs, since it's hard with TI-Basic by itself.
Since you are using a CE, it will be harder to accomplish since there are more pixels, colors, and command arguments.
Hewwo, my name is Achak Claw. I was formerly BioHazard.
In terms of using Perlin noise to generate land, how many dimensions are you planning on generating in? For a two-dimensional game, I assume you would want the noise to be 1-dimensional (see https://flafla2.github.io/2014/08/09/perlinnoise.html for more explanation), but in that case you could just use an RNG to generate the land. A while ago I created a simple terrain generator very similar to what you are talking about, but for the TI-84+. Here's my abbreviated code: (Feel free to change numbers as necessary. Bolded numbers denote numbers specific to my calculator.)
:8→A //This is the height that the world starts generating at. This will change often, due to hills and valleys.
:For(I,1,**89**,5 //This basically loops through the generating-land function enough times to fill the screen. The land generates in columns moving left-to-right, so this keeps track of which column is being generated at the moment.
:
:For(J,int(5A),**55**,5 //This will start at the surface level on whatever column is being generated, and goes down to the bottom of the screen
:If J=int(5A //This checks if the block being generated is the surface of the world
:Then
your code for drawing a grass block goes here
:Else //If the block being generated is underground
your code for drawing a stone block goes here
:End
:End
: //The column has been drawn. Now the program will calculate the next value for the surface level
:max(1,min(**11**,A+randInt(-1,1→A //Randomly increases, decreases, or keeps A the same. The max(1,min(11,... part is to make sure that the height never goes off of the screen. Change this if you want different upper and lower bounds.
: End //Go back to the beginning of the loop, and start drawing the next column.
This code works pretty well, but note that it cannot handle underground caves, floating islands, and cliffs (points where the elevation changes by more than 1). I had some tree-placing code, too, but it didn't work very well.
As a note, every block is 5x5 pixels in this code. Any use of "5" is most likely talking about the block size. If your blocks are a different size, change the 5's.
Note that a list can be used to keep track of the surface heights of columns, which means you can use the list to check the surface terrain of the world. Because of the use of the randInt( command, seeds can be used as well, in order to recreate worlds.
Changing parts of the world (by mining, building, etc.) would be difficult to program in, but I have no doubt it can be done. This program might not be the way to go, though.
Essentially, this program generates a squiggly line, and declares everything below the line to be stone, everything above it to be air, and the line itself to be dirt.
Here's a screenshot of a world it generated (ignore the trees): image on Flickr
Okay wow. This is actually a great starting point and could be used for caves, lakes, etc. For right now, I am only making this program to see what kinds of worlds it will make, So I am not too concerned with being able to interact with it yet.
How would I make this a 2-D version? Uses: ore spawns
In the code where stone generates, check the height. If its low enough to spawn an ore, generate a random number between 1 and however high you want, higher number means lower chance. If the generated number equals one, generate a vein. A vein could be one, or you could make it choose a random pattern (square, L, cross, etc).
If you post your code, I can look at it and try and create something
Here you go. I would also like the veins to be completely random, with the ability to change the size range of the vein. This way, I can generate Andesite/Granite/Diorite veins (very large), Coal veins (large), Iron/Gold/Redstone (medium), and Diamond/Emerald (small). Also, if you could send the code for tree generation, I could look into that. If any optimizations could be made, that would also be really helpful. Also, how would seed implementation work?
Also count: 4
ClrDraw
prgmBLOCKS //create the lists that tell what color pixels to place for each block
randInt(10,18)→A //World gen height
For(I,0,260,5)
For(J,int(5A),160,5)
If J=int(5A):Then
1→P //pixel counter
For(B,0,4)
For(C,0,4) //These 2 For( blocks tell the code how much to shift over each pixel coordinate
Pxl-On(J+B,I+C,⸤GRAS(P //A 25-dimension list built in the BLOCKS program
P+1→P
End:End
Else:If J=int(5A+5):Then //Draw a dirt block under the grass block
1→P
For(B,0,4)
For(C,0,4)
Pxl-On(J+B,I+C,⸤DIRT(P
P+1→P
End:End
Else:If J=int(5A+10) and randInt(0,2):Then //Chance to draw another dirt block under the first
1→P
For(B,0,4)
For(C,0,4)
Pxl-On(J+B,I+C,⸤DIRT(P
P+1→P
End:End
Else
1→P
For(B,0,4)
For(C,0,4)
Pxl-On(J+B,I+C,⸤STON(P
P+1→P
End:End
End:End:End:End
max(8,min(20,A+randInt(⁻1,1)))→A
End
Can you post the code for pgrmBLOCKS? I'm trying to get this on my calc so I can work with it. Thanks
{14,14,14,14,14,14,16,14,14,15,16,16,16,16,15,16,16,16,16,16,15,16,16,16,16}→⸤GRAS
{23,23,23,24,24,23,24,23,24,23,24,24,23,24,24,23,24,23,24,24,23,23,24,23,24}→⸤STON
{16,15,16,16,16,16,16,16,16,16,16,15,16,16,15,16,16,16,16,15,16,16,16,15,16}→⸤DIRT
{22,24,12,23,24,24,12,12,23,12,23,12,24,24,23,23,24,24,24,12,24,12,23,24,23}→⸤BEDR
Hey I was wondering if you have that code done yet?