SAS modules

BlitzMax Forums/BlitzMax Programming/SAS modules

Here are my modules if anyone wants them.

http://www.scottshaver2000.com/forum/viewtopic.php?t=135

Sprite Behaviors AI (autonomus agents)
Playing Cards (for making card games)
Scrolling Tile Maps (for use with maps from my SAS Map Editor)
BitmapFonts (For loading and displaying bitmapped fonts like you see in graphics demos)

Fixed a bug in the sprite behaviors mod. The SetVelocityToVector method, it was setting the heading not the velocity.

new version is up, I fixed a bug with the image file path in the tilemaps module

Thanks Scott, nice contributions

new version:

tilemaps: add code to update map position based on time.
	Field moveSpeedX:Float = 0 ' the number of pixels to move each second in the x
	Field moveSpeedY:Float = 0 ' the number of pixels to move each second in the y
	
	'--------------------------------------------------------
	' update the map position automatically based on time
	'--------------------------------------------------------
	Method Update(time_elapsed:Double)
		SetPosition(mapX+(moveSpeedX*time_elapsed),mapY+(moveSpeedY*time_elapsed))
	EndMethod


Sprite Behaviors: added new method to Path type to copy on path to another

	Rem
	bbdoc: make this path the same as the specified path
	EndRem
	Method CopyFromPath(npath:Path)
		wayPoints = New TList
		For Local wp:Vector2D=EachIn npath.wayPoints
			wayPoints.AddLast(CreateVector(wp.x,wp.y))
		Next
		curWaypointIndex = 0
		looped = npath.looped
		dir = npath.dir
		bounce = npath.bounce
		If curWaypointIndex>=0 And curWaypointIndex<wayPoints.Count() Then
			curWaypoint = Vector2D(wayPoints.ValueAtIndex(curWaypointIndex)); 
		EndIf
	EndMethod


sprite behaviors: Added new method to the Sprite type to check for collisions.

	'-------------------------------------------------------------
	Rem
	bbdoc: Determine if this sprite and the passed in sprite have collided.
	about: 
	returns: true if a collsion occured
	EndRem
	Method IsCollision(s:Sprite)
		If Self = s Return False
		'calculate the distance between the positions of the entities
		Local ToEntity:Vector2D = SubtractVector(s.GetPosition(),GetPosition())
		Local DistFromEachOther:Double = ToEntity.Length()
		'If this distance is smaller than the sum of their radii Then this is a collision
		Local AmountOfOverLap:Double = GetCollisionRadius() + s.GetCollisionRadius() - DistFromEachOther
		If AmountOfOverLap >= 0 Then Return True
		Return False
	End Method
		


fixed another bug in the tilemaps stuff. when saving the map for a second time the image filename got lost.

new version:

changes to the sprite behaviors module SpriteEmitter type:

	Rem
	bbdoc: Set the number of seconds between updating particle alpha
	EndRem
	Method SetAlphaUpdateDelay(ad:Double)
		alphaUpdateDelay = ad
	EndMethod

	Rem
	bbdoc: Use this to put all sprites back into the emitter pool.
	EndRem
	Method RefreshPool()
		For Local loop:Int=0 To pool.length-1
			pool[loop].SetAlpha(0)
		Next
	EndMethod

	Rem
	bbdoc: Set the number of seconds between emitting particles
	EndRem
	Method SetEmitDelay(ed:Double)
		emitDelay = ed
	EndMethod
	
	Rem
	bbdoc: Set the number of seconds between updating particles
	EndRem
	Method SetUpdateDelay(ud:Double)
		particleUpdateDelay = ud
	EndMethod
	
	Rem
	bbdoc:  Updates the emitter and it's particles
	EndRem
	Method Update(time_elapsed:Double)
		totalTimeUpdated:+time_elapsed
		'Print "te="+time_elapsed+" ed="+emitDelay+" le="+lastEmit+" ms="+MilliSecs()
		If lastEmit+(1000*emitDelay)<MilliSecs() Then
			Emit()
			lastEmit = MilliSecs()
		EndIf
		If lastParticleUpdate+(1000*particleUpdateDelay)<MilliSecs() Then
			UpdateSpritePositions()
			lastParticleUpdate = MilliSecs()
		EndIf
		If lastAlphaUpdate+(1000*alphaUpdateDelay)<MilliSecs() Then
			UpdateSpriteAlphas()
			lastAlphaUpdate = MilliSecs()
		EndIf
	EndMethod
	
	Rem
	bbdoc: Update the current alpha of the particle sprites.
	about:
	End Rem
	Method UpdateSpriteAlphas()
		For Local loop:Int=0 To pool.length-1
			If pool[loop].GetAlpha()>0 Then
				pool[loop].SetAlpha(pool[loop].GetAlpha()-alphaDelta)
			EndIf
		Next
	End Method
			
	Rem
	bbdoc: Update the current position of the particle sprites by taking into account their current position, the velocity and the velocity angle.
	about:
	End Rem
	Method UpdateSpritePositions()
		For Local loop:Int=0 To pool.length-1
			If pool[loop].GetAlpha()>0 Then
				pool[loop].UpdatePosition()
				UpdatingPosition(pool[loop])
			EndIf
		Next
	End Method
	


new version: more SpriteEmitter changes