Post by Centanoul on Nov 30, 2005 17:27:21 GMT -5
The decay rate is abnormally fast...
The growth rate is quite a bit fast also
The world takes care of itself, using different textures depending on a timer(not a clock time, just rather, a variable that resets itself. I might use a clock when I have more time to 'deal' with it.)
The point behind this is to show others how to make your world 'change' itself. You could of easily change this with the values for when the textures will change and how into a text file, or make a small scripting language for the engine to read. This is by no means a professional job, I am just a small amatuer who messed around with something he likes and thought he would share, enjoy.
IsoGrowth:
DestriaMap.txt:
This is the first program I have posted, and any comments, suggestions, and criticism is welcome.
(I have yet to see flaming on these boards. )
Edit: *sigh* no, it does NOT use the tilemap function at anypoint. So I named the Topic Wrong. lol. Enjoy anyways, and I hope to see grass growing in the 3d engines you all create.
The growth rate is quite a bit fast also
The world takes care of itself, using different textures depending on a timer(not a clock time, just rather, a variable that resets itself. I might use a clock when I have more time to 'deal' with it.)
The point behind this is to show others how to make your world 'change' itself. You could of easily change this with the values for when the textures will change and how into a text file, or make a small scripting language for the engine to read. This is by no means a professional job, I am just a small amatuer who messed around with something he likes and thought he would share, enjoy.
IsoGrowth:
'IsoMetric Growth.gb
'By Centanoul
'----------
'Dimension Variables
dim MapFile 'Files
dim Gravel '\
dim Dirt '->Textures
dim Grass(2) '/
dim XTile# 'Keeps track of tile position, x axis
dim YTile# 'Keeps track of tile position, y axis
dim Growth(10,10)'Keeps the state of each tile, and chooses what TileUsed will be
dim TileUsed 'Keeps track of which texture to draw.
'----------
'Load Files
MapFile = OpenFileRead ("Files/DestriaMap.txt")
Gravel = LoadTexture ("Textures/00009.jpg")
if Gravel = 0 then print "Failed to load texture": end: endif
Dirt = LoadTexture ("Textures/00003.jpg")
if Dirt = 0 then print "Failed to load texture": end: endif
Grass(0) = LoadTexture ("Textures/00006.jpg")
if Grass(0) = 0 then print "Failed to load texture": end: endif
Grass(1) = LoadTexture ("Textures/00008.jpg")
if Grass(1) = 0 then print "Failed to load texture": end: endif
Grass(2) = LoadTexture ("Textures/00005.jpg")
if Grass(2) = 0 then print "Failed to load texture": end: endif
'----------
'OpenGL Start
glEnable (GL_TEXTURE_2D)
glEnable(GL_CULL_FACE)
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glTranslatef(-13.2,-9.0,-16)
For YTile#= 1 to 10 'Loop in order to read the correct value for each tile
For XTile#= 1 to 10 'Its ordered like this to go read row by row
Growth(XTile#,YTile#)=Val(ReadChar(MapFile))*50 + 1 'Assign growth level to a tile
'Anything that used (XTile#,YTile#) is a property of that tile.
'And is saved in reverse fashion. (By property, instead of by tile)
Next 'End a row
ReadChar(MapFile) '- These both take out the carriage return and are
ReadChar(MapFile) '- necessary so that I may format text file like I do. (Semi-Visually)
Next 'End the reading loop.
'----------
'Main Loop Start
MainLoop: 'This is here because I like Main Loops.
While true
gosub draw
Wend
'----------
'Drawing Preperation Start.
Draw:
For XTile#= 1 to 10 'Another loops setup
For YTile#= 1 to 10
If Growth(XTile#,YTile#) > 525 then 'If growth has ended and ready to loop, loop it
Growth(XTile#,YTile#) = 151 'Loop it back to dirt
endif
If Rnd()%100+1 > 50 then
Growth(XTile#,YTile#) = Growth(XTile#,YTile#)-1
endif
If Growth(XTile#,YTile#) > 0 then
TileUsed=Gravel 'No growth, gravel stage. (You can start at this stage, but never reach it again.)
endif
If Growth(XTile#,YTile#) > 150 then
TileUsed=Dirt 'Very little growth, dirt stage
endif
If Growth(XTile#,YTile#) > 200 then
TileUsed=Grass(0) 'Sparse Grass
endif
If Growth(XTile#,YTile#) > 250 then
TileUsed=Grass(1) 'Grass
endif
If Growth(XTile#,YTile#) > 300 then
TileUsed=Grass(2) 'Bright, Light Healthy Grass
endif
If Growth(XTile#,YTile#) > 475 then
TileUsed=Grass(1) 'Back to Grass, Quickly
endif
If Growth(XTile#,YTile#) > 500 then
TileUsed=Grass(0) 'Back to Sparse Grass, Quickly.
endif
'----------
'Drawing start.
glBindTexture(GL_TEXTURE_2D, TileUsed)'2d Isometric, from the formulas.
glBegin(GL_Quads)
glTexCoord2f( 0.0, 0.0)
glVertex2f(1 + XTile# + YTile#, 9 + XTile#/2 - YTile#/2)
glTexCoord2f( 1.0, 0.0)
glVertex2f(2 + XTile# + YTile#, 8.5 + XTile#/2 - YTile#/2)
glTexCoord2f( 1.0, 1.0)
glVertex2f(3 + XTile# + YTile#, 9 + XTile#/2 - YTile#/2)
glTexCoord2f( 0.0, 1.0)
glVertex2f(2 + XTile# + YTile#, 9.5 + XTile#/2 - YTile#/2)
glEnd()
Growth(XTile#,YTile#) = Growth(XTile#,YTile#)+1 'Advance Growth
Next
Next
SwapBuffers() 'Show growth when done
return 'Go back to loop
DestriaMap.txt:
3333333333
3222223773
3211122773
3210123333
3221123344
3322123445
3332223566
3443334566
3454434436
3333333333
This is the first program I have posted, and any comments, suggestions, and criticism is welcome.
(I have yet to see flaming on these boards. )
Edit: *sigh* no, it does NOT use the tilemap function at anypoint. So I named the Topic Wrong. lol. Enjoy anyways, and I hope to see grass growing in the 3d engines you all create.