Virus..the game - not the other one !

Blitz3D Forums/Blitz3D Programming/Virus..the game - not the other one !

PaulJG(Posted 2003) [#1]
Thought I might have a little dig about with the old retro game - "Virus" or "Zarch"..

http://www.birdsanctuary.co.uk/screens.php?fi=virus&fh=virus/&shot=zarch.gif&colour=red&page=i.php&altag=Zarch%20running%20on%20the%20Archimedes

From what I've played with it, the only problem I'm gonna have is culling the landscape ?. It uses a strange patchwork effect which I'm pretty sure I can emulate with either different surfaces - or a multitextured patch.

But any ideas on how I can get the cutoff effect ??


IPete2(Posted 2003) [#2]
You could just set a very small camera range!

IPete2.

Great game btw.


PaulJG(Posted 2003) [#3]
Thanks Pete, that would cetainly stop the front and back - just the sides though ?.


IPete2(Posted 2003) [#4]
Paul

Use a viwport for a squared off effect, not sure how to make it exactly like Virus.

(The cameraviewport settings for the camera you are rendering.)

IPete2.


Who was John Galt?(Posted 2003) [#5]
What a classic! V2000 just didn't bake my biscuit in the same way. You could have a scene made out of a load of individual quads. Heights for the quads could be read from a 2d array and when a row or column goes 'out of bounds' they can be recycled to the other side of the display with new y values and colours. Birdie's terrain tiling demo that comes with Blitz is worth taking a look at.


Wiebo(Posted 2003) [#6]
I used to play Virus all the time on my Amiga... I almost finished the game as well.... Man it was hard.


Who was John Galt?(Posted 2003) [#7]
I used to have one of those 'Action replay' cheat boxes. Nothing quite like sending a hundred homing missiles at a time after your foes. Still didn't crack it...


Stevie G(Posted 2003) [#8]
I'm pretty sure virus/zarch is done as 0DFEx suggests. Is this what your looking for? Not very well commented but you get the just I'm sure. .... oh and you'd need to do some form of average to get the terrain heights for the edges - these ones don't fade in too well!!

:-

Graphics3D 640,480,16,1

Type point
Field height#
Field index
End Type

Const size=1000

Dim terrain.point(size-1,size-1)

create_terrain()


camera=CreateCamera():PositionEntity camera,0,60,-60
light=CreateLight()
grid=create_grid():surf=GetSurface(grid,1)
PointEntity camera,grid


Global x_pos# = size * 5.0
Global z_pos# = size * 5.0
Global width#=(size*10)

While Not KeyDown(1)

x_mov#=( KeyDown(205)-KeyDown(203) ) * .2
z_mov#=( KeyDown(208)-KeyDown(200) ) * .2

x_pos#=( x_pos+width + x_mov ) Mod width
z_pos#=( z_pos+width + z_mov ) Mod width

update_terrain(surf)

UpdateWorld()
RenderWorld()
Flip
Wend

;=====================================================================================================
;=====================================================================================================
;=====================================================================================================

Function update_terrain(surf)

mx#=Floor( (x_pos +5.0) / 10.0)
mz#=Floor( (z_pos +5.0) / 10.0)
fx#=x_pos - mx*10.0
fz#=z_pos - mz*10.0

For z=-5 To 5
For x=-5 To 5
v=(x+5)+(z+5)*11
ax=(mx+x+size) Mod size
az=(mz+z+size) Mod size
VertexColor surf,v,0,terrain(ax,az)\height * 50,50
vx#=x*10 - fx * (Abs(x)<>5)
vy#=terrain(ax,az)\height
vz#=-z*10 + fz * (Abs(z)<>5)
VertexCoords surf,v,vx,vy,vz
Next
Next

End Function

;=====================================================================================================
;=====================================================================================================
;=====================================================================================================

Function create_terrain()

For z=0 To size-1
For x=0 To size-1
terrain(x,z)=New point
terrain(x,z)\height = Rand(0,10)
Next
Next

End Function

;=====================================================================================================
;=====================================================================================================
;=====================================================================================================

Function create_grid()

mesh=CreateMesh():s=CreateSurface(mesh)

;points
For z=-5 To 5
For x=-5 To 5
v=AddVertex(s,x*10,0,-z*10)
VertexColor s,v,100,Rand(20,60),Rand(10,30)
Next
Next

;triangles & tex coords
For z=0 To 9
For x=0 To 9
v0=x+(z*11):v1=v0+1
v2=v1+11:v3=v0+11
AddTriangle s,v0,v1,v2
AddTriangle s,v2,v3,v0
Next
Next

EntityFX mesh,2
Return mesh

End Function


Who was John Galt?(Posted 2003) [#9]
sweet!


Big&(Posted 2003) [#10]
I was trying to do the same but gave up with the same problem.

The zip includes the original Virus/Zarch ladscape data, including object positions.

http://www.andyn.karoo.net/misc/vland.zip


Stevie G(Posted 2003) [#11]
Looks good Big& - don't recomment using 256 surfaces though. Have an idea for the averaging of the edges - will post details if I can get it working.


PaulJG(Posted 2003) [#12]
Thanks guys, lot of good info and help. :)

Anyone remember the tank game that came out after it, using the same terrain landscape engine ?. (although I dont think it was written by Braben)

Thinking about it.. not 100% sure on this one - back in the time of Amiga CD32's I've got a feeling that Acid came out with a sort of proper 3d remake of it ??. (Mark, Simon ??)
Although.. I could be mistaken.

While I'm in retro mode.. there was a fullgame available on one of the amiga cover disks that was one of the first ever 3d shootemup's. Pretty sure it was by Psygnosis - they gave it away since it was pulled from production.

Basically, you where this tank'y thing in an areana - sorta a very early Unreal Torny. (but a tank rather than a bod) - you could use things like jump pads and lasers.. anyone have any idea what I'm on about ???. (I got the original disk SOMEWHERE in the house - it would make one hell of a remake !. Buckets of playability, but with very easy coding.


PaulJG(Posted 2003) [#13]
Actually... just found the answers to my questions.

The game I was thinking about was programmed by Mark - it was called "Guardian", published by Guildhall.
(it got 83% in Amiga Computing) - think it was more of a virus/defender type game though.

The other game I was thinking about was "Trex Warrior" - now that is a game just crying out for a remake !.


col(Posted 2003) [#14]
Yep. I also believe Guardian was programmed in BlitzBasic, although in Amiga BlitzBasic you could program directly in assembler language. Also Skidmarks on the Amiga was also written in Blitz ( again using assembler command ).


Who was John Galt?(Posted 2003) [#15]
Don't do that to me again Paul - making my head ache at this time of night trying to come up with the name of some old game. Found the answer on the net, and I quote,

"CONQUEROR is a 3D tank game that makes use of the 3D engine that David Braben wrote for the classic game Zarch on the Archimedes or Virus on the Amiga."


Andy(Posted 2003) [#16]
There was also a game called ZeeWolf on the amiga... Good fun it was!

Andy


Who was John Galt?(Posted 2003) [#17]
Indeed it was. I remember that one too.


Vorderman(Posted 2003) [#18]
PaulJG : please email me at jkett@... - I have some older source code that may be of interest to you.


BlitzSupport(Posted 2003) [#19]
Zeewolf 2... drool...


Who was John Galt?(Posted 2003) [#20]
"Zeewolf 2... drool..."

a)Did exist?
b)Will exist?
c)Is a figment of your imagination?


Andy(Posted 2003) [#21]
Did exist!

http://www.amigagames.com/gage/z/zeewolf2.html

Andy


Who was John Galt?(Posted 2003) [#22]
Beauty! Must have abandoned the Amiga by then to join the mounting Hordes of PC scum. The Amiga was most definitely the victim of a conspiracy..........


Stevie G(Posted 2003) [#23]
@ PaulJG and big&

Managed to get the culling effect working a treat - using a single surface with vertex colours. If anyone is interested let me know and I'll post the code. Could easily be used for Zarch, Conqueror or Zeewolf clones.


joncom2000(Posted 2003) [#24]
I for one would like to see how you did it Stevie G. So please do post the code :)


Stevie G(Posted 2003) [#25]
Ok. Not very well commented and I'm not sure how to put the code in a black box etc... Let me know what you think?

Graphics3D 320,240,16,1

Const size#=256
Const divs#=7
Const divg#=divs*4+1
Const scale#=16
Const speed#=.25

Global camera=CreateCamera()
Global light=CreateLight()
Global target=CreatePivot()
Global map,map_tex
Global grid=create_grid()
Global surf=GetSurface(grid,1)
Global x_pos#= size *.5
Global z_pos#= size *.5
Global last_x# = x_pos
Global last_z# = z_pos
Global frames

Type point
Field height#
Field index
Field r,g,b
End Type

Dim terrain.point(size-1,size-1)

random_terrain(0) ;10031972

While Not KeyDown(1)

x_pos=qwrap( x_pos + (KeyDown(205)-KeyDown(203)) * speed,size)
z_pos=qwrap( z_pos + (KeyDown(208)-KeyDown(200)) * speed,size)

update_terrain()
update_camera()

frames=qwrap(frames+1,10)
If frames = 0 update_map()


UpdateWorld()
RenderWorld()

Flip
Wend

;=====================================================================================================
;UPDATE TERRAIN =====================================================================================================
;=====================================================================================================

Function update_terrain()

ax#=Floor(x_pos):az#=Floor(z_pos)
fx#=(x_pos) - ax:fz#=(z_pos) - az

For z=-divs To divs+1
For x=-divs To divs+1

nx#=qwrap(ax+x,size)
nz#=qwrap(az+z,size)

vy#=terrain(nx,nz)\height
vx#=qlimit( x-fx,-divs,divs)
vz#=qlimit( z-fz,-divs,divs)

;brightness
c#=.5+(divs-Sqr(vx*vx+vz*vz))/(divs)
r=terrain(nx,nz)\r * c
g=terrain(nx,nz)\g * c
b=terrain(nx,nz)\b * c

If Abs(vx)=divs Or Abs(vz)=divs
vy#=get_height( x_pos+vx , z_pos+vz)
EndIf

;vertex positions
For iz = 0 To ( z > -divs And z < divs+1 )
For ix = 0 To ( x > -divs And x < divs+1 )
x1 = ( x + divs ) * 2 - ( x > -divs ) + ix
z1 = ( z + divs ) * 2 - ( z > -divs ) + iz
v=x1+z1*(divg+1)
VertexCoords surf,v, vx * scale , vy , -vz * scale
Next
Next

;colours
For iz = 0 To (z < divs+1)
For ix = 0 To (x < divs+1)
x1 = ( x + divs ) * 2 + ix
z1 = ( z + divs ) * 2 + iz
v=x1+z1*(divg+1)
VertexColor surf,v,r,g,b
Next
Next

Next
Next

End Function

;=====================================================================================================
;GET HEIGHT OF POINT ON WORLD CO-ORDS =====================================================================================================
;=====================================================================================================

Function get_height(bx#,bz#)

bx=qwrap(bx,size):bz=qwrap(bz,size)
tx#=Floor(bx):tz#=Floor(bz)
jx#=bx - tx:jz#=bz - tz
cx#=qwrap(tx+1.0,size)
cz#=qwrap(tz+1.0,size)
v1#=terrain(tx,tz)\height+(terrain(cx,tz)\height-terrain(tx,tz)\height)*jx
v2#=terrain(tx,cz)\height+(terrain(cx,cz)\height-terrain(tx,cz)\height)*jx

Return v1+(v2-v1)*jz

End Function

;=====================================================================================================
;UPDATE CAMERA =====================================================================================================
;=====================================================================================================

Function update_camera()

PositionEntity target,0,divs*10+get_height(x_pos,z_pos)* 1.0,-divs*25
dx#=(EntityX(target,1)-EntityX(camera,1))*.1
dy#=(EntityY(target,1)-EntityY(camera,1))*.1
dz#=(EntityZ(target,1)-EntityZ(camera,1))*.1
TranslateEntity camera,dx,dy,dz

End Function

;=====================================================================================================
;UPDATE MAP =====================================================================================================
;=====================================================================================================

Function update_map()

SetBuffer TextureBuffer(map_tex)

For z=-2 To 2
For x=-2 To 2
xp=qwrap(last_x+x,size)
zp=qwrap(last_z+z,size)
Color terrain(xp,zp)\r,terrain(xp,zp)\g,terrain(xp,zp)\b
Plot xp,zp
Next
Next

For z=-2 To 2
For x=-2 To 2
xp=qwrap(Floor(x_pos)+x,size)
zp=qwrap(Floor(z_pos)+z,size)
Color 255,255,255
Plot xp,zp
Next
Next

SetBuffer BackBuffer()

last_x=Floor(x_pos)
last_z=Floor(z_pos)

End Function


;=====================================================================================================
;GENERATE RANDOM TERRAIN FOR TESTING =====================================================================================================
;=====================================================================================================

Function random_terrain(seed)

SeedRnd seed

;initialise
For z=0 To size-1
For x=0 To size-1
terrain(x,z) = New point
Next
Next

passes=50+Rand(150)

;do heights
For parts=0 To passes

start_x=Rand(0,size)
start_z=Rand(0,size)
rad#=Rand(1,32)
start_y#=Rand(8,32)

For z=-rad To rad
For x=-rad To rad
d#=Sqr(x*x+z*z)
If d < rad
py#=Cos(d/rad * 90) * start_y
px=qwrap(start_x+x,size)
pz=qwrap(start_z+z,size)
terrain(px,pz)\height = ( terrain(px,pz)\height + py )
EndIf
Next
Next
Next

;do colours - based on code from BIG&

For z=size-1 To 0 Step -1
For x=0 To size-1
th#=get_height(x+.5,z+.5)
terrain(x,z)\r = th+Rnd(80)
terrain(x,z)\g = th+120
terrain(x,z)\b = th+Rnd(80)
If th=0 ;*BODGE*Sea
terrain(x,z)\r=60+Rnd(20)
terrain(x,z)\g=60+Rnd(20)
terrain(x,z)\b=220+Rnd(20)
Else
If th < 12;*BODGE*Beach
terrain(x,z)\r=th *10+90
terrain(x,z)\g=th *10+90
terrain(x,z)\b=240-th *20
End If
End If
Next
Next
;*BODGE* Color Landing Pad
For z=-4 To 4
For x=-4 To 4
col=Rnd(32)+168
xp=qwrap(size*.5+x,size):zp=qwrap(size*.5+z,size)
If x >-4 And z >-4 terrain(xp,zp)\height=30
terrain(xp,zp)\r=col
terrain(xp,zp)\g=col
terrain(xp,zp)\b=col
Next
Next

;create map
map_tex=CreateTexture(256,256)
SetBuffer TextureBuffer(map_tex)
For z=0 To size-1
For x=0 To size-1
Color terrain(x,z)\r,terrain(x,z)\g,terrain(x,z)\b
Plot x,z
Next
Next

SetBuffer BackBuffer()
map=create_quad(camera)
PositionEntity map,-5,3,6
EntityTexture map,map_tex,0

End Function

;=====================================================================================================
;CREATE DISPLAY GRID =====================================================================================================
;=====================================================================================================

Function create_grid()

mesh=CreateMesh():s=CreateSurface(mesh)

For z=0 To divg
For x=0 To divg
v=AddVertex(s,0,0,0)
Next
Next

For z=0 To divg-1
For x=0 To divg-1
v0=x+z*(divg+1):v1=v0+1
v2=v1+divg+1:v3=v0+divg+1
AddTriangle s,v0,v1,v2
AddTriangle s,v2,v3,v0
Next
Next

EntityFX mesh,6
Return mesh

End Function

;=====================================================================================================
;=====================================================================================================
;=====================================================================================================

Function qlimit#(q#,a#,b#)

If q < a q=a
If q > b q=b
Return q

End Function

;=====================================================================================================
;=====================================================================================================
;=====================================================================================================

Function qwrap#(q#,a#)

If q >=a q=q-a
If q < 0 q=a+q
Return q

End Function

;=====================================================================================================
;=====================================================================================================
;=====================================================================================================

Function create_quad(parent=0)

mesh=CreateMesh(parent)
surface=CreateSurface(mesh)
AddVertex surface,-1,1,0,0,0
AddVertex surface,1,1,0,1,0
AddVertex surface,1,-1,0,1,1
AddVertex surface,-1,-1,0,0,1
AddTriangle surface,0,1,2
AddTriangle surface,2,3,0
Return mesh

End Function


CyberHeater(Posted 2003) [#26]
Brilliant and quite hypnotic...


PaulJG(Posted 2003) [#27]
Thanks Stevie !, good stuff - I've got loads of info and background material now. :)


joncom2000(Posted 2003) [#28]
Thanks for sharing the code. It's mint. I look forward to seeing some Virus/Zarch etc. games in the future.

I will give it a try myself as well :)


Pepsi(Posted 2003) [#29]
Hi Stevie, I saw this in the archives and rushed to find this thread! Just wanted to say thanks for sharing this code gem! Very cool Indeed :)


Big&(Posted 2003) [#30]
Awesome code Stevie. Just makes me feel damn feeble for giving up. :(

Cheers again.