OOP question

BlitzMax Forums/BlitzMax Beginners Area/OOP question

Your first example is just as inconvenient as the old Blitz method:
Type tplayer
Field target
End Type

Type tvehicle
Field speed#
End Type

player.tplayer=New tplayer
vehicle.tvehicle=New tvehicle

player\target=Handle(vehicle)

vehicle.tvehicle=Object.tvehicle(vehicle)
If vehicle<>Null Notify vehicle\speed

Your second example looks like hell.

And finally, here it is with my old system I used to write 3D World Studio:
player=CreatePlayer()
vehicle=CreateVehicle()
SetPlayerTarget player,vehicle
target=PlayerTarget(player)
If ObjectClass(target)=CLASS_VEHICLE Notify VehicleSpeed(target)


The big advantage with mine is I can do things like this:
SelectObjectClass(PlayerTarget(player))
	Case CLASS_MONSTER

	Case CLASS_FLARE
		
	EndSelect


Although OOP could do this:
Type tEngineNode
Field target:tenginenode
	Method Update()
	EndMethod
EndType

Type tPlayer Extends tEngineNode
	Method Update()
	EndMethod
EndType

Type tVehicle Extends tEngineNode	
	Method Update()
		Notify 1
	EndMethod
EndType

player:tplayer=New tplayer
vehicle:tvehicle=New tvehicle
player.target=vehicle

player.target.update()


The fact that I can't call player.target.speed is really putting me off of types.