>clear >set decimals to 6 > >* For da loop >public lquit, ndotcolor, nstep >lquit = .F. >nstep = 0 > >SetupScreen() > >* Setup Initial Conditions >public oAbsoluteMatter >oAbsoluteMatter = createobject("collection") >rand(0) >for ln1 = 1 to 300 > oAbsoluteMatter.Add(createobject("absoluteMatter", 1, ranstr() , ranstr() , ranstr() , ; > ranstr() , ranstr() , ranstr() )) >endfor > > > >* Perform rules >do while not lquit > _screen.Caption = "VFP Monads Step: " + transform(nstep) > > RefreshScreen() > ndotcolor = rand() * 16777215 > > for each oA in oAbsoluteMatter > oA.DoStuff() > endfor > nstep = nstep + 1 >enddo >* end of program > >function ranstr >return rand() * 100000 - 50000 > >*class definitions >define class absoluteMatter as Custom > nType = 0 > nX = 0 > nY = 0 > nZ = 0 > nDx = 0 > nDy = 0 > nDz = 0 > > procedure Init(tnType, tnX, tnY, tnZ, tnDx, tnDy, tnDz) > > this.nType = tnType > this.nX = tnX > this.nY = tnY > this.nZ = tnZ > this.nDx = tnDx > this.nDy = tnDy > this.nDz = tnDz > > endproc > > procedure DoStuff > > * draw us visuall on the screen >* ?str(this.nType) + str(this.nX) + str(this.nY) > _screen.FillStyle = 0 > _screen.FillColor = ndotcolor && iif(this.nType = 1, rgb(255, 0, 0), rgb(0, 0, 255)) > _screen.Circle(2, this.nX / n_scale + x_offset, this.nY / n_scale + y_offset) >* This is for mapping z >* _screen.Circle(2, this.nZ / n_scale + x_offset, this.nY / n_scale + y_offset) > > > * move inertially > this.nX = this.nX + this.nDx > this.nY = this.nY + this.nDy > this.nZ = this.nZ + this.nDz > > * see if there's anything to interact with > for each oB in oAbsoluteMatter > lnDx = oB.nDx > lnDy = oB.nDy > lnDz = oB.nDz > oB.nDx = this.nDx > oB.nDy = this.nDy > oB.nDz = this.nDz > this.nDx = lnDx > this.nDy = lnDy > this.nDz = lnDz > endfor > > endproc >enddefine > > >function SetupScreen > public n_scale, x_offset, y_offset > n_scale = 5000 > x_offset = _screen.Width / 2 > y_offset = _screen.Height / 2 > > > * Buttons > if type("_screen.cmdZoomIn") = "O" > _screen.RemoveObject("cmdZoomIn") > endif > _screen.AddObject("cmdZoomIn", "zoomin") > _screen.cmdZoomIn.Caption = "+" > _screen.cmdZoomIn.Visible = .T. > > if type("_screen.cmdZoomOut") = "O" > _screen.RemoveObject("cmdZoomOut") > endif > _screen.AddObject("cmdZoomOut", "zoomout") > _screen.cmdZoomOut.Caption = "-" > _screen.cmdZoomOut.Top = 60 > _screen.cmdZoomOut.Visible = .T. > > if type("_screen.cmdQuit") = "O" > _screen.RemoveObject("cmdQuit") > endif > _screen.AddObject("cmdQuit", "quit") > _screen.cmdQuit.Caption = "exit" > _screen.cmdQuit.Top = 80 > _screen.cmdQuit.Visible = .T. > > > if type("_screen.cmdUp") = "O" > _screen.RemoveObject("cmdUp") > endif > _screen.AddObject("cmdUp", "mup") > _screen.cmdUp.Caption = "" > _screen.cmdUp.Visible = .T. > _screen.cmdUp.Width = 40 > _screen.cmdUp.Top = 20 > _screen.cmdUp.Left = 40 > > if type("_screen.cmdDown") = "O" > _screen.RemoveObject("cmdDown") > endif > _screen.AddObject("cmdDown", "mdown") > _screen.cmdDown.Caption = "" > _screen.cmdDown.Visible = .T. > _screen.cmdDown.Width = 40 > _screen.cmdDown.Top = 40 > _screen.cmdDown.Left = 40 > > if type("_screen.cmdLeft") = "O" > _screen.RemoveObject("cmdLeft") > endif > _screen.AddObject("cmdLeft", "mleft") > _screen.cmdLeft.Caption = "" > _screen.cmdLeft.Visible = .T. > _screen.cmdLeft.Width = 40 > _screen.cmdLeft.Top = 30 > _screen.cmdLeft.Left = 0 > > if type("_screen.cmdRight") = "O" > _screen.RemoveObject("cmdRight") > endif > _screen.AddObject("cmdRight", "mright") > _screen.cmdRight.Caption = "" > _screen.cmdRight.Visible = .T. > _screen.cmdRight.Width = 40 > _screen.cmdRight.Top = 30 > _screen.cmdRight.Left = 80 > >return > >function RefreshScreen >* clear > doevents > _screen.Line(0, y_offset, _screen.Width, y_offset) > _screen.Line(x_offset, 0, x_offset, _screen.Height) >return > >define class zoomin as CommandButton > procedure click > n_scale = n_scale - 25000 > return >enddefine >define class zoomout as CommandButton > procedure click > n_scale = n_scale + 25000 > return >enddefine >define class mup as CommandButton > procedure click > y_offset = y_offset + 100 > return >enddefine >define class mdown as CommandButton > procedure click > y_offset = y_offset - 100 > return >enddefine >define class mright as CommandButton > procedure click > x_offset = x_offset - 100 > return >enddefine >define class mleft as CommandButton > procedure click > x_offset = x_offset + 100 > return >enddefine >define class quit as CommandButton > procedure click > lquit = .t. > return >enddefine >