News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Super Drift Racer!!- WIP

Started by monkeybot, January 23, 2014, 12:15:54 PM

Previous topic - Next topic

monkeybot


kevin

#16
 Here's top-down height map a mock up, there's a few errors in it, but basically it shows the concept.   You wouldn't actually need to draw the ground as triangles, provided the camera never moves on the Z axis.   When the foreground occludes the map, just cull the blocks . 


PlayBASIC Code: [Select]
   Constant ProjectionX = 400
Constant ProjectionY = 400


Type tTerrainVertex
x#,y#,Z ; 3d SPACE CORD
px#,py# ; project 2d coord
Col
Flat ; ground tile ? (drawn in first pass)
EndType



groundheight=1500

GridSize=30
Dim Terrain(GridSize,GridSize) as tTerrainVertex

For ylp =0 to GridSIze
For xlp =0 to GridSize
Terrain(xlp,ylp) =new tTerrainVertex
Terrain(xlp,ylp).x = (xlp*400)
Terrain(xlp,ylp).y = (ylp*400)

DIST#=getdistance2d(0,0,gridsize/2,gridsize/2)

Terrain(xlp,ylp).z = 1500
Terrain(xlp,ylp).flat = 1

Terrain(xlp,ylp).col=rndrgb()
next
next


for lp =0 to 30
x=rnd(gridSize-2)
y=rnd(gridSize-2)
depth=GroundHeight-rndrange(100,300)
Terrain(x,y).z = depth
Terrain(x+1,y).z = depth
Terrain(x+1,y+1).z = depth
Terrain(x,y+1).z = depth

Terrain(x,y).flat = 0
Terrain(x+1,y).flat = 0
Terrain(x+1,y+1).flat = 0
Terrain(x,y+1).flat = 0

next



; Clip the Camera
Xrange=8000
YRange=8000

CamX=00
CamY=00
CamZ=-ProjectionX


StartPass=1


c1=$205020
; c2=$605020
c3=$406020
c4=$40300


Do

cls $406080

// project /rotate points
For ylp =0 to GridSIze
For xlp =0 to GridSize

z#=Terrain(xlp,ylp).z-CamZ

; Check if the Object is in front of the camera (positive)
If Z#>0

; Translate the X# / Y# cooords object To the camera
x#=Terrain(xlp,ylp).x-CamX
y#=Terrain(xlp,ylp).y-Camy

; Calc projected X /Y coords
PX#=CameraCenterX#+((x#*ProjectionX)/Z#)
PY#=CameraCenterY#+((y#*ProjectionY)/Z#)

Terrain(xlp,ylp).px#=px#
Terrain(xlp,ylp).py#=py#

EndIf


next
next


lockbuffer




// project /rotate points
For Pass=0 to 1
For ylp =0 to GridSIze-1
For xlp =0 to GridSize-1

x1#=Terrain(xlp,ylp).px#
y1#=Terrain(xlp,ylp).py#

x2#=Terrain(xlp+1,ylp).px#
y2#=Terrain(xlp+1,ylp).py#

x3#=Terrain(xlp+1,ylp+1).px#
y3#=Terrain(xlp+1,ylp+1).py#

x4#=Terrain(xlp,ylp+1).px#
y4#=Terrain(xlp,ylp+1).py#



if Terrain(xlp,ylp).Flat=Pass then continue


if crossproduct#(x1#,y1#,x2#,y2#,x3#,y3#)>=0
gouraudtri x1#,y1#,c1,x2#,y2#,c2,x3#,y3#,c3
endif

if crossproduct#(x1#,y1#,x3#,y3#,x4#,y4#)>=0
gouraudtri x1#,y1#,c1,x3#,y3#,c3,x4#,y4#,c4
endif

next
next
next
unlockbuffer

StartPass=2

; Move the camera
Speed=10

If UpKey() Then Camy=Camy+-Speed
Login required to view complete source code

stevmjon

hey monkey dude

I was in the mood to make some graphics for you in my 3D program.
they are individual pics, that need to be cut up and made into a map image. I made them divisible by 64 pixels.

also, you don't need to make as many tiles as you did. use the ones with black as transparent, and you can paste these on top of dirt / road tiles. this is where z buffer comes in handy.  eg. use all grass tiles on z layer 5, use road / dirt tiles on z layer 10. this way you will use less tiles.

I like this game, and i am looking forward to seeing more.

hope this helps,  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

monkeybot

Thanks chaps.i will check these things out.

monkeybot

what does  crossproduct#() do?
i can't find it in the docs

kevin


monkeybot

#21
thanks,i see you are using it for shading purposes(i think)

monkeybot

#22
i have a problem,if i use the basic tile set in my game(via playmapper) the game runs fine but if i use the posh tileset the collision is constantly being triggered  which is level 3 on the map.
it is almost definitely  user error,it generally is...

stevmjon

hey monkeybot

how are you defining collisions? are you using shapes colliding with a map? or are you manually checking collisions?

if you could post your source code with the images in a zip file, it would be handy. I understand that some people don't like to share their code, but it would be helpful to determine the issue.

  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

monkeybot

i am checking points against the map

stevmjon

hey monkeybot

I re-made the map image for you, as one instead of individually. the older ones were all 24bit, but this new one is 32bit. this allows loading as AFX images to be used for an AFX map.

I adjusted the dirt and road tiles to show more detail, and I removed the specular highlights from the grass, so there are no bright spots anymore. the tiles on the right hand side are to roughen up the grass edges.
remember to use levels(layers). put grass on top, and put dirt and road underneath.

because the tiles are different, you will need to modify your map tile numbers for placement. sorry about that. you can at least use less tiles with mine.

hope you like it, if you need any adjustments, let me know. my 3D scene is set-up and I can easily adjust individual tiles.

  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

monkeybot

#26
Hey nice one they look great.
I will get round to it as soon as possible.
Thanks again

micky4fun

#27
Hi all

looking good monkeybot , reminds me of auto racing on the intellivision , loved that game , thought this was such a good system , football (soccer) at the time looked so real the way they run , how things changed

https://www.youtube.com/watch?v=kWaUCaRAioQ



keep up the good work , look forward to complete game

mick :)

monkeybot

nice.

I knew you couldn't stay away mick.  :-)

kevin


Reminds me those sprint/supersprint arcades from the late 70's



Was thinking that for the track what you could look into making them out of polygons.    So in the designer you have mutliple layers, such as ground layer, track layer, then a foreground stuff layer.   The ground and track would be merged together and spat out as a tile map or just a big bitmap.