Hi Somarl,
Quote: "1) A world to move in.
Setting up the very basics.
a) Simple terrain.
First we set up the screen and create a small textured random terrain.
b) A way to move.
Simple unrestricted camera movement to move round that terrain."
Here is some code that I think will pretty much cover #1. It sets up a basic terrain with camera movement. The necessary media and the source/project code are included in the download.
sync on : sync rate 60
autocam off : hide mouse
set camera range 1.0, 7200.0
fog on : fog color rgb(128,128,128) : fog distance 7000
#constant true 1
#constant false 0
global GameOver, CurrObject
GameOver = false : CurrObject = 1
type PlayerData
obj_num, status, health, weapon, damage
endtype
player as PlayerData
BuildTerrain()
x# = 21696.8
z# = 5398.0
y# = get terrain ground height(2000,x#,z#) + 70.0
position camera x#,y#,z#
point camera x#,y# - 70.0,z# + 200
update terrain 2000
SetupPlayer()
repeat
HandleCamera()
Debug()
update terrain 2000
sync
until spacekey() = 1 or GameOver = 1
end
function BuildTerrain()
load image "ColorMap.bmp",1
load image "DetailMap.bmp",2
make object terrain 2000
set terrain heightmap 2000, "Heightmap.bmp"
set terrain scale 2000, 400, 40, 400
set terrain split 2000, 32
set terrain tiling 2000, 8
set terrain light 2000, 1, 1, 1, 1.0, 1.0, 1.0, 0.7
set terrain texture 2000, 1, 2
build terrain 2000
endfunction
function Debug()
text 10,10,"FPS: " + str$(screen fps())
text 10,30,"CamX# = " + str$(camera position x(),1)
text 10,50,"CamZ# = " + str$(camera position z(),1)
` text 10,70,"Cam angle Y# = " + str$(camera angle y(),1)
endfunction
function GetFreeObject()
repeat
inc CurrObject
until object exist(CurrObject) = false
endfunction CurrObject
function HandleCamera()
if keystate(30) = true : // A (strafe left)
ya# = camera angle y()
yrotate camera (ya# - 90.0)
move camera 2.0
yrotate camera ya#
x# = camera position x()
z# = camera position z()
y# = get terrain ground height(2000,x#,z#)
position camera x#,y# + 70.0,z#
endif
if keystate(32) = true : // D (strafe right)
ya# = camera angle y()
yrotate camera (ya# + 90.0)
move camera 2.0
yrotate camera ya#
x# = camera position x()
z# = camera position z()
y# = get terrain ground height(2000,x#,z#)
position camera x#,y# + 70.0,z#
endif
if keystate(17) = true : // W (forward)
x# = camera position x()
z# = camera position z()
ya# = camera angle y()
x# = newXvalue(x#,ya#,10.0)
z# = newZvalue(z#,ya#,10.0)
y# = get terrain ground height(2000,x#,z#)
position camera x#,y# + 70.0,z#
endif
if keystate(31) = true : // S (backward)
x# = camera position x()
z# = camera position z()
ya# = camera angle y()
x# = newXvalue(x#,ya#,-5.0)
z# = newZvalue(z#,ya#,-5.0)
y# = get terrain ground height(2000,x#,z#)
position camera x#,y# + 70.0,z#
endif
caX# = camera angle x() : ya# = camera angle y()
xrotate camera caX# + (mousemovey() * .3) : // use mouse to angle camera
yrotate camera ya# + (mousemovex() * .3)
endfunction
function SetupPlayer()
player.obj_num = GetFreeObject()
player.status = 1
player.health = 100
player.weapon = 0
player.damage = 0
endfunction
The WASD keys and mouse are used for movement. Note that the code does not check the borders, so you can easily move right off the edge of the terrain. Also, while this same terrain will appear every time, it is random in how it looks. If you wanted to make additional terrains, or replace it, you could easily change the heightmap. The more white a color is on the heightmap, the higher it will be on the terrain.
I don't understand why you would make a world and then make a more complicated one in the following step. If it were me, once I had a basic world, I would add the other game components (gun, shooting, buildings, NPCs, AI, etc) before I concerned myself with a more complicated world.
Anyway, this is one way you could get started in the process.
So many games to code.....so little time.