Discuss Scratch

Sigton
Scratcher
1000+ posts

Quick codegolf anyone?

To entertain myself I tried to make a platforming engine in the minimum blocks I could, and decided to turn it into a challenge.

Criteria:
• Left and right arrow keys move the sprite left and right at a velocity which can be set
• When not touching a certain color, the sprite accelerates at an acceleration which can be set
• When touching that color, the sprite moves upwards 1 pixel
• When touching that color and the up arrow key is pressed, the sprite's velocity is set to a value which can be chosen by the programmer without changing the block count
• Run at 30 FPS

All blocks are counted, including Booleans and reporters.

In the lead currently is MonsterOfTheDeep with 13 blocks.

Sigton

Last edited by Sigton (Sept. 20, 2016 06:32:39)

CodeLegend
Scratcher
500+ posts

Quick codegolf anyone?

Does there have to be velocity and friction in both axes?

And how accurate does the platform collision have to be? Can it land on a platform, fall through a little bit (whatever the velocity was), ‘float up’, and then bounce up and down a pixel on top of the platform? (this bothers me so much)
CodeLegend_test
Scratcher
11 posts

Quick codegolf anyone?

CodeLegend wrote:

Does there have to be velocity and friction in both axes?

And how accurate does the platform collision have to be? Can it land on a platform, fall through a little bit (whatever the velocity was), ‘float up’, and then bounce up and down a pixel on top of the platform? (this bothers me so much)
If it doesn't have to be super accurate, I can do it in four blocks with friction and velocity. Three blocks without.

EDIT: A super complicated method that may or may not work could do it in three blocks with velocity and friction. Obviously, those blocks are:
when green flag clicked
forever
go to x: (0) y: (0)//this block would be very large :^)
end
I won't pursue this option, maybe…

EDIT 2: After a little testing, I can confirm that this would in fact work. And it actually wouldn't be very difficult… I think I may choose this option after all.

EDIT 3: Got it working for basic platforming. Now I'll need to work on edge cases so it doesn't get stuck.

EDIT 4: Oh I totally forgot I can use the timer hat trick… Get ready to see it in two blocks.

EDIT 5: Done! Friction and velocity with just two blocks.

TL;DR:

Sigton wrote:

I got it down to 20 blocks. Anyone think they can top that?
Yes, yes I do.

Last edited by CodeLegend_test (Sept. 17, 2016 05:08:54)

Sigton
Scratcher
1000+ posts

Quick codegolf anyone?

I should've mentioned I was counting Booleans and reporters in that 20 blocks, sorry.
Great platformer though; 1 stack block is pretty neat

Sigton
Sigton
Scratcher
1000+ posts

Quick codegolf anyone?

My example with 17 blocks total. It works better than when I had 20 ironically

Sigton
_x-
Scratcher
52 posts

Quick codegolf anyone?

Sigton
Scratcher
1000+ posts

Quick codegolf anyone?

_x- wrote:

16 blocks
Clever, I've been looking for a trick like that

Sigton
CodeLegend
Scratcher
500+ posts

Quick codegolf anyone?

Sigton wrote:

I should've mentioned I was counting Booleans and reporters in that 20 blocks, sorry.
Great platformer though; 1 stack block is pretty neat

Sigton
Ah, that makes sense. In that case, it looks like it's not going to get any shorter than 16… Unless you use the timer hat trick like me. But that reduces it to 15 FPS.

EDIT: Although using the timer hat block only removes one block, I may be able to remove 2 blocks with it. Turbo mode will be required.

EDIT 2: Silly me. I forgot that you have to put booleans and reporters in the timer hat…

EDIT 3: 15 blocks, woo!

Last edited by CodeLegend (Sept. 17, 2016 15:39:40)

Sigton
Scratcher
1000+ posts

Quick codegolf anyone?

CodeLegend wrote:

Sigton wrote:

I should've mentioned I was counting Booleans and reporters in that 20 blocks, sorry.
Great platformer though; 1 stack block is pretty neat

Sigton
Ah, that makes sense. In that case, it looks like it's not going to get any shorter than 16… Unless you use the timer hat trick like me. But that reduces it to 15 FPS.

EDIT: Although using the timer hat block only removes one block, I may be able to remove 2 blocks with it. Turbo mode will be required.

EDIT 2: Silly me. I forgot that you have to put booleans and reporters in the timer hat…

EDIT 3: 15 blocks, woo!
Yeah, I doubt 16 is beatable

Sigton
-stache-
Scratcher
500+ posts

Quick codegolf anyone?

Sigton wrote:

CodeLegend wrote:

Sigton wrote:

I should've mentioned I was counting Booleans and reporters in that 20 blocks, sorry.
Great platformer though; 1 stack block is pretty neat

Sigton
Ah, that makes sense. In that case, it looks like it's not going to get any shorter than 16… Unless you use the timer hat trick like me. But that reduces it to 15 FPS.

EDIT: Although using the timer hat block only removes one block, I may be able to remove 2 blocks with it. Turbo mode will be required.

EDIT 2: Silly me. I forgot that you have to put booleans and reporters in the timer hat…

EDIT 3: 15 blocks, woo!
Yeah, I doubt 16 is beatable

Sigton
Uhm he just did 15…
Sigton
Scratcher
1000+ posts

Quick codegolf anyone?

-stache- wrote:

Uhm he just did 15…
That's what I meant to say xD

Sigton
_x-
Scratcher
52 posts

Quick codegolf anyone?

Jonathan50
Scratcher
1000+ posts

Quick codegolf anyone?

TheMonsterOfTheDeep
Scratcher
1000+ posts

Quick codegolf anyone?

TheMonsterOfTheDeep
Scratcher
1000+ posts

Quick codegolf anyone?

I guess it's not valid as there's no momentum…

I might work on that soon
_x-
Scratcher
52 posts

Quick codegolf anyone?

13 blocks

I also created a 20 block version with wall detection

Last edited by _x- (Sept. 18, 2016 00:49:20)

CodeLegend
Scratcher
500+ posts

Quick codegolf anyone?

Clearly we needed some more specific criteria
IcyCoder
Scratcher
1000+ posts

Quick codegolf anyone?

Gonna try this
Sigton
Scratcher
1000+ posts

Quick codegolf anyone?

CodeLegend wrote:

Clearly we needed some more specific criteria

Sigton wrote:

allows the player to jump, walk both left and right and fall with momentum
I was included in the OP.

Sigton
TheMonsterOfTheDeep
Scratcher
1000+ posts

Quick codegolf anyone?

Sigton wrote:

Sigton wrote:

allows the player to jump, walk both left and right and fall with momentum

My 11-block thing does have momentum; I think what you meant to say was acceleration.

Powered by DjangoBB