ultimate bubble generator :-P

Blitz3D Forums/Blitz3D Programming/ultimate bubble generator :-P

Trader3564(Posted 2007) [#1]
Based on a joke of me & big10p about bubbles hereby the code for a bubble generator :-P

;The ULTIMATE bubble generator!
;
;Worklog
;-------
;big10p 20-may-07, bubble mesh
;LeeMing 20-may-07, Tbubble, movement


Graphics3D 800,600,32
SetBuffer BackBuffer()

SeedRnd MilliSecs()

Global cam = CreateCamera()
CameraClsColor cam,50,0,100
PositionEntity cam,0,0,-5

Global light = CreateLight()
Global light2 = CreateLight()
TurnEntity light,50,90,0
TurnEntity light2,90,50,0

Global ang# = 0.0

Type Tbubble
	Field mesh
	Field uf# ;up force
End Type

For b=1 To 60
	bubble.Tbubble = New Tbubble
	bubble\mesh=makebubble()
	bubble\uf=Rnd(.1,.3)
	PositionEntity bubble\mesh, Rand(-80,80)/10, Rand(-70,70)/10, Rand(4)
Next

While Not KeyHit(1)

	For bubble.Tbubble = Each Tbubble
		ScaleEntity bubble\mesh,1+(Cos(ang)*0.05),1+(Sin(ang)*0.05),1+(Cos(ang)*0.05)
		ang = (ang + 10) Mod 360.0
		TurnEntity bubble\mesh,.5,.5,.5
		PositionEntity bubble\mesh,EntityX(bubble\mesh)+Rnd(-.1,.1),EntityY(bubble\mesh)+bubble\uf,EntityZ(bubble\mesh)
		
		If EntityY(bubble\mesh)>7 Then PositionEntity bubble\mesh,EntityX(bubble\mesh),EntityY(bubble\mesh)-14,EntityZ(bubble\mesh)
		;If EntityX(bubble\mesh)>4 Then PositionEntity bubble\mesh,EntityX(bubble\mesh)-8,EntityY(bubble\mesh),EntityZ(bubble\mesh)
		;If EntityX(bubble\mesh)<4 Then PositionEntity bubble\mesh,EntityX(bubble\mesh)+8,EntityY(bubble\mesh),EntityZ(bubble\mesh)
	Next

	RenderWorld
	Text 10,10, "The ULTIMATE bubble generator!"
	Flip True
Wend

End

Function makebubble()
	bubble = CreateSphere(32)	
	inside = CreateSphere(32)	
	FlipMesh inside
	AddMesh inside,bubble
	FreeEntity inside
	
	EntityShininess bubble,1
	EntityBlend bubble,3
	EntityFX bubble,2+32
	
	ss = 0
	ee = 55
	surf = GetSurface(bubble,1)
	For i = 0 To CountVertices(surf)-1
		VertexColor surf,i,Rand(ss,ee),Rand(ss,ee),Rand(ss,ee),1
	Next
	
	Return bubble
End Function



puki(Posted 2007) [#2]
I like this.


_33(Posted 2007) [#3]
Excellent! Nicely done.


Who was John Galt?(Posted 2007) [#4]
Is this for use with hot or cold drinks?


Trader3564(Posted 2007) [#5]
lol, whatever, i would say go with cold drinks :)