This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-04-16 12:56:13

Keba
Scratcher
Registered: 2010-04-16
Posts: 9

instances of objects

Hi there

I am an OOP developer and used to code with Scratch because of science lessons. Well, Scratch has some nice features and using BYOB there is even fun.  smile

Am I able to use any OOP basic features, for example to create instances of objects? I would like to add objects in runtime. Of course I could hide every possibly object, but that would be really, really dirty and lots of c/p work.

I have heard about Elements and that looks nice, but I am not sure whether I am able to use this with Scratch well...

I also like the FP paradigm, but it seems that Scratch forces me to use objects? And every object needs to by one sprite? Right? Can I change that behavior?

Kind regards, Keba.

Offline

 

#2 2010-04-16 14:00:01

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: instances of objects

Sadly, you can't create instances in normal scratch.
Some people have hacked a "clone" block, but that's as close as you will get. And your last question, I don't think you can change this...


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#3 2010-04-16 14:08:36

Keba
Scratcher
Registered: 2010-04-16
Posts: 9

Re: instances of objects

Hm, thanks...

Well, that clone block would be more than nothing. How to get it?

Offline

 

#4 2010-04-16 14:40:58

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: instances of objects

http://scratch.mit.edu/forums/viewtopic.php?id=33653


You can now reach me on Twitter @johnnydean1_

Offline

 

#5 2010-04-16 16:11:52

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: instances of objects

Hi Keba,

as has been pointed out above, Scratch does not (yet) support the concept of abstracting objects into classes and of creating instances. There have been some promising "cloning" hacks (the best one by far, btw, is right in the published source code itself - it's not the "clone hack" you'll find everywhere in these forums, but a simple, well integrated method in the source code named #cloneAndSend: which supports prototype-like instancing). If you dare a little Squeak Smalltalk, you can have a lot of fun with just a tiny modification to the source code (simply add another block to the block specs and evaluate the #buildBlockSpecDict method before saving the image).

I'm excited that you like BYOB! We're currently working on a substantially enhanced version that incorporates some fundamental ideas from Scheme/LISP and that will allow you to call another sprite's custom block by way of the

   [ attribute ]  of [ spritename ]

reporter block. Then you'll at least have real message passing, which is also a basic OOP feature  smile


Jens Mönig

Offline

 

#6 2010-04-18 07:58:52

Keba
Scratcher
Registered: 2010-04-16
Posts: 9

Re: instances of objects

Thanks for your answers  wink

>  If you dare a little Squeak Smalltalk, you can have a lot of fun with just a tiny modification to the source code (simply add another block to the block specs and evaluate the #buildBlockSpecDict method before saving the image).

Sounds nice, how to do that? Downloading the source files, editing them and then compiling, I assume? Well, I dont know how to compile on Windows (I am a Linux user). How do you do that?

Or need I an IDE to hack into the source?

//Edit: Hm, I see how to do that using the common Scratch. How do you do that using BYOB? How to turn fullscreen mode off in this mode (I cant shift-click on the R of SCRATCH, because there is no SCRATCH...)?

Last edited by Keba (2010-04-18 09:18:35)

Offline

 

#7 2010-04-18 09:58:07

Keba
Scratcher
Registered: 2010-04-16
Posts: 9

Re: instances of objects

Well, Jens, would you like to hack the clone block into BYOB? It seems you have removed the image editor for some reason... As you said, hacking the clone block into an image file is no big deal...

So it would be really, reeally nice, if you did that for me...

Kind regards, Keba.

Offline

 

#8 2010-04-18 12:33:40

Kingdaro
Scratcher
Registered: 2008-06-08
Posts: 100+

Re: instances of objects

Well, you could easily hack into the source code of BYOB and add the clone block posted on forums yourself through a tutorial that tells you.

Offline

 

#9 2010-04-26 18:30:43

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: instances of objects

To truly make it use instances, the best thing to do is use  the name block, because names are the only things that are not copied. One will be released in Slash when it comes out.

Offline

 

Board footer