3.10 OOP try

You can talk about anything related to LB Booster here, not covered in another category
Post Reply
bluatigro
Posts: 2
Joined: Sat Apr 14, 2018 6:35 am

3.10 OOP try

Post by bluatigro » Thu Oct 24, 2019 1:04 pm

i was trying some stuf in OOP

how do i do this good

Code: Select all

new a as class 1 , 2 , 3
new b as class 4 , 5 , 6


''new c as class::add b::x , b::y , b::z
print c
end
class v3d
  dim x , y , z
  sub class
    call v3d::class 0 , 0 , 0
  end sub
  sub class a , b , c
    x = a
    y = b
    z = c
  end sub
  function add( a , b , c )
    x = x + a
    y = y + b
    z = z + c
    new add as v3d::class x , y , z 
  end function
end class

guest
Site Admin
Posts: 77
Joined: Tue Apr 03, 2018 1:34 pm

Re: 3.10 OOP try

Post by guest » Thu Oct 24, 2019 2:16 pm

bluatigro wrote:
Thu Oct 24, 2019 1:04 pm
how do i do this
This works:

Code: Select all

new a as v3d 1, 2, 3
new b as v3d 4, 5, 6

call a::add 7, 8, 9
call b::add 10, 11, 12

call a::get d, e, f
call b::get g, h, i

discard a
discard b

print d, e, f
print g, h, i
end

class v3d
  dim x , y , z
  
  sub v3d
    x = 0
    y = 0
    z = 0
  end sub
  
  sub v3d a , b , c
    x = a
    y = b
    z = c
  end sub
  
  sub add a , b , c
    x += a
    y += b
    z += c
  end sub
  
  sub get byref a, byref b, byref c
    a = x
    b = y
    c = z
  end sub

end class

Post Reply