Hey,
I decided to try and make a basic rpg in the style of the elder scrolls or similar, and so far, after about an hour i have a basic movement, and next i need to add collision / gravity.
I have never tried anything like this before, but i am prepared to stick with it, so i would really appreciate some help or even just a link to a tutorial on how to do this or something similar.
EDIT:
I have made a lot of advancements with terrain using open source projects and tutorials and such, but i still cant figure out gravity and collision. At the moment i am using "get ground height()" but it seems to be extremely inaccurate...
`Display Setup
width = desktop width()
height = desktop height()
set display mode width, height, 32, 1
set window off
sync on : sync rate 60
hide mouse
jumping = 0
jumpstage = 1
height1# = 2
height2# = 6
takeheight = 1
`Camera Setup
make camera 1
position camera 1, 0, 2, 0
`Images
load image "heightmap.bmp", 1
load image "texture.bmp", 2
`Terrain Setup
make matrix 1, 500, 500, 64, 64
position matrix 1, -50, 0, -50
prepare matrix texture 1,2,1,1
cls
paste image 1,0,0
modifier = 256 / 64
for x = 0 to 64
for y = 0 to 64
pixelcolor#=rgbr(point(x*modifier,y*modifier))
set matrix height 1,x,y,pixelcolor#
next x
next y
update matrix 1
cls
`Water Setup
make object plain 1, 500, 500
load image "water.bmp", 3
texture object 1, 3
set reflection shading on 1
set alpha mapping on 1, 25
position object 1, 250, 15, 250
xrotate object 1, -90
`Sky Setup
load image "sky.bmp", 4
make object sphere 2, (-500 * 2)
texture object 2, 4
position object 2, 250, 0, 250
set ambient light 100
make light 1
position light 1, 0, 50, 0
`Main Loop
do
gosub lookinghandler
gosub movementhandler
gosub gravityhandler
gosub worldhandler
sync
loop
lookinghandler:
camy# = camy# + mousemovex() * 0.1
camx# = camx# + mousemovey() * 0.1
if camx# > 90 and camx# < 135 then camx# = 90
if camx# > 270 and camx# < 225 then camx# = 90
yrotate camera 1, camy#
xrotate camera 1, camx#
return
movementhandler:
if keystate(17) = 1 then move camera 1, 0.2
if keystate(31) = 1 then move camera 1, -0.1
if keystate(30) = 1 then move camera left 1, 0.2
if keystate(32) = 1 then move camera right 1, 0.2
if spacekey() = 1 then jumping = 1
return
gravityhandler:
if jumping = 0 then position camera 1, camera position x(1), get ground height(1, camera position x(1), camera position z(1)) + 0.2, camera position z(1)
if jumping = 1
if takeheight = 1 then height1# = camera position y(1) + 0.2
takeheight = 0
if jumpstage = 1
inc height1#, 0.2
position camera 1, camera position x(1), height1#, camera position z(1)
inc timesincreased, 1
endif
if jumpstage = 2
dec height2#, 0.2
position camera 1, camera position x(1), height2#, camera position z(1)
inc timesdecreased, 1
endif
if timesincreased = 20
jumpstage = 2
timesincreased = 0
height2# = height1#
height1# = 2
endif
if timesdecreased = 20
jumpstage = 1
jumping = 0
timesdecreased = 0
height2# = 6
takeheight = 1
endif
endif
return
worldhandler:
`Water
if down=0
move object 1, 0.005
if object position y(1) => 15 then down=1
endif
if down=1
move object 1, -0.005
if object position y(1) =< 24 then down=0
endif
if camera position y(1) < object position y(1)
color ambient light rgb(0,0,192)
set shading off 1
else
color ambient light rgb(255,255,255)
set reflection shading on 1
endif
`Sky
yrotate object 2, object angle y(2) + 0.05
return
Any help is appriciated
Matt
Welcome down to London City where the attitudes bad and the weather is shitty...