How to do basic variables - HWC topic remake

howto
riphwc

#1

Once again, this is from November and hasn't been read. :stuck_out_tongue:

NOTE: I will go through and add to this. I need to update the images and include self.

Hi, I'm @TheMasterOfAirjitzu.

I am going to teach you some cool things to do with variables.

Variables are numbers you can change in projects using these blocks:

Now, I will show you the default values and what they do.

Default Values

Default Values

Both characters and the device have values. Default values are changed by thing in game, not blocks.

Those are the device's default values.

Width

Width is the width of the screen. In landscape, it is 1024, and in portrait it is 768.

Height

Height is the height of the screen. In landscape it is 768 and in portrait, 1024.
Useful for making backgrounds

Tilt up %

This is how tilted up the iPad is.

Tilt down %

This is how tilted down the iPad is.

Tilt left %

This is how tilted left the iPad is.
This is good for making driving games.

Tilt right %

This is how tilted right the iPad is.
Good for making driving games

Last touch X

This is the location of the last touch on X.
Essential to drawing tools

Last touch Y

This is the location of the last touch on Y
Essential to drawing tools

So that's all the default iPad values, but characters have them too.

Rotation

This is the object's angle from the bottom of device in degrees. Edited by the set angle and turn blocks.
Clones have this to themselves

X Position

This is the object's Location on X, edited by move forward, change X, and set position blocks.
Useful for making backgrounds
Clones have this to themselves

Y Position

This is the object's Location on Y, edited by move forward, change Y, and set position blocks.
Clones have this to themselves

Invisibility as a %

The object's invisibility, edited by the set invisibility block.
Clones have this to themselves

Size as a %

The object's size, edited by the set size, grow by, and shrink by blocks.
Clones have this to themselves

Speed

The object's speed, edited by set speed blocks.
Doesn't effect set position
Clones have this to themselves

You may have noticed a new value button. This creates values.

Creating values

Creating values

1.

Select the device to make a value.

2.

Tap "new value"

3.

Name your value.

Values you created can be changed by any value block, no matter what. Let's look at the value blocks again:

I will now teach you set value:

Set Value

Set Value

With set value, you can set any value (besides the default ones) to whatever you like. The first bubble is for the value being set. The second is for what it's being set to. A number, a math problem, even another value!

Set value can be used for high scores, levels, even websites and iPads! (Although the last two are easier thanks to the new "when" blocks)

Setting values to other values

Setting values to other values works like this: it gets set to the second value at the time of the set value block. Example:

You may think 1 will = 1, but because 2 hasn't changed yet, it'll = 0.

Ah! Now that you have a basic understanding of set value, we will learn the next value block!
Let's see what it is:

Oh, increase value! You'll love this if you're into making timer based games, scores, and more!

Increase Value

Increase value is simple and useful, once you understand it.

Bringing values up

To bring a value up, put the value you wish to increase in the first bubble, and what you are adding to it in the second. Using values for two bubbles is very similar to set value.

Bringing down a value

To bring down a value, simply use a negative number.

That's it!

I hope you enjoyed and learned a valuable lesson. I spent a while on this and it's my second "how to" this week.

I have more "how to"s
Make a Shop
Make "And" "Or" "When Blocks"
"Clean up" Code


#2

That is nice. This is good.


#3

Hehe, it's outdated ATM.

Seriously. ._. @FearlessPhoenix


#4

Good tutorial. This'll help the new HS/HSFers.


#5

Yes full on agree with fearless


#6

Of course you Do! XD Egoistic me!


#7

Well I actually agreed with u


#8

I know you did! XD

Seriously what, @Petrichor?


#9

I know u know I did. Gtg walk my cat


#10

This is a great topic for beginners learning Hopscotch! :D


#11

Wow this is lovely, I really like how you explained each of the default variables too :smiley:


#12

This is a really good topic! :thumbsup: