sexta-feira, 3 de janeiro de 2020

Starting with GFX

Hello, MiniScripters! Today i will tell a bit about GFX (Graphics Effects), and how to draw squares and ellipses. You need to know how to deal with this if you want to earn the Pixel Neophyte and the Pixel Master MiniScript Badges. You can see how to draw a shape by typing "help "graphics"" at MiniMicro. But now let's start.

With MiniMicro

Step 1


Type:

gfx.clear color.white

Step 2 


Type:
gfx.color = color.black


Step 3


Type:
gfx.fillEllipse 350, 200 , 200, 200


Step 4


Type:
gfx.fillEllipse 310, 360, 100, 100



Step 5


Type:
gfx.fillEllipse 490, 360, 100, 100



Step 6


Save and run.


Your program must look like this:

Yeah, it's Mickey Mouse's head.



Explaining

"gfx.clear color.white"

It must to erase all the gfx effects on the screen and set the screen color to white.

"gfx.color = color.black"

This command defines the color of the graphical effects. In this case, it set the gfx color to black; soo, if we draw a square or a circle with the gfx command, it's color will be black.

"gfx.fillEllipse 350, 200 , 200, 200"

This command draws a ellipse, with the following parameters: gfx.fillEllipse left, bottom, width, height.

So, this was the post today, i hope you like it! If you have any questions, you can ask it here, at the MiniScript forums or at discord.

quarta-feira, 27 de novembro de 2019

Locating the pointer

Hello, MiniScripters! Today we will learn a bit more about functions. Let's make a function that say where are the mouse pointer.

With MiniMicro

Step 1


Type:
locatePointer = function()


Step 2


Type:
print "Mouse's X position: " + mouse.x



Step 3


Type:
print  "Mouse's Y position:" + mouse.y




Step 4


Type:
end function

Step 5

Click "Save and exit", don't forget to type "save", and run. You must to see something like this:
But with different numbers of course

Explaining: "locatePointer = function()"

The "locatePointer" is just the name of the function, so you can change it as you want. "function()" just defines that "locatePointer" is a function and that this function have no parameters.

Explaining: "print "Mouse's X position: " + mouse.x"

You must to know what the "print" do. It just prints something on the screen. In this case, it prints "Mouse's X position: " and the "mouse.x", that is the X position of the mouse pointer."

Explaining: "print "Mouse's Y position: " + mouse.y"

Here is the same thing, but it print the Y position of the mouse pointer.

Explaining: "end function"

It just defines that this is the end of the function.


With Try It!

I'm sorry... i think there's no way to do this with Try It! page. You can just detect the mouse position in Mini Micro.



If you know the position of the mouse pointer, you can do a lot of things. There's also another way to print the mouse position. You could write:
while true
     print "Mouse's X position: " + mouse.x
     print "Mouse's Y position: " + mouse.y
end while
...and the program will print the mouse's position forever. But you can break the loop with CTRL + C.

This is all for today, but you can do very interesting thing when you know where the mouse are!


The basic structure of a function


sexta-feira, 22 de novembro de 2019

Inputs

Hello, MiniScripters!
Today you'll learn about inputs and outputs. The difference between they is:
Inputs are strings that the player types in the prompt; they pass data to the program, like "print "Hello World!"".
Outputs are strings that the program prints. They pass data to the user.
Now that you know the basic about inputs and outputs, let's start. We will make a program that asks the name, the age and the favorite food of the user, then print a record with all this information.

With MiniMicro

Step 1



Type  "name = input("Hi! What's your name?")"

Step 2



Type "age = input("And what's your age?")"

Step 3



Type "food = input("What's your favorite food?")"

Step 4



Now let's make a pretty record, with the user's personal data;

Type:
print "_________________"
print "Name:   " + name"
print "Age:   " + age"
print "Favorite food:   " + food
print "_________________"

And our program is done,ready for running.
Don't forget to type "save"! Now just type "run" and test your program.When you answer all the questions the program will make, it must to look like this:

Of course, you must to have typed some other name or age, or favorite food, but the result is basically this. Now you can make program using inputs and outputs. These are super important things in a game; inputs and outputs. It's the post of today, bye! See you later!

Squaring a number

Hello, MiniScripters! Today you'll learn about lists, "if"s and more.
Let's make a program that squares any number the user wants!
It's a very simple program, but you can also make better things from this.


With MiniMicro

Step 1


Type:
f = function(x)

Explaining "f = function"
"f" is the name of the function, and you can put any other name you want. So "f = function" defines that there's a function called "f". That "(x)" is just a variable (or parameter) that the function uses.


Step 2


Type:
   return x^2

Explaining "return x^2"
The "return" command defines the value of the function. "x^2" print the square of x


Step 3


Now just type:
end function

...but now, instead of  type "run", you must type:
f  2 (typing "f", you call the function "f", that prints the square of any number.)

If you type "f 2", the program must print 4. If you type "f 3", it must print 9. Now we have a function that prints the square of a number.
Well, it's just it for now. It's a small post, but now you know the basic to make a simple function.

With Try It!

Again, with Try It! you must to type exactly the same code, except that in Try It!, you must to change slightly the code. Write this:

...run the program and you must to see this:


I must explain somethings about MiniMicro and Try It!. When you write in the MiniMicro's command prompt, you are in a REPL (Read Eval Print Loop). A REPL means that the computer
Read what you type, Evaluate it and Print the result -- and Loop this.
      But if you are using Try It! you are not in a command prompt. The same if you are editing a program in MiniMicro(with the `edit` command). In this case, you are writing a program, not using a REPL.
So if you are writing a program, you must to write "print f(2)", and if you are in a command prompt, you can type just "f 2".


Well, this is the end of the post, see you later!

segunda-feira, 18 de novembro de 2019

Beginning at MiniScript

This blog, as the name says, is about Mini Script, a relatively new programming language. I made this blog because i realized that in the web, currently, there is no videos or blogs teaching Mini Script. So my goal, in this blog, is introduce YOU to the Mini Script language. Even i am starting, so for now i'll just tell the basic. Also, there's already a nice tutorial at this page, where you can run some Mini Script code.
  But let's start now. Mini Script is a very simple language. To do the famous "Hello World" example, you just have to type:
print "Hello, world!"
... and done, the program will print "Hello, world!".

  But of course you're not here just for learn how to print something. So now, i'll make a example program and tell about input and variables!


First, you must open the Try it! page or download the MiniMicro engine at https://miniscript.org/MiniMicro. I advise downloading the Mini Micro engine, since it is FREE and don't take so much space in the computer. Now we can start writing:

Our program will be very simple. It must ask what the user want him to print, then print it and store it in a variable. Let's start:

With MiniMicro


Step 1


Type:
save "test1"

Note: Substitute the "test1" by the name that you want for you project.

Step 2


Type "edit". You must to see something like the image above.

Step 3


Type:

var = ""
text = input("What must i print?")

Explaining the "var = """
"var" is the name of the variable, and the = "" is the contents of the variable, that is nothing.

Explaining the "text = input("What must i print?")
Well. Inputs are like variables, but they store what the user says. In this case, "text" is the name of the input, "= input" defines that "text" is the name of the input and the rest is just what the program will print.
Now the program already prints "What must i print?", but don't do anything more. Let's add some more code...

Step 4


 Type:

var = text
print var

Explaining the "var = text"
As i have already explained, "var" is the name of the variable and "text" is the name of the input. When we type "var = text", it means that "var" has the same contents of  "text". So, if "text" = "Hello", var is also "Hello".

Explaining the "print var"
I don't thinks it even need to be explained. It just prints the contents of the "var" variable. Now we have a simple program that asks "What must i print?", and print what the user wants.

Now, click the save button...


... and type "run". Done! If the program go wrong, verify the code, rewrite the code and try again.

With Try It!

Now, with the Try It! page. It's almost the same of the MiniMicro. It's the same code, so just do the steps 3 and 4... and done. But remember that it is just a base program. Using the same commands that this program uses you can create a lot of different things.

NOTE that we used more variables than we really need here, just to show how they work. We could have just written:

var = input("What must i print?")
print var

So, this was the first post about MiniScript. See you later!