30
Visit http://www.codeawesomeness.webs.co m/ to download CodeAwesomeness

Visit to download CodeAwesomeness

Embed Size (px)

Citation preview

Page 1: Visit   to download CodeAwesomeness

Visit http://www.codeawesomeness.webs.com/

to download CodeAwesomeness

Page 2: Visit   to download CodeAwesomeness

The first step in building a CodeAwesomeness project is running the actual editor.

Go to the “C:\Program Files\CodeAwesomeness” directory. Double Click on the application. The name may differ with different versions, but you should be able to tell, as there is only one application in the CodeAwesomeness folder.

Page 3: Visit   to download CodeAwesomeness

A big part of learning programming is understanding your editor.

The big textbox in the middle of the editor is where your code will go. The smaller textbox to the bottom right-hand corner tells you what you can do in the main coding box. Now, the last textbox above the second textbox is the textbox that holds the information about what you have in your “\bin” directory, which holds all the files you may need to use in your program, like pictures for you game.

Page 4: Visit   to download CodeAwesomeness

Now is where you learn what your toolbar at the top does. The toolbar is where you can perform some actions.

All the names of the buttons correspond to the actions the button performs. Say the button says “Print”, so the button will print out your code to see for later. If the button says “New”, then it means it will make a new file for you.

Very simple.

Page 5: Visit   to download CodeAwesomeness

Now for learning the code.Coding is like assembling a puzzle. If the

piece you are trying to assemble doesn’t fit, you will wind up trying to jam in the piece that just won’t work. You need to piece your statements to put together in a way that will function properly.

But to code, you need to learn the language. This is like trying to speak a language without knowing the vocabulary necessary. You would be walking blindly in the dark.

Page 6: Visit   to download CodeAwesomeness

If you look at the textbox to the bottom right-hand corner, you will see a list of statements, functions and properties. The words between the lines represent the Library, which contains other statements to use. Anything under a library you can use. For example:

Library: Aero, Library Function: Exp().Now, in CA you would use the code like this:Library.Function(), or Aero.Exp() Remember

this slider as we move to the next…

Page 7: Visit   to download CodeAwesomeness

So, as we discussed in the last slide, you need a function to go with the library. In this slide, you will learn about Parameters.

Parameters are basically instructions for the function to use to run. Look at this:

Aero.Exp(param1, param2, param3, param4)Parameters are separated by commas. For this

particular function, you need 4 parameters:Left, Right, Top, Bottom. Here is what the code

would look like with the parameters as integer values.

Aero.Exp(0, 0, 40, 0)

Page 8: Visit   to download CodeAwesomeness

So what does this function do?This particular function expands the glass

border of the window. So the left border would be set to 0 pixels, 0 pixels for the right, 40 pixels for the top, and 0 pixels for the bottom border.

What is a function? You might ask. A function is a command telling the compiler to perform an action, with a set of parameters (if needed). A function is enclosed with parenthesis, which are used as indexes for the beginning and end of your parameters.

Page 9: Visit   to download CodeAwesomeness

Now for properties. Properties are basically a sketch-up of a particular object, or item. Take for instance the “des.Title” property. This is a property that indicates the value of the title for the title bar of your window.

When setting a property, you must set it to a primitive value, saying a string or number value. Here is an example: Des.Title = “Hello, World!”

This sets the title to “Hello, World!”

Page 10: Visit   to download CodeAwesomeness

Keywords are just things you can use in your code to define certain elements. Here is a list of all keywords:

If, dim, for, while.All of these keywords indicate a certain job

to be done. If you use the keyword “if”, then it will accomplish a certain job, when using a set of, for lack of a better word, “Parameters.”

Page 11: Visit   to download CodeAwesomeness

The dim keyword is used to create variables. A variable is a string value, holding another value. Here is an example of the Dim keyword:

Dim variable1 = Stringvalue1This code above created a variable with the

name of “variable1”, with the value of “Stringvalue1.”

You can use variables as parameters for functions:

Dim var1 = 40aero.Exp(0, 0, var1, 0)

Page 12: Visit   to download CodeAwesomeness

The for keyword is a loop. Take this code:Dim i = 1For i To 10Code…End ForThis code will loop from the starting

variable, “i”, and loop until the ending value, 10. Whatever is inside the “For” and “End For” keywords will loop until the loop is over.

Page 13: Visit   to download CodeAwesomeness

The If (condition) keyword is harder to explain. The if statement runs a certain code only if a certain statement returns true. Take this code:

Dim var1=5Dim var2=1If <var1> {>} [var2] ThenCode…End IfBecause the statement is true, the code inside

the “If” and “End If” keywords will run.The operator for the conditions can be “<, >,

=, and <>”

Page 14: Visit   to download CodeAwesomeness

The End() function is a function like any other, but its purpose is to end the program .

No parameters are required.The End() is different from the rest because it

does not have a library to sit in, so you can call that function like this:

End()Without a library. Even though it does not

have parameters, it still requires the parenthesis.

Page 15: Visit   to download CodeAwesomeness

In previous slides I had mentioned variables, but never fully. A variable and its value is defined by the Dim keyword. A variable can be used multiple times throughout your code.

As I had said before, variables can be used as parameters. They can also be used as values for properties.

Because variables can only be created with dim, how do you get a new variable to equal another variable? Use VarDim(oldvar, newvar)

Page 16: Visit   to download CodeAwesomeness

Now you have 2 “Dim” things down. New here is funcdim. Funcdim runs a Function and sets the value of a variable to the return value of the function.

funcDim(variable, Function)But if the function used does not have a

return value, then the value of the variable will be set to the last returned value of a variable.

In later coding, you will be using funcDim a lot.

Page 17: Visit   to download CodeAwesomeness

Now that you’ve learn funcDim, you might ask, “What if I need a variable to equal the return value of a property?” My answer is: Use propDim. PropDim uses the same syntax as funcDim, except instead of a variable as the second parameter, you use a property.

propDim(variable, Property)Example of propDim put in use:propDim(title, des.Title)This will set the value of “title” to the title of

the window.

Page 18: Visit   to download CodeAwesomeness

Sometimes in programming you’ll need to use arrays. An array is just a variable holding information. Take this code in C:

arrayexample [x][y]=value;If you were making a chess game, you could use

the above code to get what piece is in what square, without using 64 individual variables. In CA, we use reDim. Example:

reDim(variable, arraylength, index1, index2, index3)

In the future, you’ll be able to use the C example for creating arrays, for more flexability. The next slide shows more on Arrays.

Page 19: Visit   to download CodeAwesomeness

In most games, you’ll need to use arrays to make your code run faster, and more efficiently. Say you are making a Chess game. You need to make an array index for each square. Take this SB code:

For (i == 1) To 8;For (j == 1) to 8;

grid[i][j]=void;Next;

Next;This just creates an 8x8 array, where each square

on the board is empty. Then you can set some squares to contain pieces.

Page 20: Visit   to download CodeAwesomeness

Look at this chess game I made in VB:

I needed to use arrays to hold the name and types of pieces in each square. For example, grid[6][1] is equal to “White Bishop”, and grid[3][7] is “Black Pawn.” These arrays help the program know if you can move the piece you want to the specified square or not.

Page 21: Visit   to download CodeAwesomeness

eQ lets you set the value of a variable to a the solution of a complex equation. Look at this:

eQ var1=mc2

But of course to do this, you would need to set the values of m and c.

dim c=Speed of Lightdim m=MasseQ energy=m(c^2)cLine.print(energy)

Page 22: Visit   to download CodeAwesomeness

A primitive is either a string, a double or an integer. A primitive is basically any ANSI character, or combination of such characters. For example,

“string123!@#$%^&*()_+”is a primitive string. More on strings and integers in the next two slides. You can get characters and character codes with the Txt class.

Page 23: Visit   to download CodeAwesomeness

A string in programming is a combination of characters. These characters can be any character from ANSI. ANSI stands for American National Standards Institute.

When learning to do programming, strings are very useful. Look at this code in VB:

dim newstring as string = “String Value”Primitives are not as useful as individual strings

and integers, but they are useful in languages like CodeAwesomeness, where you need to be able to use a single variable as a string and integer.

Page 24: Visit   to download CodeAwesomeness

Integers are numbers without a fractional part. So 1 is an integer, and 1.5 is not. In VB you would declare an integer like so:

dim variable as integer = 4Then you could use this integer in other

places. But what if you wanted to make a complex calculator to multiply decimals? How would you do that with integers?

The next slide answers that question.

Page 25: Visit   to download CodeAwesomeness

A double is short for double-precision, which means that the number has twice the precision, or can have a fractional part.

If you were to make a calculator, you’d want to use doubles instead of integers. In VB you’d declare a number as a double like so:

dim variable as double = 4.5In CodeAwesomeness there is no use for

doubles, because primitives can be used in that place.

Page 26: Visit   to download CodeAwesomeness

An event is used for running a certain code when a certain thing happens. In an event called “MouseDown”, a specified code runs when the mouse is clicked. Or in “Des.SizeChanged”, the code would run when the window size is changed.

But you can’t use events in CA v0.3. In CA v0.3.5, you will be able to use events. Here is a VB code to handle events:

Private Sub MouseMoved(sender as object, e a System.Windows.F orms.

MouseEventArgs‘Code…End Sub

Page 27: Visit   to download CodeAwesomeness

Images play an important part in most programs. But in CodeAwesomeness, you need to use the Img class. To load an image into memory, use this code:

funcdim(image, img.Load(source))You can use these images in you code, and

you can also use them with the PEdit class to edit your images.

Page 28: Visit   to download CodeAwesomeness

Compiling you code is the last step to your programming code. To compile your code, just click the “Compile and Run” button at the top of the editor. If your project is saved, it will output a *.codexe file in your source directory.

Double-Click on the *.codexe file to run it, and view your application.

Page 29: Visit   to download CodeAwesomeness

You can also code in Notepad, or Notepad ++. Just type your code into the editor and save your file as either a *.txt or a *.cod file.

Then drag the saved file onto the CaWN.exe application.

This should run your application and compile the project, then create a *.codexe file in the directory of your saved source code file.

Page 30: Visit   to download CodeAwesomeness

Cool! You’ve finally finished this slideshow! Not bad for 30 slides, huh?

So now you can create your own games and programs in CodeAwesomeness, and you know a little bit of VB and C (from the examples).

Feel free to give feedback on our website (http://www.codeawesomeness.webs.com) , and ask for help in the forums.

Thanks!-The CodeAwesomeness TeamSlideshow Created by Mitchell M. K.