Discuss Scratch

michael971
Scratcher
13 posts

Snap! user discussion

Question on creating a predicate function block. How do I define “true” and “False” in the return values of the block?
bharvey
Scratcher
1000+ posts

Snap! user discussion

michael971 wrote:

Question on creating a predicate function block. How do I define “true” and “False” in the return values of the block?
Hi. In the Operators menu, just after AND, OR, and NOT, you'll find a True block; if you click on the slider thingy it turns into a False block.

michael971
Scratcher
13 posts

Snap! user discussion

bharvey wrote:

michael971 wrote:

Question on creating a predicate function block. How do I define “true” and “False” in the return values of the block?
Hi. In the Operators menu, just after AND, OR, and NOT, you'll find a True block; if you click on the slider thingy it turns into a False block.

Awesome. Thanks!!
michael971
Scratcher
13 posts

Snap! user discussion

Can I rename a Sprite in SNAP
bharvey
Scratcher
1000+ posts

Snap! user discussion

michael971 wrote:

Can I rename a Sprite in SNAP
Sure, the text box at the top of the scripting area is editable. Just click in it.

Dale_Mahalko
New to Scratch
27 posts

Snap! user discussion

It appears the search function is screwed up on this website. I have engaged my Google-fu, to make this thread searchable:

Do a Google search for the keyword plus site:scratch.mit.edu/discuss/topic/4455

For example all results for the word “clone” in this dense Snap threadmess:

https://www.google.com/search?q=site%3Ascratch.mit.edu%2Fdiscuss%2Ftopic%2F4455+clone

Last edited by Dale_Mahalko (Aug. 8, 2017 03:58:54)

Dale_Mahalko
New to Scratch
27 posts

Snap! user discussion

Is there some sort of speed limit on how fast child sprite entities can be produced?

I am trying to make a fast side-scroller game and it is taking a ridiculously long time to draw the sprite-tiles that make up the world.

This is bad, as I need to be able to place a strip of 16 new tiles/sprites probably up to 1/30th of a second as the world scrolls left or right when the player is moving.

Enclosing the slow tile-placer code blocks with Warp does not help, and instead warp seems to break the placement of the tiles and they don't appear at all..

The tile cloner/placer:
http://i.imgur.com/iKghbbh.png

Project window…. “Super Snappy World”
http://i.imgur.com/gxzoJSF.png
bharvey
Scratcher
1000+ posts

Snap! user discussion

Dale_Mahalko wrote:

Is there some sort of speed limit on how fast child sprite entities can be produced?
No, there's no artificial slowdown.

One thing I noticed in your code is that you copy the variable Clone ID to a different variable, L_Clone.ID, when a clone is created. If you make Clone ID a sprite-local variable, then each clone you create will automatically get its own local Clone ID, so you don't have to copy it into a different variable. I'm guessing that the reason the display gets confused when you WARP the clone creation is that the global Clone ID has already changed for another clone creation before the previous clone gets to run.

Another thing you could try is to turn on turbo mode. (There's a block in Sensing to turn it on and off.) That will give running code priority over stage redisplay, so several clones will be created in each display cycle, while still letting each new clone run before the next clone is created.

P.S. If you click the left arrowhead ◄ on the LIST block at the top of the clone creation code it'll get rid of that input slot, which creates an empty list item that I'm guessing you don't really want.

P.P.S. Next time, if you share the project and include the shared URL in your message, we can actually try out ideas to improve it, instead of guessing.

bharvey
Scratcher
1000+ posts

Snap! user discussion

Hey, gang!

Please try out the beta 4.1 release! We'd like to try it out among friends before we make it official. It's at

http://snap.berkeley.edu/snapsource/dev/snap.html

The big change is sprite OOP with inheritance. If you don't remember how it worked in BYOB 3.1, you can read the chapter on sprite OOP in the old BYOB manual. It's a little different in Snap! 4.1, but you'll figure it out. There are also a bazillion little improvements, including bug fixes. If you find a bug, please report it on Github and be sure to specify that it's a 4.1 beta bug.

It'd be great if everyone always runs the dev version over the next month. Thanks!

PullJosh
Scratcher
1000+ posts

Snap! user discussion

Wow! This is really cool! I can't say that I know exactly how to utilize it, but I'm still thrilled that these new features exist.

Dale_Mahalko
New to Scratch
27 posts

Snap! user discussion

For some reason there is no way to easily tell a local variable from a regular global variable. Why do this?

And the way that variables are “all Local to a sprite” but not “individually Local to the script” is exceptionally weird. So I can have multiple scripts within a single sprite which all share the same so-called local variables? Um, no, this is not how it is done in the real world. You are teaching an invalid concept that is not used anywhere else and violates what the concept of “Local” is supposed to mean that every other language with locals uses. Why are we teaching students a wrong concept that will get them into trouble if they try to apply it anywhere else?

To get around all this and keep myself from getting confused, it appears I need to include the name of the script and whether the variable is local or global in the name.
L.RefreshScreen.MapX

Though even this is not exactly helpful because the list of variables is not sorted or apparently sortable.

Last edited by Dale_Mahalko (Aug. 8, 2017 17:34:46)

PullJosh
Scratcher
1000+ posts

Snap! user discussion

Dale_Mahalko wrote:

So I can have multiple scripts within a single sprite which all share the same so-called local variables?
I believe what you're looking for are “script variables”, which can be created using the appropriate block in the variables section.

bharvey
Scratcher
1000+ posts

Snap! user discussion

Dale_Mahalko wrote:

For some reason there is no way to easily tell a local variable from a regular global variable. Why do this?
It's a good idea to give a visible indication that a variable is sprite-local. It's on our list, probably soon since we're revisiting variables anyway for OOP.

Officially they're not called “local”; they're called “for this sprite only.” But that's too many syllables (or keystrokes) for use in conversation. I guess in the OOP world they're called “fields,” although a search for “object local variables” gets plenty of hits. I prefer to reserve “fields” for the pieces of a record in a database. I've used “instance variables” when teaching a class/instance OOP language. But, really, they are local; creating an object creates an environment frame just as calling a procedure does.

Languages in the Logo family, including Scratch and Snap!, take the position that we're not in the business of training professional computer programmers. Our mission is to bring programming to the masses. This has historically led to all sorts of informal language: “reporter” instead of “function” (whose CS usage is technically incorrect anyway, to a mathematician), “input” instead of “argument,” and so on. Technical jargon is valuable for specialists, but is also a barrier to entry for non-experts.

Dale_Mahalko
New to Scratch
27 posts

Snap! user discussion

Well if you want to view my uncommented experiment in progress, here you go.

I fully accept that the following is a mess. Everything is in flux and can change at moment's notice. I have used Scratch in the past, and I don't yet know all the new blocks added in Snap! so this will keep changing.

http://snap.berkeley.edu/snapsource/dev/snap.html#present:Username=lhs-dmahalko&ProjectName=Super%20Snappy%20World%20v.0.4.1

World data is stored as monospaced ASCII art in long rows of text in the stage, then converted into a 2D array. It's unclear if the 2D array is any faster or slower than reading single characters from a long line of text in a 1D array.

The block data looks unreadable because list data is not monospaced. (Is there a way to set a monospace font for list data?)

I see the project is able to save data statically between runs, but I'd rather re-initialize all stored data constants with each run. Eventually all variables will likely be renamed L. -local G. -global C. -constant

Copy and paste the following into Windows Notepad
Original display area is 24 wide by 16 tall

Original display area is 24 wide by 16 tall

Screen:A| Screen:B|
1 2 3 4
123456789012345678901234567890123456789012345678
01,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
02,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
03,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
04,,,,,,,,,,,,,,,,,,,NOP,,,,,,,,,,,,,,NOOP,,,,,,,,
05,,,,,,,,,,,,,,,,,,,TUV,,,,,NOOOP,,,,TUUV,,,,,,,,
06,,,,,,,,,,,,,,,,,,,,,,,,,,,TUUUV,,,,,,,,,,,,,,,,
07,,,,,,,,,,,,,,,,,,,,,,C,,,,,,,,,,,,,,,,,,,,,,,,,
08,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
09,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
10,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
11,,,,,,,,,,,,,,,,C,,,XMXCX,,,,,,,,,,,,,,,,,,,,,,,
12,,_,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,{},,,,,,,,
13,/H\,,,,,,,,,,,,,_,,,,,,,,,,{},,,,,,,,,,,,,,,,
14/HhH\,,,,,,dBBBb/H\,,,,dBb,,,,,,,,,,,,,,,,,,
15################################################
16################################################

(EDIT: My periods are being converted to ellipses.. by the website? using commas here)

Mapping data source:
http://www.mariouniverse.com/images/maps/nes/smb/1-1.png

Last edited by Dale_Mahalko (Aug. 8, 2017 20:17:59)

bharvey
Scratcher
1000+ posts

Snap! user discussion

I cleaned it up a little:

http://snap.berkeley.edu/snapsource/dev/snap.html#present:Username=bh&ProjectName=Super%20Snappy%20World%20v.0.4.1

It's still needlessly copying x-y values from global to sprite-local variables. I cleaned up the creation of the array of sprite type letters, although I'm thinking the actual play of the game will be faster if you do the conversion from type letters to actual sprites during the setup, so you'll have an array of sprites instead of an array of letters. (I did turn the list of eight sprite names into a list of sprites.)

Dale_Mahalko
New to Scratch
27 posts

Snap! user discussion

Um, heh, I'm not really expecting the author of the language to help fix up my noobishness. I need to read the manual on some of whatever you did there. “map() over()” … ???

The sprites contain an “am I cloned” check because all of them get the message to do stuff, and the uncloned original has no data so I get weird “undefined list” errors coming from the original.

I don't know yet what you refer to about duplicate local clone data. The plan is to scroll the world as expected. The clones need to know how to move together as a group, and all follow map.offset.

,

Having a few hundred sprite tiles on screen is not likely to be very fast. I'm sure it would be tons faster if I could just use the static sprites as stamps onto the background, and then move the background around, except the stage has nothing in the motion section. I don't know if it is possible to stamp patterns onto layers of sprites for “fake depth” multiplane / parallax scrolling.

I can see some ways to “cheat” graphically and make the scrolling faster. Big bitmaps are probably faster than tiny patterned sprites. The ground is nearly always solid so make a huge solid ground sprite, 2x as wide as the screen. When a hole is needed, place blue “hole” sprites over it.

Also the clouds, hills, pipes, and grass should probably be large single sprites rather than tiled pieces… that would cut the sprite count considerably.
Jonathan50
Scratcher
1000+ posts

Snap! user discussion

Yay! Is the INHERIT block the same as DELETE?

ae2d2bcb-e9e3-4f9c-a847-290d71bd8bfd 222ec087-6694-42cf-8c41-064e9066f004
bharvey
Scratcher
1000+ posts

Snap! user discussion

Jonathan50 wrote:

Yay! Is the INHERIT block the same as DELETE?
Yes.

bharvey
Scratcher
1000+ posts

Snap! user discussion

Dale_Mahalko wrote:

I need to read the manual on some of whatever you did there. “map() over()” … ???
Yeah, good idea! It says, call this reporter for each item of the list, and collect the results in a list. In this case, it says “find the sprite named ___” for each name in your list of sprite names, so you end up with a list of sprites. Then when you want to clone one, we don't have to search for the one you want.

I don't know yet what you refer to about duplicate local clone data.
You say “L.Clone.MapX prend la valeur Clone.X.New” but you could just make Clone.X a sprite-local variable and when you make a clone it'll get a copy of the parent's value automatically.

(By the way, do you know if there's some reason the translation isn't “donner à ( ) la valeur ( )”? All the other ones seem to be infinitives.)

Having a few hundred sprite tiles on screen is not likely to be very fast.
No, Jens has demo projects with 1000 clones. That's not the problem.

But I'd be tempted to try it this way: Have one tile sprite with eight costumes, each named with the single letter that you use in the array that represents the world. Fill the stage with clones of it. Then you can say

to redraw the world, shifted as desired.

Jonathan50
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

Yes.
Ok, thanks. Does “Release” in the right-click menu of a clone mean to turn it into a Scratch 2.0-like clone?

ae2d2bcb-e9e3-4f9c-a847-290d71bd8bfd 222ec087-6694-42cf-8c41-064e9066f004

Powered by DjangoBB

Standard | Mobile