CP - Alien Breed Remake - 5

Miscellaneous Forums/Blitz Showcase/CP - Alien Breed Remake - 5

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

changed load function in map.bb, added LoadObjectFile function:
; load the map in
Function Load(filename$)

	If FileType(FileName$+".map") = 1
		filein = ReadFile(FileName$+".map")
		For layer = 0 To NumLayers
			For x=0 To 255
				For y=0 To 255
					map(x,y,layer)= ReadInt(filein)
				Next
			Next
		Next
		CloseFile filein
	Else
		DebugLog "Filename does not exist: " + FileName$+".map"
	EndIf
	
	LoadObjectFile(FileName$)
		
End Function


;;;;;;;;;;;;;;;;;;;;;;;;;;;
; FUNCTION LoadObjectFile ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function LoadObjectFile(FileName$)
	;load the object file
	For od.objdef=Each objdef
		Delete od
	Next
	
	If FileType(FileName$+".obj") = 1
		filein = ReadFile(FileName$+".obj")
		NumObjects=parse(ReadLine(filein),"=",1)		
		ReadLine(filein) ; blank space
		If NumObjects>0 Then
			Dim objectdef.objdef(NumObjects)
			For i=1 To NumObjects
				objectdef(i)=New objdef
				objectdef(i)\image=Trim(parse(ReadLine(filein),"=",1))				
				objectdef(i)\trigger=Trim(parse(ReadLine(filein),"=",1))			
				;add a separator to the start to make searching simpler
				If Left(objectdef(i)\trigger,1)<>"|" Then objectdef(i)\trigger="|"+objectdef(i)\trigger
				objectdef(i)\name=Trim(parse(ReadLine(filein),"=",1))			
				
				For n=1 To CountString(objectdef(i)\trigger,"|")
					objectdef(i)\script[n]=ReadLine(filein)
				Next
				ReadLine(filein); blank space
			Next
		End If
		DebugLog numObjects+" objects loaded from "+FileName+".obj"
		CloseFile filein
	Else
		DebugLog "Filename does not exist: " + FileName$+".obj"
	EndIf	
End Function


in editor-include.bb - function CreateRandomMap() add:
LoadObjectFile("maps\default") to the end of the function

This will set default.obj to any new map including the one that is created on startup.