Possible Suggestion: libfov ...

BlitzMax Forums/Brucey's Modules/Possible Suggestion: libfov ...

mic_pringle(Posted 2009) [#1]
@Brucey

As it seems you are on a roll with all your oldskool mods (gme, libtcod etc) could I perhaps offer up another one - libfov

I would have a go at this myself but I can't seem to get it to compile properly on OS X (although I believe this to be a problem at my end rather than with the lib itself) and also the sample included relies on SDL which would require some effort to get running on a Mac as you have to play around with SDLMain etc which I have no experience of.

I'll look forward to your response with fingers crossed.

Thanks

-Mic


mic_pringle(Posted 2009) [#2]
@Brucey

And another - MicroPather

I think these would be useful because they seperate out the different parts of the TCOD lib, so you can plug and play with what you need.

Also, I have seen the posts on the libtcod forums with regards to the unstability of the 1.5 release and the fact there's no timescale for it's release and feel these two libraries would go part way to replacing a lof of the available functionality available in libtcod.

Again, I would have stab at this myself but I know very little c++ and have no idea how to derive a BlitzMax type from a c++ class.

Thanks

-Mic


Brucey(Posted 2009) [#3]
Well, the libtcod example (included with the module) is working fine - apart from some image issues related to 1.5. But otherwise, it seems to be working much as it did before (in 1.4).


GW(Posted 2009) [#4]
Micropather would a great mod, but LibTcod already has several Fov algos available.


mic_pringle(Posted 2009) [#5]
@GW

As true as that is, the API in libfov is exceptionally easy to use and understand. Also if all you need are fov and pathfinding then libtcod is a little overkill.

That's why I thought about having separate mods. That way you can just pick an choose whatever you need.

@Brucey

Ah. I didn't realize that. With some of the libtcod authors comments on the forum it seemed as though there was a lot more issues. I think he even suggested leaving the 1.5 branch alone until a formal beta was released.

Let me know your thoughts. I'll be more than happy to help where I can.

Thanks

-Mic


GW(Posted 2009) [#6]
Here is the los i wrote for my roguelike engine. it seems a little inefficient but there is no performance hit.

Function UpdateLOS(m:tMonster, UpdateMap:Int = True)

	If m = Null Then RuntimeError("Null in LOScheck!")
	Local XX:Int, YY:Int
'reset all los for the map
	For xx = 0 To MAPWIDTH - 1
		For yy = 0 To MAPHEIGHT - 1
			If Map[xx, yy].InLOS = True Then
				Map[xx, yy].HasSeen = True
				Map[xx, yy].InLOS = False
			EndIf
		Next
	Next

	For Local angle:Float = 1 To 360 
		Local dist:Int = 0
		Local x:Float = Float(m.X) + 0.5 '// center of the cell
		Local y:Float = Float(m.y) + 0.5
		Local xmove:Float = Cos(angle)
		Local ymove:Float = Sin(angle)
	
		Repeat
			x = x + xmove
			y=y+ymove
			dist = dist + 1
			
			If dist >= m.Vision Then Exit '// vision range
			
			If X >= MAPWIDTH Then Exit
			If y >= MAPHEIGHT Then Exit
			If x < 0 Then Exit
			If y < 0 Then Exit
			
			Map[x, y].InLOS = True
			If Map[x, y].BlockVision Then Exit
			
		Forever
	Next
	
	Map[m.X, m.Y].InLOS = True 
	'// show monsters in los
	If m = player Then
		For Local o:tMonster = EachIn monsters
			If o <> Player Then
				o.visible=False
				If map[o.X,o.y].inLos = True Then
					o.visible = True
				End If
			EndIf
		Next
	EndIf

End Function



Brucey(Posted 2009) [#7]
With some of the libtcod authors comments on the forum it seemed as though there was a lot more issues.

I haven't noticed any, other than the image problems I've mentioned previously.

It was a lot of hacking to get it ported to work with the 1.5 code though... but generally it seems to work much as it did before.