HELP!!!!

Blitz3D Forums/Blitz3D Beginners Area/HELP!!!!

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

How's this?

you need blitz_bass_studio
, and Blitz3D\Games\TunnelRun\Media\tex0.bmp.


Graphics3D 1024,768,32
SetBuffer BackBuffer()
AutoMidHandle True
AmbientLight 255,255,255
Include "bass.bb"

BASS_Init(-1,44100,0,0,0)
BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD,50)

;Breath_Of_Heaven.mod
;Metalsynth.mod
;Over_Heat.mod
music = BASS_MusicLoad(0,"Over_Heat.mod",0,0,0,0) 



;pong
Type paddle
	Field image,x,y,score
End Type
Type ball
	Field image,x,y,dx,dy
End Type
Type tunnel
	Field tunnel,texture,texpos#,scrollspeed#,divfactor#,red,green,blue
End Type
Global p1.paddle = CreatePaddle(0,GraphicsHeight()-20,1)
Global p2.paddle = CreatePaddle(0,20,2)
Global ball.ball = CreateBall(GraphicsWidth()/2,GraphicsHeight()/2)
Global loopcount = 0
Global multiplayer = WB3D_Notify("Pong","Play 2 player?",4)
If multiplayer = 6 Then multiplayer = 1
If multiplayer = 7 Then multiplayer = 0
;pong

BASS_ChannelPlay(music,0)


cam = CreateCamera()
CameraFogMode = 1
;te = LoadTexture("tex0.bmp")


Global te = Vis("hollow oval")





Global t.tunnel = CreateTunnel(0,0,0,te,50,1200,50)



FPS = CreateTimer(40)
Repeat
	
	BASS_Update()
	Local vumono = BASS_ChannelGetLevel (music) ; vumeters
	Local vuleft = BASS_MakeLoWord (vumono)
	Local vuright = BASS_MakeHiWord (vumono)
	
	PositionEntity cam,0,0,vuright/52*2
	
	t\scrollspeed = vuleft*.000005
	
	If (vuleft+vuright/2)/52 > 500
		t\red = Rand(150,255)
		t\blue = Rand(150,255)
		t\green = Rand(150,255)
	EndIf
	
	
	If vuleft/52 > 5
		;AmbientLight Rand(100,255),Rand(100,255),Rand(100,255)
		UpdateTunnel(t)
	EndIf
	
	If (vuleft+vuright/2)/52 > 800
		num = Rand(1,7)
		Select num
			Case 1
				te = Vis("hollow oval")
			Case 2
				te = Vis("filled oval")
			Case 3
				te = Vis("hollow rect")
			Case 4
				te = Vis("filled rect")
			Case 5
				te = Vis("tex")
			Case 6
				te = Vis("tex alpha")
			Case 7
				te = Vis("tex add")
		End Select
		t\texture = te
		EntityTexture t\tunnel,t\texture
	EndIf
	
	
	RenderWorld()
	UpdatePong()
	;vumeter
	Color 255,0,0
	Rect 10,GraphicsHeight()/2-100,10,vuright/52,0
	Color 0,255,0
	Rect 0,GraphicsHeight()/2-100,10,vuleft/52,0
	Color 255,255,255
	Text 0,200,(vuleft+vuright/2)/52
	Flip
	Cls
	WaitTimer(FPS)
	If KeyHit(1) Then Exit
	loopcount = loopcount +1
Forever
BASS_Stop()
End

;pong
Function GetPaddle(b.ball)
	If b\y < GraphicsHeight()/2
		Return 2
	ElseIf b\y > GraphicsHeight()/2
		Return 1
	EndIf
End Function
Function CreatePaddle.paddle(x#,y#,num)
	p.paddle = New paddle
	If num = 1
		p\image = CreateImage(80,20)
		SetBuffer ImageBuffer(p\image)
		Color 50,50,255
		Rect 0,0,80,20,0
		SetBuffer BackBuffer()
		Color 255,255,255
	ElseIf num = 2
		p\image = CreateImage(80,20)
		SetBuffer ImageBuffer(p\image)
		Color 255,150,0
		Rect 0,0,80,20,0
		SetBuffer BackBuffer()
		Color 255,255,255
	EndIf
	p\x = x
	p\y = y
	Return p
End Function
Function CreateBall.ball(x#,y#)
	b.ball = New ball
	b\image = CreateImage(10,10)
	SetBuffer ImageBuffer(b\image)
	Color 255,0,0
	Oval 0,0,10,10,0
	SetBuffer BackBuffer()
	Color 255,255,255
	b\x = x
	b\y = y
	b\dx = 1
	b\dy = 1
	Bounce(b,"both")
	Return b
End Function
Function Bounce(b.ball,kind$="sideways")
	If kind = "sideways"
		b\dx = -Sgn(b\dx)*(Rand(3,5))
		b\x = b\x + (3*Sgn(b\dx))
	ElseIf kind = "both"
		
		b\dx = Sgn(b\dx)*Rand(-5,5)
		.test
		If b\dx = 0 Then b\dx = Rand(-5,5):Goto test
		
		paddle = GetPaddle(b)
		If paddle = 1
			b\y = b\y -10
		ElseIf paddle = 2
			b\y = b\y +10
		EndIf
		
		b\dy = -Sgn(b\dy)*(Rand(3,5))
		
	EndIf
End Function
Function UpdatePong()
		SeedRnd MilliSecs()
	For b.ball = Each ball
		DrawImage b\image,b\x,b\y
		b\x = b\x +b\dx
		b\y = b\y +b\dy
		If b\x > GraphicsWidth()
			Bounce(b)
		ElseIf b\x < 0
			Bounce(b)	
		EndIf
		
		If b\y > GraphicsHeight()
			p1\score = p1\score+1
			Delete ball
			ball.ball = CreateBall(GraphicsWidth()/2,GraphicsHeight()/2)
			Exit
		ElseIf b\y < 0
			p2\score = p2\score+1
			Delete ball
			ball.ball = CreateBall(GraphicsWidth()/2,GraphicsHeight()/2)
			Exit
		EndIf
		
		;Text 0,0,
		
		For p.paddle = Each paddle
			DrawImage p\image,p\x,p\y
			If p\x <= 0+40
				p\x = 0+40
			ElseIf p\x >= GraphicsWidth()-40
				p\x = GraphicsWidth()-40
			EndIf
			
				If ImagesCollide(b\image,b\x,b\y,0,p\image,p\x,p\y,0)
					Bounce(b,"both")
				EndIf
		Next
		
		Text 0,0,"p1: " + p1\score
		Text 0,12,"p2: " + p2\score
	Next
	
	If KeyDown(32)
		p1\x = p1\x +6
	ElseIf KeyDown(30)
		p1\x = p1\x -6
	EndIf

	If multiplayer = 1
		If KeyDown(205)
			p2\x = p2\x +6
		ElseIf KeyDown(203)
			p2\x = p2\x -6
		EndIf
	Else
		If ball\x-40 > p2\x
			p2\x = p2\x +6
		ElseIf ball\x+40 < p2\x
			p2\x = p2\x -6
		EndIf
	EndIf
End Function
;end pong



Function Vis(mode$)
	FreeTexture(te)
	Select mode
		Case "hollow oval"
			te = CreateTexture(20,20)
			SetBuffer TextureBuffer(te)
			Oval 0,0,20,20,0
			SetBuffer BackBuffer()
		Case "filled oval"
			te = CreateTexture(20,20)
			SetBuffer TextureBuffer(te)
			Oval 0,0,20,20,1
			SetBuffer BackBuffer()
		Case "hollow rect"
			te = CreateTexture(20,20)
			SetBuffer TextureBuffer(te)
			Rect 0,0,20,20,0
			SetBuffer BackBuffer()
		Case "filled rect"
			te = CreateTexture(20,20)
			SetBuffer TextureBuffer(te)
			Rect 0,0,20,20,1
			SetBuffer BackBuffer()
		Case "tex"
			te = LoadTexture("tex0.bmp")
		Case "tex alpha"
			te = LoadTexture("tex0.bmp",2)
			TextureBlend te,1
		Case "tex add"
			te = LoadTexture("tex0.bmp")
			TextureBlend te,3
		Default RuntimeError("")
	End Select
	Return te
End Function
Function CreateTunnel.tunnel(x#,y#,z#,texture,sx#,sy#,sz#,scrollspeed#=.01,divisionfactor#=1,red=255,green=255,blue=255)
	t.tunnel = New tunnel
	t\texture = texture
	t\tunnel = CreateCylinder(100,0)
	EntityTexture t\tunnel,t\texture
	FlipMesh t\tunnel
	ScaleEntity t\tunnel,sx,sy,sz
	PositionEntity t\tunnel,x,y,z
	RotateEntity t\tunnel,90,0,0
	t\scrollspeed = scrollspeed
	t\texpos = 0
	t\divfactor = divisionfactor
	t\red = red
	t\green = green
	t\blue = blue
	EntityColor t\tunnel,t\red,t\green,t\blue
	EntityType t\tunnel,tunnel_CT
	Return t
End Function
Function UpdateTunnel(t.tunnel,mode=True)
	t\red=t\red+Rand(-20,20)
	t\green=t\green+Rand(-20,20)
	t\blue=t\blue+Rand(-20,20)
	If t\red > 255 Then t\red = 255
	If t\green > 255 Then t\green = 255
	If t\blue > 255 Then t\blue = 255
	If t\red < 0 Then t\red = 0
	If t\green < 0 Then t\green = 0
	If t\blue < 0 Then t\blue = 0
	EntityColor t\tunnel,t\red,t\green,t\blue
	
	t\texpos=t\texpos+t\scrollspeed
	If t\texpos>1 Then t\texpos=t\texpos-1
	
	If mode = True
		PositionTexture t\texture,t\texpos/t\divfactor,t\texpos
	ElseIf mode = False	
		PositionTexture t\texture,0,t\texpos
	EndIf
End Function