A little Trig and IH Blobs!

Miscellaneous Forums/Blitz Showcase/A little Trig and IH Blobs!

(New thread here)

It has an actual name now! (blobulos)

(Larger)


Default Controls:
F1 - Toggle info/options page
S - Change blob influence mode
A - Change blob draw mode
LeftMouse - Draw (or delete a group of) blobs
RightMouse - Influence blobs
Space - Clear the current blob field

Download page (source and binaries):
http://hosted.filefront.com/poqls/2327272

Project page:
http://www.komiga.com/?q=node/12

Woah!! Try using DrawLine for the texture generation too :P

You killed my gpu...less than 1 frame per second in either opengl or dx. :) I can at least run it when I create 120 TEnemy instead of 1200. lol..

Very cool btw.

I can do upto like 2000 :P


EDIT: This one has a few changes (be sure to change the resolution)
SuperStrict

Framework brl.standardio
Import BaH.random

Import brl.glmax2d

SetGraphicsDriver(GLMax2DDriver())

Graphics 1440, 900


Type TEnemy
  
  Global _list:TList = New(TList)
	
	Field xpos:Float, ypos:Float, osize:Float, ospeed:Float, angle:Float, pulse_angle:Float, pdir:Int
	
		Method New()
			_list.AddLast(Self)
		End Method
		
		Method Create:TEnemy(_xpos:Float, _ypos:Float, _osize:Float, _ospeed:Float, _pulse_angle:Float)
			
			xpos = _xpos; ypos = _ypos
			osize = _osize; ospeed = _ospeed
			pulse_angle = _pulse_angle
			
		   Return Self
		   
		End Method
		
		Method Draw(to_x:Float, to_y:Float, chase:Int, chasetype:Int)
		  Local angle:Float
			If chasetype = True
				angle = AngleFromPoints(xpos, ypos, to_x, to_y)
			Else If chasetype = False
				angle = AngleFromPoints(to_x, to_y, xpos, ypos)
			End If
			
		  Local xspeed:Float = Cos(angle), yspeed:Float = Sin(angle)
		  Local csize:Float = (osize + Sin(pulse_angle)) / 10.0
		  
			If chase = True
				xpos:+xspeed * ospeed
				ypos:+yspeed * ospeed
			End If
			
			'SetColor(255, 255, 255)
			'DrawOvalUnfilled(xpos - csize, ypos - csize, csize * 2, csize * 2)
			'DrawOval(xpos - csize, ypos - csize, csize * 2, csize * 2)
			SetColor(xspeed * pulse_angle, yspeed * pulse_angle, (yspeed - xspeed) * pulse_angle)
			'SetColor 25, 25, 25
			
			SetRotation(angle)
			SetScale(csize, csize)
			DrawImage(gradient, xpos, ypos)
			
			'SetColor(255, 0, 0)
			'DrawLine(xpos, ypos, xpos + (xspeed * csize), ypos + (yspeed * csize))
			
			If pulse_angle >= 360.0 Or pulse_angle <= 180.0 Then pdir:~ 1
			
			If pdir = True Then pulse_angle:+5.0 Else pulse_angle:-5.0
		
		End Method
		
		
		Function DrawAll(to_x:Float, to_y:Float, chase:Int, chasetype:Int)
			
			For Local nme:TEnemy = EachIn _list
				
				nme.Draw(to_x, to_y, chase, chasetype)
				
			Next
			
		End Function
		
End Type


Local intensity:Float = 6.5

For Local i:Int = 1 To 2000
	
	New(TEnemy).Create(Rnd(0, GraphicsWidth()), Rnd(0, GraphicsHeight()), Rnd(2.5, intensity), Rnd(3.5, 6.0), Rnd(180.0, 360.0))
	
Next

AutoMidHandle(True)
'Draw a blobby energy field with squared falloff
Local size:Int = 256
For Local Radius:Float = 1 Until size Step 0.5
  Local Energy:Float = (Radius * Radius) / 1024.0
	
	SetColor(Energy, Energy, Energy)
	'DrawOval(Radius / 2.0, Radius / 2.0, size - Radius, size - Radius)
	DrawRect(Radius / 2.0, Radius / 2.0, size - Radius, size - Radius)
	
Next

'Turn it into an image/texture
Global gradient:TImage = CreateImage(size, size)
GrabImage(gradient, 0, 0)

SetBlend(LIGHTBLEND)

Local antial:Int, chasetype:Int

While Not KeyHit(KEY_ESCAPE) And Not AppTerminate()
	
	Cls()
	'If antial > 2 Then Cls() ; antial = 0
		
		If KeyHit(KEY_SPACE) Then chasetype:~ 1
		
	  	TEnemy.DrawAll(MouseX(), MouseY(), MouseDown(MOUSE_LEFT), chasetype)
		
		'antial:+1
		
	Flip() ; Delay(10)
	
Wend

Function AngleFromPoints:Float(x1:Float, y1:Float, x2:Float, y2:Float)
	
	Return ATan2((y2 - y1), (x2 - x1)) + 180
	
End Function


Function DrawOvalUnfilled(x0:Float, y0:Float, w:Float, h:Float)
  Local xr:Float = w *.5
  Local yr:Float = h *.5
  Local segs:Int = Abs(xr) + Abs(yr)
		
	segs = Max(segs, 12) & ~3
	
	x0:+xr
	y0:+yr

	Local px:Float, py:Float

	'glBegin(GL_LINES)
	
	For Local i:Int = 0 Until segs + 1
	  Local th:Float = i * 360 / segs
	  Local X:Float = x0 + Cos(th) * xr
	  Local Y:Float = y0 - Sin(th) * yr
		
		If i > 0
			
			DrawLine px, py, X, Y
			
		End If
		
		px = X
		py = Y
		
	Next
	
	'glEnd()
	
End Function


rem
	  xspeed = Cos(angle)
	  yspeed = Sin(angle)
		
		If MouseDown(MOUSE_LEFT)
			pointx = pointx + xspeed * 8.0
			pointy = pointy + yspeed * 8.0
		End If
		
	  mz = defsize + Sin(pulse_angle) * 10
		
		If KeyHit(KEY_SPACE) Then chase:~1
		If chase = True
			angle = AngleFromPoints(pointx, pointy, MouseX(), MouseY())
		Else If chase = False
			angle = AngleFromPoints(MouseX(), MouseY(), pointx, pointy)
		End If
		
		DrawOvalUnfilled(pointx - mz, pointy - mz, mz * 2, mz * 2)
		'DrawOvalUnfilled(MouseX() - mz, MouseY() - mz, mz * 2, mz * 2)
		
		'SetColor(0, 0, 255)
		'DrawLine(pointx, pointy, MouseX(), MouseY())
		
		SetColor(255, 0, 0)
		DrawLine(pointx, pointy, pointx + (xspeed * mz), pointy + (yspeed * mz))
		
		
		SetColor(255, 255, 255)
		'DrawText("Angle: " + angle, 0, 0)
		
		If pulse_angle >= 360 Then pulse_angle = 0
		pulse_angle:+15
end rem






You need a lot of `fill rate` in your GPU to do blobs this way. I will check this out tonight ;-)

Hehehehe, nice! You certainly make me feel right at home! 8)

Yup, it's a little on the slow side here, too, but a neat idea! ;)
...very pretty!

doesnt work for me, youre using 1 or more non standard modules.

I had to remove all of the framework and import stuff to make it work on my end.

Me too, no Bah module, converted Rnd to Rand, and removed the framework. Interesting effect, not quite sure what you're trying to achieve with it though?

Nothing really, it just looked cool. I forgot no one has all of Brucey's module :x.

I'll change it for *standard* users.

I did download the BaH.random and appearantly had the rest, hehe... (?!)...so there were little problems. After winding the amount of items down to 500 it went fairly smooth. I think it looks neat, too.

Ahh that's better.. Changed again so the blobs are affected by range too.

Hehe, let me know when and how we can have a look at your changes?! :)

Have you checked out my alternative spaceship design, yet?
THREAD: alternative spaceship design for astroids clone

Thought you could get a kick out of it, too... ;}

Hehe, let me know when and how we can have a look at your changes?! :)
The code is already changed..
Have you checked out my alternative spaceship design, yet?
THREAD: alternative spaceship design for astroids clone

Thought you could get a kick out of it, too... ;}
I'm going to assume you meant to post that in the Star Opus thread :)

YES, but I didn't want to pollute it!
I've uploaded a new version, too, by the way!

I also thought already that you may have just changed the above code... guess I'm just to wrapped into my little space exploration! 8}

...just worte a tiny silly fractal noise type of thingy to make a big background nebula... kinda nice, but super primitive.

I also thought already that you may have just changed the above code... guess I'm just to wrapped into my little space exploration! 8}
Yes, I only updated the code at the top of the page - too busy with character rigging for uploads :P.

Ok.. Another change; now you can *paint* the blobs, and the colors are limited now (so they don't become invisible.)

EDIT: Also re-uploaded the binary (Linux binary coming tomorrow, though the same code already works :)

Updated! (see first post)

Fancier now!