SAS modules

BlitzMax Forums/BlitzMax Programming/SAS modules

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