A Textual Adventure – MathStudio Tutorial

Several weeks ago, we released the first stable version of MathStudio, our free technical IDE. Let’s play with some of the new built-in functions!

You can use GoManga MathStudio not only to make technical application. A new year is coming, and we know that it’s boring to talk about maths during the Christmas holidays, so in this blog post we are going to show how you can make a simple textual adventure using the MathStudio language.

Making a good introduction is one of the most important things to do when you make a textual adventure: it’s the first thing that the player sees! Choose your background and foreground color wisely. You can use the bcolor and the tcolor functions to do this.

Now it’s the time to introduce your player to your narrative universe: be creative! Use the wait function to improve the climax and even change text and/or background colors to make your adventure look beautiful.

After that it’s the time to code the game itself. What is your gameplay? Are you going to make your player choose between different choices? Are you going to make your player insert an action to do? Just be creative!

In the example below we make the player choose between several different choices using the switch construct. We are actually allowing the player to explore our envirorment:

```:init
clear
output.
output.
output You are locked inside a classroom. You have to escape.
output.
output Where are you going?
output.
output 1 - To the door
output 2 - To the interactive whiteboard
output 3 - To the puzzle on the first table
output 4 - To the teaching post
output 5 - To the locker
output 6 - To the windows
output.
[choice] = input

switch {choice} then
case 1 then
clear
output.
output.
output The door is closed. You have to find a different way to escape.
output.
output Press any key to go back...
pause
goto init
endcase
case 2 then
goto iwb
endcase
case 3 then
goto table
endcase
case 4 then
goto teachPost
endcase
case 5 then
goto locker
endcase
case 6 then
clear
output.
output.
output The windows are to high to jump. You have to find a different way to escape.
output.
if {flashlight} = 0 then
output There is a strange flashlight on the sill, it can be useful, so you pick up.
output.
[flashlight] = 1
endif
output Press any key to go back...
pause
goto init
endcase
default then
goto init
enddefault
endswitch
```

This is just a piece of our present for you: a free, playable and open source textual demo inspired by Narcissic Pulse, our new VR game.

… and remember: “Enjoy this Christmas as if it was your last one”

Simple second grade equation solver – MathStudio Tutorial

Let’s start exploring the MathStudio Script Language with this first tutorial. In this article we are going to code a simple second grade equation solver.

Some days ago we released the beta of our Mathematical IDE, MathStudio, which allows you to develop your technical applications in a simple way.

Actually, MathStudio has a simple command that implements the Brent’s equation solver, but we won’t use that in this tutorial. We will let the user input the coefficients of the second grade equation one by one. To do that in MathStudio, we use the input command:

```output Insert 'a' coefficient: [a] = input output Insert 'b' coefficient: [b] = input output Insert 'c' coefficient: [c] = input```

We now have all the coefficients declared. According to Maths theory, we have to calculate the delta (discriminant). Delta is defined as ∆=b^2-4*a*c, so:

`[delta] = calc ({b})^2-4*({a})*({c})`

Now, according to the algorithm to solve this kind of equations, we have two results: x = (-b±√∆)/2*a, so:

```//First result [x1] = calc (-({b}) + sqrt({delta}))/2*({a}) //Second result [x2] = calc (-({b}) - sqrt({delta}))/2*({a})```

All we have to do now is to printing the results on the screen:

```output First result: {x1} output Second result: {x2} pause```

In order to prevent the script from returning NaN (Not a Number) for both the results if delta is minor than zero, we can put a goto mark before the pause command:

`if {delta} < 0 then`

output [Delta < 0] Cannot calculate solutions.
goto end

endif

[…]

:end
pause

You can also plot the function graph associated to the equation if you want:

```fdef f(x) = ({a})*x^2+({b})*x+({c}) plot "f"```

This sample is included in the GoManga MathStudio installer and you can find it under C:\GoManga\MathStudio\Samples\equations.ms but you can also download from here.

Have fun!

MathStudio beta is available

We are proud to announce that, after several months of news blackout on Social Networks and Devlog, we are back to share our news with you. We’re hard working on both Insane Decay of Mind: The Sound of Silence and Not Another Platform Game.

Moreover, in the last month we worked on a little new project, too. Its name is GoManga MathStudio and it is a powerful Mathemathical IDE developed in C# that will allow you to write your complex maths application in a very simple way. In fact, MathStudio provides a very simple syntax for its commands making technical software development easier than ever. Also, it includes a parser which is able to solve coplex mathematichal expressions and it offers several built-in tools for mathematical analysis. MathStudio beta is now available for free and all you need is downloading it!

Isn’t it enough for you?
MathStudio allows you to write your own commands and extentions for the editor! You can do this implementing the MathStudio.Core.Plugin interface in your code. Under the main directory of MathStudio (C:\GoManga\MathStudio\Samples\Plugins), you can also find two examples of implementation. The first one, written in C#, is a plugin that allows you to use the sumf command; the second one, written in VisualBasic, is a UI implementation of the maths parser for the editor. Take a look of the API Documentation for more details. Please note that, according to End-User License Agreement provided with the MathStudio installer wizard, you are not allowed to redistribute MathStudio binaries and executables, even if you are using them for your plugin. The MathStudio DLLs are not required to be put in the Plugins directory.

Are you ready to start coding?

First of all you need to download and install the MathStudio executables. Then, start the MathStudio Editor and write the code below:

output Hello World!
pause

This code is the so famous Hello World script written in the MathStudio Language. You can execute it by simply pressing the F5 button.

Cool, isn’t it? Take a look to the quick reference to see how to code in the MathStudio Language. In the C:\GoManga\MathStudio\Samples directory, you can find several examples of code and we will provide new ones on this Devlog.

We can’t wait to see what you make with this powerful editor: feel free to send your code at info@gomanga.it.