How they glow....

Miscellaneous Forums/Blitz Showcase/How they glow....

My "Glowing Line" module is now complete, for DirectX anyway. It does work with OpenGL but lacks the tForm commands - hopefully someone can help here.

The module consists of 2 functions which are :-

- Textured Poly, you set the image, frame, position and UV for each vertex. This is similar to my old function but is now a seperate module, you DO NOT need to play with the official modules to make it work!

- GlowingLine, Utilises Textured.

Here is a sneek peek, I've overdone the glow a bit here to demonstrate the effect.

Check out the Demo *** : http://www.igloader.com/examples/glow.php



The following commands work with this Module :-

- SetColor
- SetBlend
- SetRotation
- SetScale
- SetTransform
- SetAlpha

The source for this demo
Strict

Import indiepath.texturedpoly

SetGraphicsDriver D3D7Max2DDriver()

Global vObjectList:Tlist = New Tlist

Type vObject

	Field x#
	Field y#
	Field red
	Field green
	Field blue
	Field size#
	Field angle#
	Field rot#
	Field sides
	Field vx#
	Field vy#
	
	Method New ()
            	If vObjectList = Null Then vObjectList = New TList
            	vObjectList.AddLast Self
    	End Method	
	
	Function Create(x#,y#,size#,angle#,sides:Int,red:Int,green:Int,blue:Int)
		Local v:vObject = New vObject
		v.x = x
		v.y = y
		v.size = size
		v.angle = angle
		v.sides = sides
		v.red = red
		v.green = green
		v.blue = blue
		v.vx = Rnd(-1,1)
		v.vy = Rnd(-1,1)
		v.rot = Rnd(-3,3)
	End Function
	
	Method Draw(image:tImage)
		SetColor Self.Red,Self.Green,Self.Blue
		DrawGeom(image,0,self.x,self.y,self.sides,self.size,self.angle)
	End Method
	
	Method Update()
		x:+ vx
		y:+ vy
		angle:+ rot
		If angle > 360 Then angle:-360
		If angle < 0 Then angle:+360
		If x < 0 Then x:+640
		If x >640 Then x:-640
		If y < 0 Then y:+480
		If y > 480 Then y:-480
	End Method
	
	Function DrawAll(image:Timage)
		For Local v:vObject = EachIn vObjectList
			v.Update()
			v.Draw(image)
		Next
	End Function
	
End Type


' //////////////****************************************************///////////////////////
' //////////////****************************************************///////////////////////
' //////////////****************************************************///////////////////////


Function DrawGeom(image:tImage,frame:Int,x#,y#,sides#,length#,angle#)

	Local aStep# = 360 / sides
	Length# = (length/2)/Sin(aStep#/2)  			
	Local temp# = ((Sin(MilliSecs()/5) + 1) * 10) + 10
				
	For Local a:Int = 0 To sides-1
		Local x1# = x# - (Sin(angle + (aStep * a))*length)
		Local y1# = y# - (Cos(angle + (aStep * a))*length)
		Local x2# = x# - (Sin(angle + (aStep * (a+1)))*length)
		Local y2# = y# - (Cos(angle + (aStep * (a+1)))*length)
		DrawGlowingLine(image,frame,x1,y1,x2,y2,temp)	
	Next
	
End Function

' //////////////****************************************************///////////////////////
' //////////////****************************************************///////////////////////
' //////////////****************************************************///////////////////////

Graphics 640,480,0

SeedRnd(MilliSecs())

SetBlend(ALPHABLEND)
SetAlpha(1)
SetBlend(LIGHTBLEND)

Local temp:TImage = LoadImage("glowing_dot.png",FILTEREDIMAGE)

For Local i:Int = 0 To 100
	vObject.Create(Rand(0,640),Rand(0,480),Rand(10,20),Rand(0,360),Rand(3,10),Rand(0,255),Rand(0,255),Rand(0,255))
Next

While Not KeyHit(KEY_ESCAPE)
	Cls
	vObject.DrawAll(temp)
	Flip

Wend

End


The texture applied to the polys is a simple image, this image can have many frames.

This could also be acheived quite simply on Blitz3D using pretty much the same code.

mmmm.... i cant see ur pictures.

.

Looks nice, perfect for another 360 Shooter! :)

This looks lush, roll on 720 Shooter!

Demo changed.

mmm, is it just me but i cant play the demo, i cant event visit ur site.. looks good tho :D

Use the CTRL button and the cursors

From the game example (which is great!) I sometimes see vertical lines moving around/toward the player. Is this a known problem?
They seem to be part of the enemies but it's difficult to tell.

Screen grabs:



Yeah I see what you mean, to be honest I just did a "find and replace" in the source code and rebuilt the project. It may have something to do with the rotation transformation which does appear to be broken at the moment.

Gah, the link just gives me a page that generates a MAV! Is this openGL? [edit], the second time I tried it worked fine.

Now Tim, have you been getting a teeny bit distracted lately?

Hey isn't this Tempest 2000? Did you just make that whole game or use some existing souce?

Distracted me? Na only today :P

This source comes with BMAX, I just changed the line drawing code.

Oh OK, you probably posted that already and I didn't read it. I wonder who gets more distracted you or me? I'm REAL bad. I love it when I have to visit clients for jobs as I can't get distracted there thus I actually earn some money.

Are you going to release it to us mortals when you've finished the opengl portion? I'd love to utilise this lovely piece of code.

Yes I will make this available when I get it all finished.

Looking good there, Indie =]

Nothing more to say beyond what has already been said, but I wanted to add that this looks really nice

Now works with OpenGL, I'm just going to fire up my Mac and test it on there..

Oh and I took the Scale and Rotation commands out, they were too much of a mess and did not work.

If you want to rotate you lines or polygons use maths like the rest of us :)

Bugger me, it works on the Mac!

http://www.blitzbasic.com/Community/posts.php?topic=55716

Come and get it.