Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About FB and object-orientation...
#21
:lol:

I think it should be this...

[Image: 6775500LG.jpg]
Reply
#22
How about a metalic robot/android horse!
That shoots lasers from it's eyes!

And breaths fire!!

AND THEN IT TAKES OVER THE WORLD!!

ALL HAIL THE MIGHTY HORSE OF FB!!!11


ahem...


I'll just.. go.. now... uhm... right...
Reply
#23
Quote:what about writing the "object" class yourself? tired or what? why should one need to have one autoinherited baseclass?
Perhaps you have a better idea. But imagine the standard-framework should be extended by some kind of balanced binary tree. Assuming FB doesn't have any kind of genericity like e.g. C++ or Eiffel nor it has a common base class like Java. How would wou write that tree?
There is no easy way. You could try to do it the C way and use some kind of void-pointer and pass a comperator-function-pointer used by the tree. But this is neither easy to use nor type safe but rather error prone.
Every modern language comes with a big collection framework. Blitz said I should do something usefull. Such a framework would be something that I'm interested in. But at the moment I don't see how to build such an easy to use collection framework.
Perhaps you (or anybody else here) have an idea?


Quote:"FB is nothing more than C with a clown suit": helium, do you really think i will answer or pay attention to anything you say after that?
Seems like you don't like clowns Wink

Seriously, I didn't want to attack you or your work in any way. Sorry.
Reply
#24
Wow, that got kinda off-subject, now, didn't it? :-D
color=blue]subxero - admin at this place.[/color]
Reply
#25
Helium? What is OOP? in the end it is still compiled to procedural code. I wrote small (very buggy) oop layer for fb in one night -Translates oop like code into procedural sequence. I'm sure someone as experienced programmer as you should't find it hard at all to write a full OOP layer with all inheritence and overloading stuff you so mutch miss in FB.
url]http://fbide.sourceforge.net/[/url]
Reply
#26
OMG

I have no experience with OOP. And it seems, that in future there comes FB-code, which I never understand.

For example in Java there existing a method called "paint".
And if you have created this method, it will always be called (and allways two times). This is illogically.


For examplee say it in FB:

If you have this program:
Code:
screen 1

print "begin the program"
othersub

sub paint
line (12,34)-(12,34), 1
print "Hello"
end sub

sub othersub
print "Hi, to all!"
end sub

Then in normal FB you have as output

Code:
begin the program
Hi, to all!

But in OOP FB there would be stand

Code:
Hello
Hello
begin the program
Hi, to all!

That is illogically.


If v1c integrated OOP support in FB, it would be nice, if anybody writes a very good tutorial about OOP.
And it must really very good, because I have some C++, Java and C# books at home. And the only thing I never understood is the OOP.

Greatings
theuserbl
Reply
#27
why so? I see no reason at all it would give this output.

OOP is actually just another way to look at programming -but some people like to think that if no oop then no programming. In OOP instead of designing more functins/subs and procedure sequence you design objects.
url]http://fbide.sourceforge.net/[/url]
Reply
#28
FB will be added classes. That means that you can define a class that contains functions and data (methods and attributes in OOP). It is just like a type structure but with functions.

It's very comfortable to use, i.e. you could have some kind of class for a spaceship in your game:

Code:
CLASS SpaceShip
   PRIVATE x AS INTEGER
   PRIVATE y AS INTEGER

   SUB SpaceShip (x AS INTEGER, y AS INTEGER)
      THIS.x = x
      THIS.y = y
   END SUB

   SUB setX (x AS INTEGER)
      THIS.x = x
   END SUB

   FUNCTION getX () AS INTEGER
      getX = x
   END FUNCTION

    ...

   SUB move(mx AS INTEGER, my AS INTEGER)
      x = x + mx
      y = y + my
   END SUB

   ...
END CLASS

DIM mySpaceShip AS NEW SpaceShip (160, 100)

PRINT mySpaceShip.getX()
Spaceship.move(10,-30)
...

Inheritance is not hard either, basicly you create a new class that adds stuff to an existing one, for example for a boss spaceship:

Code:
CLASS BossSpaceShip EXTENDS SpaceShip
   PRIVATE life AS INTEGER
   ...
END CLASS

Automaticly, an object of the class "BossSpaceShip" has all the attributes and methods that an object of the class "SpaceShip" has plus the new ones defined in that class.

Once you get used to it, it's not very hard, and it's awesome to share code among several developers. (btw, I invented this syntax, but looks cool, uh?)

...

(very Java'ish, but that's what I know well Wink)

theuserbl: What you say doesn't make sense. That paint method is called in java graphical applets when needed (when any applet component has to be redrawn due to several causes). This is done more or less automaticly 'cause of the nature of such method. But that doesn't mean that in a OO program methods are called automaticly. In fact they aren't.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#29
polymorphism, everything else is just like structs in c++
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
#30
Actually the inttention of having OO in FB is to solve the pointer references for function in a UDT as I'm understand it. Code such as this:

Code:
TYPE CALC
    Number as LONG
    Add    as FUNCTION(a as long, b as long) as integer
END TYPE

DECLARE FUNCTION CalcAdd (a as long, b as long) as integer

DIM Math AS CALC

    Math.Add = @Calc()
    
    Math.Number = Math.Add(3,7)
    Print Math.Number

FUNCTION CalcAdd (a as long, b as long) as integer
    CalcAdd = a+b
End Function

Into a shorter with auto-bind function address:

Code:
CLASS CALC
    Number as LONG
    FUNCTION Add (a as long, b as long) AS INTEGER
        Add = a+b
    END FUNCTION
END CLASS

DIM Math AS CALC

    Math.Number = Math.Add(3,7)
    Print Math.Number

So, it nothing to worry about FB turned into Java or NET. But I thing in Basic that New at DIM's alias is not neccessary.
= inc(¢) Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)