OOP Support (it is time)
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: OOP Support (it is time)
[Silly burger analogy deleted]
Last edited by MachineCode on Mon Mar 21, 2011 1:03 pm, edited 1 time in total.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
-
- User
- Posts: 52
- Joined: Wed Feb 04, 2009 8:11 am
- Location: Armenia
Re: OOP Support (it is time)
Looks like you right. I am......
And Gosh. Comparing Programming Language with a Burger ???....... not even close.
And Gosh. Comparing Programming Language with a Burger ???....... not even close.
Re: OOP Support (it is time)
@DaylightDreamer
I don't know anything about OOP, but your examples really caught my interest! Do you have some tips where I can find good'n'easy tutorials to understand/learn it?
I don't know anything about OOP, but your examples really caught my interest! Do you have some tips where I can find good'n'easy tutorials to understand/learn it?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
-
- User
- Posts: 52
- Joined: Wed Feb 04, 2009 8:11 am
- Location: Armenia
Re: OOP Support (it is time)
Of course.
The idea of OOP is to separate part of the code from the main code.
For example you have the request from the lead programmer to develop an enemy Object , also named Class.
The code gonna look something like like that
NONE of that will be visible in the main program.
And here how we gonna call it from the main code
here we have two independent enemies
and on each frame we can call the function from inside the object
This is basically it.
And of course you don't have to use all that and continue coding in procedural way.
This is basically it.
The idea of OOP is to separate part of the code from the main code.
For example you have the request from the lead programmer to develop an enemy Object , also named Class.
The code gonna look something like like that
Code: Select all
Class enemy
var enemy_health.l // This variable will be visible only inside this object and will not conflict with the main program
// and what is modified inside one function in this object later can be accessed from another function
Procedure enemy()
// Here We gona create our enemy, loading his models, sounds textures
EndProcedure
Procedure update_enemy()
// Here We gonna update our enemy step
//And Based on some conditions we might want to destroy ourself
EndProcedure
Procedure __destruct()
// This part of code will be called any time this object is deleted by some reason
// Here we will free our textures objects sounds
EndProcedure
EndClass
And here how we gonna call it from the main code
Code: Select all
enemy1 = new enemy()
enemy2 = new enemy()
and on each frame we can call the function from inside the object
Code: Select all
enemy1.update_enemy()
enemy2.update_enemy()
And of course you don't have to use all that and continue coding in procedural way.
This is basically it.
-
- User
- Posts: 52
- Joined: Wed Feb 04, 2009 8:11 am
- Location: Armenia
Re: OOP Support (it is time)
You can have one class name Enemy which will manage all the enemies on the stage and will free resources correctly.
Another name MainCharacter
Another named Bullet,Item,StageDecoration and so on.
And the coolest part that each Object can be developed by the separate person. And this person dont have to worry about conflicts with the main program.
Complex games are developed that way.
Another name MainCharacter
Another named Bullet,Item,StageDecoration and so on.
And the coolest part that each Object can be developed by the separate person. And this person dont have to worry about conflicts with the main program.
Complex games are developed that way.
-
- User
- Posts: 52
- Joined: Wed Feb 04, 2009 8:11 am
- Location: Armenia
Re: OOP Support (it is time)
And if you have questions i will gladly answer.
Re: OOP Support (it is time)
Thanks, but this can't be all: Isn't all this possible in PureBasic somehow? I think I've already seen code that works that way. I just remembered a tutorial by srod, gonna read that: http://www.purecoder.net/oop.zip
I don't see why there is so much discussion for something that simple...
I don't see why there is so much discussion for something that simple...
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
-
- User
- Posts: 52
- Joined: Wed Feb 04, 2009 8:11 am
- Location: Armenia
Re: OOP Support (it is time)
Well logically all this is nothing more than a Stricture with possibility to put Procedures inside.
This example is a recreation of OOP.
But with the syntax i described, on the background happens wht you see in this example.
It is simple once when you understand the theory.
I dont know if you familiar with DivGamesStudio created in Spain around 10 years ago.
There also had very interesting approach to game development.
You could create a function and this function could work in parallel with the main program.
This example is a recreation of OOP.
But with the syntax i described, on the background happens wht you see in this example.
It is simple once when you understand the theory.
I dont know if you familiar with DivGamesStudio created in Spain around 10 years ago.
There also had very interesting approach to game development.
You could create a function and this function could work in parallel with the main program.
Re: OOP Support (it is time)
Ok, I don't get these requests. At the end of the day, OOP has to unravel down to ASM. So why not take the step that was going to be C++? A precompiler!
Take this WORKING example in PureBasic:
That's using SimpleOOP, so if you want to make it a two pass compiler, why not do the first pass yourself ?
What is this incessant request to make it the core, when it's just another programming methodology, that the solution for it *already exists* ?
Take this WORKING example in PureBasic:
Code: Select all
EnableExplicit
Class Animal
Public Abstract Walk()
Public Abstract Sleep()
EndClass
Class Dog Extends Animal
Public Method Walk()
Debug "Im Walking Very Fast! Wuff!"
EndMethod
Public Method Sleep()
Debug "Im Sleeping Now! Wuff!"
EndMethod
EndClass
Class Turtle Extends Animal
Public Method Walk()
Debug "Im Walking Very Slow! Crawl!"
EndMethod
Public Method Sleep()
Debug "Im Sleeping Now! One Turtle, Two Turtle...!"
EndMethod
EndClass
Class Cat Extends Animal
Public Method Walk()
Debug "Im Walking! Miauw!"
EndMethod
Public Method Sleep()
Debug "Im Sleeping Now! Buzz...Buzzz!"
EndMethod
EndClass
NewList *Animals.Animal()
AddElement(*Animals())
*Animals() = NewObject.Dog
AddElement(*Animals())
*Animals() = NewObject.Turtle
AddElement(*Animals())
*Animals() = NewObject.Cat
ForEach *Animals()
*Animals()\Walk()
*Animals()\Sleep()
Next
What is this incessant request to make it the core, when it's just another programming methodology, that the solution for it *already exists* ?
-
- User
- Posts: 52
- Joined: Wed Feb 04, 2009 8:11 am
- Location: Armenia
Re: OOP Support (it is time)
Another very important thing it is stability.
In complex program i might create 100 or 1000 objects (explosion particles)
And after completing its animation each particle will destroy itself.
Did you play Gradius ? Remember how many moving objects do you have on the screen ?
Each one is a separate "Object,Class"
And each object destroys itself one he goes outside the screen.
If two pass precompiler can handle that without crashing i don't have problem with that.
In complex program i might create 100 or 1000 objects (explosion particles)
And after completing its animation each particle will destroy itself.
Did you play Gradius ? Remember how many moving objects do you have on the screen ?
Each one is a separate "Object,Class"
And each object destroys itself one he goes outside the screen.
If two pass precompiler can handle that without crashing i don't have problem with that.
Re: OOP Support (it is time)
Well, give it a go, and then tell us (and the author) how it goes. Perhaps you can march the way forward for using OOP in PureBasic.
Re: OOP Support (it is time)
Thanks, Foz for your contribution.
Nice to see that anyone else but me is using SimpleOOP
(not to confuse anyone. I'm not the author. I just use it and think it's a great alternative to waiting for ages for everybody who wants oop in pb)
I am actually kinda used to the procedural programming. Because I never had anything else.
PB is procedural and so are the many tutorials on php (since they added oop only in version 5).
So I don't feel the need to add oop to PB. But it's a nice to have and for this purpose the precompiler does its job quite well, I think.
I'm with Foz on this one. Give it a go!
Nice to see that anyone else but me is using SimpleOOP

(not to confuse anyone. I'm not the author. I just use it and think it's a great alternative to waiting for ages for everybody who wants oop in pb)
I am actually kinda used to the procedural programming. Because I never had anything else.
PB is procedural and so are the many tutorials on php (since they added oop only in version 5).
So I don't feel the need to add oop to PB. But it's a nice to have and for this purpose the precompiler does its job quite well, I think.
I'm with Foz on this one. Give it a go!
Re: OOP Support (it is time)
I heard there are at least 3 good-working precompilers for PureBasic (SimpleOOP being one of them). Which one do you prefer most?
Sure every has its pros and cons but for me - as a total beginner in this matter - it's hard to differentiate them.
Any tips? Is SimpleOOP the best one?
Sure every has its pros and cons but for me - as a total beginner in this matter - it's hard to differentiate them.
Any tips? Is SimpleOOP the best one?

If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: OOP Support (it is time)
I use SimpleOOP. But honestly I haven't tried the others.
I don't know which one is better. I imagine there are slight differences in syntax, or maybe not.
You could install 3 new PBs and test them yourself.
Since there seem to be only few users of oop-precomilers, profound advice on which one to take is probably very hard to find.
SimpleOOP comes with a ton of easy to understand, well documented examples that explain syntax and how to use oop with it generally.
But I think the concept of Inheritance it not fully developed. I don't know about the others.
But for getting oop to know it's as good as any.
If you find you push the limits of simpleOOP, try another one.
But that won't happen so fast, I think.

I don't know which one is better. I imagine there are slight differences in syntax, or maybe not.
You could install 3 new PBs and test them yourself.
Since there seem to be only few users of oop-precomilers, profound advice on which one to take is probably very hard to find.
SimpleOOP comes with a ton of easy to understand, well documented examples that explain syntax and how to use oop with it generally.
But I think the concept of Inheritance it not fully developed. I don't know about the others.
But for getting oop to know it's as good as any.
If you find you push the limits of simpleOOP, try another one.
But that won't happen so fast, I think.
Re: OOP Support (it is time)
Of the others, I prefer the syntax of SimpleOOP, for one reason: procedures in the classes (I can relate to that syntax due to using VB.net at work)
I believe that if *everyone* (including the team) used the same OOP precompiler, I would think that it would be integrated into the core in short order, regardless of Feature Requests for OOP.
That said, I don't use really use OOP with PureBasic, as I prefer working procedurally.
I believe that if *everyone* (including the team) used the same OOP precompiler, I would think that it would be integrated into the core in short order, regardless of Feature Requests for OOP.
That said, I don't use really use OOP with PureBasic, as I prefer working procedurally.