flkr - Extreme

Community Forums/Showcase/flkr - Extreme

TartanTangerine (was Indiepath)(Posted 2006) [#1]
I'm intruiged by new tech simulating old tech. One thing I've been playing with recently is attempting to simulate phosphor burn - ie. A pixel burns brighter the longer it's on the screen and fades slowly when removed. You get this effect on the old Vector Screens like the ones used in the original Asteroids game. So some time back I released the glowing lines mod that I see many people using today to create a nice glow effect to thier vector games. I wanted to add something more to that, something that would offer very subtle or very extreme effects. So I borrowed some old feedback/motion blur code of mine from the Morphlings games - here is the result.


http://indiepath.com/tim/extreme.rar

And the code.
Strict

Import indiepath.texturedpoly
Import indiepath.projmatrix

Global vObjectList:TList = New TList

Type vObject

	Field x#
	Field y#
	Field color1
	Field color2
	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)
		Local v:vObject = New vObject
		v.x = x
		v.y = y
		v.size = size
		v.angle = angle
		v.sides = sides
		v.color1 = Rand($FF222222,$FFFFFFFF)
		v.color2 = Rand($FF222222,$FFFFFFFF)

		v.vx = Rnd(-1,1)
		v.vy = Rnd(-1,1)
		v.rot = Rnd(-4,4)
	End Function
	
	Method Draw(image:tImage,frame:Int)
		DrawGeom(image,frame,self.x,self.y,self.sides,self.size,self.angle,self.color1,self.color2)
	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:+480
		If x >480 Then x:-480
		If y < 0 Then y:+360
		If y > 360 Then y:-360
	End Method
	
	Function DrawAll(image:Timage,frame:Int)
	
		TPoly._Begin()
	
		For Local v:vObject = EachIn vObjectList
			v.Update()
			v.Draw(image,frame)
		Next
		
		TPoly._End()
	End Function
	
End Type


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


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

	Local aStep# = 360.0 / sides
	Length# = (length/2)/Sin(aStep#/2)  		
	
	'Local temp# = ((Sin(MilliSecs()/5) + 1) * 10) + 10
				
	For Local a:Float = 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)
		TPoly.Line(image,frame,x1,y1,c1,x2,y2,c2,20,True,True)	
	Next
	
End Function

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


AppTitle = "Subtle Glow - NOT!"

Graphics 640,480,0

projectionmatrix.Initialise(480,360)
tPoly.Initialise()

SeedRnd(MilliSecs())
SetAlpha(1)


Local temp:TImage = LoadAnimImage("glowing_dots.png",64,64,0,4,FILTEREDIMAGE|MIPMAPPEDIMAGE)

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

While Not KeyHit(KEY_ESCAPE)

	SetAlpha(1)
	SetBlend(LIGHTBLEND)
	vObject.DrawAll(temp,2)

	' This is the bit that provides the nice phosphor effect.
	DrawImage(temp,-100,-100) ' * Force a state change
	SetColor 0,0,0
	SetBlend(ALPHABLEND)
	SetAlpha(0.1)
	DrawRect 0,0,480,360

	Flip 

Wend

End







TartanTangerine (was Indiepath)(Posted 2006) [#2]
Now I go and do some proper work.


Vorderman(Posted 2006) [#3]
Everyone seems to be using the word extreme on the end of their game names - I'll have to change SRX to be called something else...


TartanTangerine (was Indiepath)(Posted 2006) [#4]
Extreme refers to the glow not the game. It's not a game anyway, maybe I should make it into a game and since I borrowed bits from GEOM I should call it "GEOM WARS EXTREME" :P


John Pickford(Posted 2006) [#5]
Let's buck the trend.

Coming Soon: Naked War Mild


Grisu(Posted 2006) [#6]
hehe.

"360" is another trend btw.


Grey Alien(Posted 2006) [#7]
Pentium Mellow Edition.

Indiepath: This looks cool. I don't really get how you achieve that overall glow effect though, guess it must be hidden in the modules? I see there is a glowingdots.png, do you use this to draw you lines one dot at a time?


Warpy(Posted 2006) [#8]
Damn JP, beat me to it!


Wiebo(Posted 2006) [#9]
Mildly Naked War


Grey Alien(Posted 2006) [#10]
oh, what sorta FPS can that code pull?


TartanTangerine (was Indiepath)(Posted 2006) [#11]
@Jake, each line is created from 6 triangles using 8 vertices. I use the vertex UV to tell the renderer how to texture the line. The ends of the line are textured using the left side and right sides of the dot texture. The length of the line is textured using the very centre line of the dot texture, this is then stretched the length of the line. You can also specify the color and alpha at either line end.

How fast is it? well it's just textured polys so you should be able to use in excess 100,000 and still maintain 60FPS.

The overall fade/blur is controlled by 4 lines :
	' This is the bit that provides the nice phosphor effect.
	SetBlend(ALPHABLEND)
	SetAlpha(0.09)
	SetColor 0,0,0
	DrawRect 0,0,480,360

You see I'm not using CLS, I'm using an Black Alpha Rectangle to slowly clear the contents. Play with the Alpha setting and see what happens SetAlpha(0.02) is crazy.


Yan(Posted 2006) [#12]
I played with something similar a while back, but without the fancy glowing lines...




Wiebo(Posted 2006) [#13]
Hah, that's really cool, and simple. nice one!


big10p(Posted 2006) [#14]
What does 'flkr' mean?


Boiled Sweets(Posted 2006) [#15]
Where to get ?

Import indiepath.texturedpoly
Import indiepath.projmatrix


TartanTangerine (was Indiepath)(Posted 2006) [#16]
http://modules.indiepath.com

flkr = Flicker = flkr.net = something new :)


Boiled Sweets(Posted 2006) [#17]
And are these mods and code free to use?


Grey Alien(Posted 2006) [#18]
Tim. Thanks for the answer, I get it now, cool. And that sounds FAST btw :-D


Boiled Sweets(Posted 2006) [#19]
Sorry but how do i install the mods?


TartanTangerine (was Indiepath)(Posted 2006) [#20]
Yes the stuff is free to use in freeware and commercial projects. All I ask is for a mention in your credits and let people know where you got the code from. The code may not be wrapped or supplied for sale as a part of or as a feature of a framework blah...blah...and you can't sell this stuff as your own..blah blah.. If Jake includes anything in his "Framework" then you can be assured that he has permission to do so.


TartanTangerine (was Indiepath)(Posted 2006) [#21]
Install the mods to you BlitzMax/mods folder. Your structure should look something like BlitzMax/mods/indiepath.mod/...

** Oh and I wanna play Thrust Extreme with this stuff in it please :) NOW!


big10p(Posted 2006) [#22]
Something new?! I should've guessed! :)


Boiled Sweets(Posted 2006) [#23]
ARGH!

I have /mod/indiepath.mod/texturedpoly.mod

this dir contains...

the docs and examples dirs and texturedpoly.mod but still it cannot find it!

Says cannot find interface for mode 'indiepath.texturedpoly'

Could some one please send me both mods zipped in in the correct folder structure so I can compile this excellent stuff...


TartanTangerine (was Indiepath)(Posted 2006) [#24]
Like this :
C:\Program Files\BlitzMax\mod\indiepath.mod\texturedpoly.mod



Grisu(Posted 2006) [#25]
Also you need "ProjMatrix.mod" for the example!

P.S. And you need to REBUILD MODULES too.


Boiled Sweets(Posted 2006) [#26]
I have that path setup...

Could someone send me theirs?

How do I rebuild modules MY OPTION IS GREYED OUT!

aarrghhh!


Grisu(Posted 2006) [#27]
You need to have mingw setup correctly on your system for a rebuild:
http://www.blitzbasic.com/Community/posts.php?topic=53442

Gimmi a min, sending you mine... 8)

Sent!


TartanTangerine (was Indiepath)(Posted 2006) [#28]
Oh and it works on Mac and Linux.


Boiled Sweets(Posted 2006) [#29]
Grisu,

thanks - builds but when I run I get unhandled exception trying to access field or method of null object

TPoly.Line(image,frame,x1,y1,c1,x2,y2,c2,20,True,True)

:-(


TartanTangerine (was Indiepath)(Posted 2006) [#30]
Have you got the image in the directory?


Boiled Sweets(Posted 2006) [#31]
Ooops - no - shoot me!


Grisu(Posted 2006) [#32]
*Kaboooooooooooooooooom* *click, click *Kabooooooooooom*

Just in case the first bullet missed... ;)


Grisu(Posted 2006) [#33]
@Tim:
For the Credits, what would you prefer?

Poly Module by:
1. Tim Fisher
2. Indiepath
3. www.indiepath.com


TartanTangerine (was Indiepath)(Posted 2006) [#34]
Indiepath please, send everyone to indiepath.com


Grisu(Posted 2006) [#35]
Ok, will do.

Don't know if this is overkill, but I like my tiny Extreme Credits. :)



Boiled Sweets(Posted 2006) [#36]
Grisu,

is that a game?

Indiepath - how d'ya get the exe so small - using upx?


Grisu(Posted 2006) [#37]
no, my credits window, it's an extremely boring app! :)


TartanTangerine (was Indiepath)(Posted 2006) [#38]
The .exe is UPX'd but it would be smaller if I only used the frameworks that were needed.


Grisu(Posted 2006) [#39]
Btw:
Have you tested the module under opengl win32?
It seems to crash my whole app after a while! 8)

Any ideas?


TartanTangerine (was Indiepath)(Posted 2006) [#40]
Actually OpenGL does not act as it should... Let me investigate.


Grisu(Posted 2006) [#41]
Thanks!


TartanTangerine (was Indiepath)(Posted 2006) [#42]
OpenGL had a state change problem it was easily solved by using this code.
	' This is the bit that provides the nice phosphor effect.
	DrawImage(temp,-100,-100) ' * Force a state change
	SetColor 0,0,0
	SetBlend(ALPHABLEND)
	SetAlpha(0.1)
	DrawRect 0,0,480,360

Not sure why you are getting a crash though, it's not happening here.


Grisu(Posted 2006) [#43]
The problem might be the fact that im using it inside a maxgui canvas, though I dont understand that it runs fine as long as I don't use the gldriver... :(


TartanTangerine (was Indiepath)(Posted 2006) [#44]
YUK did you say canvas? urrrgggh.


Grisu(Posted 2006) [#45]
Yes, CANAVS, as my app is full written with the bmx gui. *hell of work and I found nice gui bugs on the way*

*gets himself a plushy chainsaw*

As soon as my INFO window gets inactive, it crashes.

(pic deleted)

P.S.:
Well, I have given up. No sense in spending more time on this as I'm not writing a game with it. Was worth a try.