Jump to content

OOP in BlitzMax


VeTaL
 Share

Recommended Posts

Faced the similar problem as Function/Method - maybe i'm missing something again?

 

1) I have a type/class of walker, it has a field scanPivot

Type TNodeWalker Extends TNode

Global nodesWalkers:TList = CreateList()
Field scanPivot:TEntity

 

TNode is base class, it consists of mesh and nodes list... but i decided to create also additional list nodesWalkers to search walkers faster

 

2) In constructor, i create scanner node

ListAddLast(nodesWalkers, Self)

scanPivot = CreateCube()
Local scanPos:TVec3 = EntityPosition(mesh)
scanPos.y:+16
scanPos.z:-10
PositionEntity(scanPivot, scanPos)
EntityParent(scanPivot, mesh)

 

Actually, at this point everything works fine, as planned: bot running forward, scanner flys before bot

1321908804-clip-23kb.jpg

 

Now, i'm calling from the main loop

Repeat
***
TNodeWalker.UpdateWalkersList()
***

 

This function is declared inside TNodeWalker and it is running throguh all walkers and call their UpdateWalkers()

Function UpdateWalkersList()
For n:TNodeWalker = EachIn nodesWalkers
	n.UpdateWalkers()
Next
EndFunction

 

in UpdateWalkers() i have:

Method UpdateWalkers()
pickFrom = EntityPosition(scanPivot)
DebugLog "scanPivot pos: " + pickFrom.x + " " + pickFrom.y + " " + pickFrom.z
EndMethod

 

The problem is that debugger shows

DebugLog:scanPivot pos: 0.000000000 -5.00000000 -10.0000000

DebugLog:scanPivot pos: 0.000000000 -5.00000000 -10.0000000

DebugLog:scanPivot pos: 0.000000000 -5.00000000 -10.0000000

DebugLog:scanPivot pos: 0.000000000 -5.00000000 -10.0000000

DebugLog:scanPivot pos: 0.000000000 -5.00000000 -10.0000000

DebugLog:scanPivot pos: 0.000000000 -5.00000000 -10.0000000

DebugLog:scanPivot pos: 0.000000000 -5.00000000 -10.0000000

 

So, looking like method cannot access class field ?

Working on LeaFAQ :)

Link to comment
Share on other sites

Okay, throwing out TNodeWalker.UpdateWalkersList()

 

Trying to call this one returns compilation error

Repeat
***
For n:TNodeWalker = EachIn nodesWalkers
       n.UpdateWalkers()
Next
***

 

 

This compiles, but output is still wrong

Repeat
***
For n:TNodeWalker = EachIn TNodeWalker.nodesWalkers
n.UpdateWalkers()
Next
***

 

PS: nodesWalkers is global list

Type TNodeWalker Extends TNode
Global nodesWalkers:TList = CreateList()

Working on LeaFAQ :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...