Need some help on some code - please look


#1

So, if you have a series of large rectangles organised across the screen, and have them moving left (

Repeat Forever
Change X by -1024
Set position X 1024, Y 404

It is moving left and resetting its position beautifully! But, once its position reaches 0 the whole large rectangle will disappear and go to 1024 X. This is supposed to happen, but you can see it reset its position, so at 0 and 1024 there is a gap, and then the rectangle suddenly appears!

The objective of my question:
"Is there a way that large blocks can move across the screen with the illusion that it is coming from the "outer screen" and NOT showing when the large object reaches 0 it disappears and appears at the position 1024"

(A rectangle isn't the shape I'm using, that's just an example.)

Please help
-BlastFusion

Summary
Summary

List (127 tags)
@BB-Box
@Allyb
@Artistic_cat
@ArtyAnimal
@AvocadoDont
@AwesomeNachos
@Awesome_giraffe
@BaconStudios
@BerryFOX
@BlastFusion
@BubblegumCupcakeMix
@ButterBark
@celine
@ChocolateFox
@CodePerfect
@codingkit
@ColorlessCanvas
@ColourfulBlack
@ConnellCoder
@CreationsOfaNoob
@cupcakemaniac1
@Cutedolphin
@DatKawaiiPillow
@danaball20
@DECODECO
@DiamondDragon
@diss_track_queen
@DMF
@DragonMc
@Dylan329
@EmojiArts
@EmojisRUs
@Explorer_
@ExquisiteSoup
@FascinatingTreehouse
@FCD
@FearlessPhoenix
@FluffyMarshmellow
@FreshGuppy
@FunkyGoldfish
@GiraffeProductions
@GLaDOS_On_Da_Forum
@Goobrgrlrye
@gryphonroadblocks
@happy12345678910
@HappyPerson
@Himynameismeredith1
@Houseelf87
@HRR1213
@IKeudin
@ILoveFashion12
@Jess888
@Jojo
@JonnyGamer
@KawaiiHotDog
@Kayro
@kenlauescuadro
@KiraForPrez
@KoolM123
@Kosho
@kubajr
@KVJ
@LavenderArts
@LegendOfFriday
@Mei-The-Riolu
@Mothwolf
@Mr.rex
@NeoPixel
@Petrichor
@Paige1212
@Paydent12
@PerfectPanda24
@PianoGorilla2006
@PIANOMAN
@Pink_Roses
@Periwinkle_Dolphin
@Potter_Head
@PumpkinGirl
@Puppylulu
@PurpleStorybook
@Rainboom
@Rider
@RubyStars
@RubyWolf1
@ScarySweetheart
@Sensei_Coder
@shamrockcat
@Silverdolphin
@Skyarmygenral
@SnowGirl_Studios
@sophia71205
@StarKid
@StarryDream
@Steelhooves
@StRiKe_Charler123
@Strongerthanyou
@Sugarisyummy
@Sweater
@TACOCODE
@treefrogstudios
@TrevCoding
@UnderagedCoder1
@Valgo
@ValueGamesStudio
@Vortex.inc
@waddlemarco
@WasIdealessHere
@W-Healer
@WhiteFeathers
@William04GamerA
@Work_kids_coding
@Yellow_Mellow
@YuxinaYammy
@Zachyswag
Get the latest list here: http://forum.gethopscotch.com/t/official-mass-tag-list-omtl/168431


I need some help, on a game
#2

@ThinBuffalo? @Stradyvarious?


#3

You can make it set it's position outside of the screen, so you can't see it. Then you let it move across the screen until it reaches a position outside the screen where you can't see it. There you reset it.
@t1_hopscotch has invented a nice technique for making "Repeat until" blocks.


#4

Ok. Thanks.

How would "repeat until" blocks be relevant to this? I looked at @t1_hopscotch's code for this before.


#5

That doesn't exactly work.


#6

Actually it doesn't work at all


#7

@Creationsofanoob:

It sounds like you may be using Move Forward or Change X/Y. Those blocks only result in objects being displayed on the screen. Don't ask why, that's just the way THT decided to make the blocks work.

To position an object off of the screen, just use Set Position. Make sure X position is < 0 or > 1024, or that Y position is < 0
-Thinbuffalo


#8

Use Set Position and Wait in a repeat block to move your shapes off the screen.


#9

Yes, that's what I mean. Use set position until (repeat until) it reaches outside of the screen.


#10

Tag me again if you haven't figured out how yet.


#11

Ok, here's what you do:

What happens is, the block starts at -1124, 100 off the screen, it moves to 0 by removing 1124 from its X position. Then, it sets its position to [its position- 10 ] 10 times so that it is once again, 100 off the screen (10x10=100) this should make a smooth transition into it starting again. Play with the numbers if you like.


#12

Sorry that I don't have much time to add more things to others

it is true in relation to what you brought up with 'Move Forward vs Set Position' from ThinBuffalo and what Jojo and CreationsOfANoob added

More on repeat until in a project here though I don't use it for this later on.

Now that you say that, COAN, I didnt even really think of myself as inventing it or anything :thinking: until I searched up that project (wow, it looks pretty old from the date). it was partially inspired I guess by Emily from THT's projects (Dr. Em) using abilities inside each other for fractals.

I dont really claim credit for it though, hehe it just seems as natural in Hopscotch as when people used to use Repeat 9999999 when there was no Repeat Forever — using this in replacement of a Repeat Until)

I think a quick way for you BlastFusion might be to try replacing Change X by -1024 to:

Repeat times 1200
    Set Position X: (x position - 1) Y: 404

and then see how it goes (does it pop off the screen at the end?) and then you can change the other Set Position to an X coordinate that is further to the right of the screen

this doesn't explain much at all right now sorry :joy: I will add more in addition to any comments on this later on. (I am heading off the forum at the moment :upside_down:)


#13

Adding an extra column?


#14

Try using variables to work around the problem.


#15

@BlastFusion
A Do While Loop, while completely valid, isn't necessary here since the number of loops required for the movement is known in advance.

2 nested loops (one for the number of "steps" in each pass across the screen & one for the number of times to move across the screen) is likely a simpler approach for most to understand since Do While Loops are not a native Hopscotch functionality.

Similar to other's suggestions I'd use this. I just added the Speed variable to demonstrate how to easily change that characteristic of the movement since the Speed property doesn't apply here. Note: 55 is just the min distance to get my particular object off the screen. 110 is 2x since the full movement is into view, across the screen, & out of view.


#16

Wait.
Everyone besides ThinBuffalo, I have tried the set position method, and it isn't suitable for my scenario. I have cloned objects which need to be a certain distance apart and a laggy iPad will have a positional difference compared to a fast iPad.


#17

Oh yeah, this is a old draft since I have been working on this for ages. I don't think I have self.

Summary

Im screwed eh?


#18

You could try edit the JSON files and hack Self into your project


#19

What? Ha? Hack? How?


#20

I can't restart. And use self. I've done so much.