Isometric Game

User projects written in or related to FreeBASIC.
leopardpm
Posts: 1791
Joined: Feb 28, 2009 20:58

Isometric Game

Postby leopardpm » Oct 30, 2010 7:03

Hi,
Well, my project is far from completed but I have gotten to one point in its development where I can at least let people mess around with something.

This program is basically a Random Terrain (world) Generator with a heightmap transformation to display in Isometric style.

The 'world' it is currently generating is 1024 x 1024 x 32 (z-levels) and it takes forever for it to finish.

When you run the program, watch the window title for information (it stops generating when it reaches 2500 'lands' or a height of 30). You can get a quick snapshot of the generation process by pressing space, and you can stop the generation process at anytime by pressing 'Q', but I recommend waiting until at least 1000 lands have passed so that you have something to look at it the viewer besides ocean and bumpy sea-bottom!

After Terrain generation, the Isometric viewer will appear and in this part you can use the arrow keys or number pad to scroll the map. I have a slow machine and the framerate is pitiful currently, but its still rather interesting to explore the world. I have alot of optimization to do in both the generation process and the viewer, but it works as is and gives folks something to look at.

I didn't include source code because I am embarrassed, but I don't have a problem giving it out once I have streamlined it.

BTW: the 'game' itself will use tiles 32 x 32 and this viewer is reduced to 16 x 16 just so I could show more of the world at one time.

Here is the link to the zip file (my first time using this file hosting service so I hope it works!):
http://www.mediafire.com/?00ya2xd7dquus85

Any feedback, criticism, or kudos are more than welcome!

I can describe the final game idea if you are interested, just let me know!

Enjoy!
Leo
Last edited by leopardpm on Jan 08, 2011 12:39, edited 1 time in total.
leopardpm
Posts: 1791
Joined: Feb 28, 2009 20:58

Postby leopardpm » Oct 30, 2010 7:09

oh yeah,

regarding the terrain generation method: I tried the Midpoint Displacement Fractal method and wasn't too happy, also did the circle method and that wasn't cutting it either, tried adding noise and various other crap, but after alot of frickin around I have 'kinda' settled on this method which plots a series of randomly decreasing sized circles in a given area and each circle 'adds' terrain height within its radius. Each of the 'lands' (the feedback variable in the window title) represents 1 series of these circles plotted.

I am currently satisfied with the output, but it needs alot of work yet. I want cliff faces and vast praires, mountain ranges and valleys, as well as islands and continents. After the past 2 days of experimenting, I think my goals are attainable.

PS: those things in the white tundra/snow are evergreen trees, not the apple trees you see in the lower elevation.

Leo
angros47
Posts: 1443
Joined: Jun 21, 2005 19:04

Postby angros47 » Oct 30, 2010 9:56

With MiniB3D library, you can make true 3d, and use heightmaps to make terrains, if you are interested.
leopardpm
Posts: 1791
Joined: Feb 28, 2009 20:58

Postby leopardpm » Oct 30, 2010 12:35

angros47 wrote:With MiniB3D library, you can make true 3d, and use heightmaps to make terrains, if you are interested.


I am interested, but a bit scared... I have looked at the Mini3D demos and they are a bit intimidating.... plus.... I intend for my project/game to have quite alot of agents/sprites/etc and I understand 2D animation (and have most of the sprites already), but 3D animation is over my lil head at the moment.... plus I think for what I have in mind (akin to an RTS in units/view), it will overtax a 3D engine.... don't know though.
leopardpm
Posts: 1791
Joined: Feb 28, 2009 20:58

Postby leopardpm » Oct 30, 2010 13:01

angros47,

I do have a weird question for you!

ok, so I have this world map, which is stored in a 3-dimensional array filled with pointers to terrain tiles (basically). Is it possible to take that same array, and transform it into a 3D terrain?

For example, imagine an RTS game with an overhead/Iso view of the world with many units running to and fro... now, selecting one of those units and 'activating' a first-person, 3-D view... kinda like going from 'god-mode' to possessing one of the folks in the world.

My problem is that the Iso world array is not static, it can and will change, perhaps drastically - so can my 3d Iso Terrain array be transformed rather real-time into a true 3-d environment? Even if it is a blocky looking, yet still true 3-D (aka: Minecraft), that is acceptable. Now, the critters in Minecraft are also blocky and I was thinking this was done just to keep with the theme... but I do have Blender files(models) from which my Iso unit sprites were created from so possibly I have some 3d-models with animations to use in the 3D view...

any ideas?

Thanks!
Leo
Oz
Posts: 585
Joined: Jul 02, 2005 14:21
Location: Waterloo, Ontario, Canada
Contact:

Postby Oz » Nov 09, 2011 1:33

Hey leopardpm, I've recently been looking for either a tutorial or anything on how to do procedural world generation - do you have any tips, or are you willing to let me peek at your formulas?

Thanks,
-Oz

PS: I thought the software ran really well, and seemed quite natural :D
gothon
Posts: 220
Joined: Apr 11, 2011 22:22

Postby gothon » Nov 09, 2011 2:24

leopardpm wrote:angros47,

I do have a weird question for you!

ok, so I have this world map, which is stored in a 3-dimensional array filled with pointers to terrain tiles (basically). Is it possible to take that same array, and transform it into a 3D terrain?

For example, imagine an RTS game with an overhead/Iso view of the world with many units running to and fro... now, selecting one of those units and 'activating' a first-person, 3-D view... kinda like going from 'god-mode' to possessing one of the folks in the world.

My problem is that the Iso world array is not static, it can and will change, perhaps drastically - so can my 3d Iso Terrain array be transformed rather real-time into a true 3-d environment? Even if it is a blocky looking, yet still true 3-D (aka: Minecraft), that is acceptable. Now, the critters in Minecraft are also blocky and I was thinking this was done just to keep with the theme... but I do have Blender files(models) from which my Iso unit sprites were created from so possibly I have some 3d-models with animations to use in the 3D view...

any ideas?

Thanks!
Leo


What you are describing is actually very close to what I am working on. Except my program is 100% 3D graphics, so switching views is not needed.

http://vast3d.com/~athomson/exe/VRTS/Wine16.png

I have actually already posted simple cube face generating sample code in the thread here:
http://www.freebasic.net/forum/viewtopic.php?t=18708

I have the main overview map and the fog of war working. Though the mini-map is still not fully functional. I have units with simple working path finding. At the moment I don't have any 3D models, hence the cylindrical units. Most of the critical algorithms I have figured out, although they are unimplemented. And all of the gameplay is unimplemented.

You can download my binary from:
http://vast3d.com/~athomson/exe/VRTS/WallCraft.zip

It is compiled for both Windows and Linux and runs on SDL and OpenGL. As you can see from the frame rate it runs pretty fast on my system; hopefully it will run ok on your system. The controls are:

Select Units:
left click individual units, hold ctrl to not drop current selection
left click terrain = rectangle select
+ arrow keys / roller to make a rectangular solid
+ shift + roller = move rectangle up/down

Order Units to Move with right click, the icon menu is not functional yet.

Pan Map:
Arrow keys / PgUp / PgDown
Hold middle mouse button / use roller

Tilt / Spin Map View:
Ctrl + Arrow Keys

Zoom Map View:
Shift + Arrow Keys
Ctrl + PgUp/PgDown
'+'/'-' keys

Open the Menu with the escape key
angros47
Posts: 1443
Joined: Jun 21, 2005 19:04

Postby angros47 » Nov 09, 2011 17:44

@leopardpm

You can dynamically create and modify a terrain using ModifyTerrain. With a simple loop, you can convert a 2d array into an heightmap, and have your terrain.
Gonzo
Posts: 722
Joined: Dec 11, 2005 22:46

Postby Gonzo » Nov 10, 2011 0:14

you might wanna add this dependency:
http://sourceforge.net/projects/libpng/ ... p/download

to procedurally generate 3d, or even 2d you need to have a clear understanding of what you want to do, and how you need to do it
start simple, and go from there

for example, to get repeatable randomness, the simplest is good enough for starters:
create new project
make array of random numbers
write it to file
blabla

heres an example:

Code: Select all


Type genrands
   As Single rands(1023, 1023)
End Type
Dim Shared genrand As genrands

Sleep Rnd*100
   Randomize Timer

For i As Integer = 0 To 1023
   For j As Integer = 0 To 1023
      
      genrand.rands(i, j) = Rnd
      
   Next
Next

ChDir( ExePath )
Dim As Integer ff = FreeFile()

Open "ingen.rnd" For Binary As #ff
   Put #ff, , genrand
Close #ff


to use:

Code: Select all


Const As Integer irand_axis = 1023

Type ingenRand
   As Single r(irand_axis, irand_axis)
End Type
Dim Shared irand As ingenRand

Sub ingenInit()
   Dim As Integer ff = FreeFile()
   
   ChDir ExePath
   Open "ingen.rnd" For Binary As #ff
      Get #ff, , irand
   Close #ff
   
End Sub

Function iRnd(...) As Single
   
   Dim As UInteger x, y, z
   x = worldx Shl 4 + bx
   y = worldy Shl 3 + by
   z = worldz Shl 4 + bz
   
   x += y Shl 3
   z += y Shl 2
   
   Return irand.r( x And irand_axis, z And irand_axis )
   
End Function

Function iRnd2D(...) As Single
   
   Dim As Integer x, z
   x = worldx Shl 4 + bx
   z = worldz Shl 4 + bz
   
   Return irand.r( x And irand_axis, z And irand_axis )
   
End Function


for example =)
its a very simple method that gives you the same random value for a specific coordinate each time
thats also its downside too, so you might want to create other methods

for "real" procedural generation you want noise that is smooth and also reproducible
but thats kind of complicated... see perlin / simplex / noise

here is a very simple 2D version of what im doing
http://www-cs-students.stanford.edu/~am ... eneration/

and most of all, the "art" of procedural generation really comes down to 90% looks like $%#@, 10% looks ok

Return to “Projects”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 0 guests