HTML5 GameMaker Help Documentation:I'm writing the syntax and structure for the HTML5 GameMaker. It'll guide me in my quest of creation.
The HTML5 GameMaker is an online game maker with the sole purpose of allowing you to make online HTML5 games in a faster and easier manner.
Copyright to the Game Maker's Garage. Created by programmer Matthew French(AKA Gan).
Syntax:
If-Statement:
If 1 = 1 Then
//Do Stuff
End If
For loop:
For i = 1 to 5
//Do stuff involving i
Next
Declaring variables: (Should var be used to declare variables?)
myNum = 2;
myString = "cow";
Should all variables created be global? Or should they be local unless specified as global variables?
General Methods:
Game Open - Gets called when the game opens. This is where you load media.
Key Down - Gets called when a key is pressed down.
Key Up - Gets called when a key is released.
Mouse Down - Gets called when the mouse clicks.
Mouse Up - Gets called when the mouse is released.
Mouse Move - Gets called when the mouse moves.
Timer Tick - Gets called when the timer ticks. Should the timer's interval be changeable? Should there even be a main timer? Should the player be allowed to make their own timer that calls a method?
Game Close - Gets called when the application closes.
Methods:
Custom methods can be created that are callable.
Classes:
The main class contains the General Methods.
Custom classes can contain methods that can be called by CustomClass.CustomMethod().
Custom objects can be created from custom classes:
spaceship = new SpaceShip()
Global variables of custom objects can be set by:
spaceship.shield = 50
Commands:
Funny thing about javascript. You don't need to declare types.
var myVar = 5;
var myVar2 = "cow';
Javascript is crazy like that, just so dynamic that is detects the type as the code runs...
So for simplicity sake I think I'll keep the same format:
var myVar = 5
var myVar2 = "cow"
Funny thing about javascript. You don't need to declare types.
var myVar = 5;
var myVar2 = "cow';
Javascript is crazy like that, just so dynamic that is detects the type as the code runs...
So for simplicity sake I think I'll keep the same format:
var myVar = 5
var myVar2 = "cow"
Welcome to the wonderful world of scripting languages.
Circuit:Will it be possible to create an array of similar types and perform the same operations on all of them? (Provided that they have the same variables and methods.) If so, then that's fine.
Thanks for the input Circuit. I actually hadn't thought of inheritance. A drop down selection would be easiest... though inheritance can be created just by making 2 different class alike.
Hmm, this might make things more confusing for the end user. Turns out for Javascript classes you declare class specific variables by this.myVar = 2.Yes. If Javascript requires class variables to have full names (e.g. this.myVar), then make the interpreter automatically prefix the class names onto the variables when the code is translated into Javascript.
Which begs the question, should custom classes have a Class Variables section where you define variables by "var myVar"?
Or should I just allow the On Constuct method(or any other method in the class) to handle variables and you create variables by "this.myVar=2"? So for normal variables you use var, and for class variables you use this.myVar or myObject.myVar to declare.Constructors shouldn't create variables, only initialize them. IMO.
InJavascript you can declare class variables anywhere. The best place is in the constructor.Circuit:Will it be possible to create an array of similar types and perform the same operations on all of them? (Provided that they have the same variables and methods.) If so, then that's fine.
Thanks for the input Circuit. I actually hadn't thought of inheritance. A drop down selection would be easiest... though inheritance can be created just by making 2 different class alike.Hmm, this might make things more confusing for the end user. Turns out for Javascript classes you declare class specific variables by this.myVar = 2.Yes. If Javascript requires class variables to have full names (e.g. this.myVar), then make the interpreter automatically prefix the class names onto the variables when the code is translated into Javascript.
Which begs the question, should custom classes have a Class Variables section where you define variables by "var myVar"?Or should I just allow the On Constuct method(or any other method in the class) to handle variables and you create variables by "this.myVar=2"? So for normal variables you use var, and for class variables you use this.myVar or myObject.myVar to declare.Constructors shouldn't create variables, only initialize them. IMO.
InJavascript you can declare class variables anywhere. The best place is in the constructor.That seems inconsistent with OOP, but I could probably get used to it. It seems like a very efficient way to define classes.
Declaring variables: (Should var be used to declare variables?)
Should all variables created be global? Or should they be local unless specified as global variables?
Yeah, the game maker is in HTML5 and Javascript.Neat. I'll stay tuned for releases.
As for variables, we've decided to declare them using var so that there's a differentiation between local and global variables.
As for OOP, when you start making a game it's not OOP. But you can make classes and objects if you want OOP.
DrawLine(100,150,450,50)
context.moveTo(100, 150)
context.lineTo(450, 50)
context.stroke()
How will it save? If it saves onto the user's computer you can put it where you want, share it, back it up....Hmmm. Haven't thought of sharing.
can u find the modulus of a number? ???Yeah that'd work.
like: 5 % 2 = 1
Well if it's saved on the server maybe you can add an option for a file to be shared and others can load it. People WILL be making templates or engines or generally code they want to let others use.I like that idea.
But I still like the option of downloading/uploading files.
There should be a method to calculate the distance between 2 points:I'll make sure to add those.
function distance (x1, y1, x2, y2)
{
return Sqrt(POW(x1-x2, 2) + POW(y1-y2, 2));
}
EDIT: there should also be a method to raise a number to a given power.
function POW (base, exponent)
{
//etc.
}
Sounds awesome! Does this mean it's loading any pictures or sounds from the user's computer?Good question. The user will have to upload his/her media onto the net. Their own site or some file hosting site.
I'm going to try and add portability functionality where you can share game code. In the export tab you'd click a download button where it downloads your game file, then people can import it to try it out.
Now that I think of it, people will want to be able to play other people's games. So! I think I'll add an extra feature in the export tab. Where you'll be able to click a button that uploads your compiled game to the GMG and gives you a link you can copy. When you go to the link it'll open up a web page with your game that you can play. Share the link, and others can play your game.
Been testing more...Nice choice of image. I could always use more promotion. ;)
http://f.cl.ly/items/2d3m1O3U0Q3k363T282C/HTML5%20GM%20Preview%20-%20Broadband.m4v
Oh yeah, and I've reached a bit of success in connecting it to the forum. Still working on it.
Maybe I'll make a game about Steven.Ok. Steven is a serial killer who roams the earth searching to kill waldo. In fact, if you look close enough at "Where's waldo in the gamemakers garage" you can see him. He enjoys toast with strawberry frosting and pink and white marshmallows on top. He prefers store brand crackers to the name brand kind and owns a bakery in narnia. He has a vacation home in candyland and enjoys going there to terrorize young travelers trying to get the the candy castle. He currently lives in Hoboken, new jearsey. He has a pet turtle named William.
Metaprogramming is the generation of higher-order programs which, when executed, produce programs (possibly in a different language, or in a subset of the original language) as a result.
Mmmmm, Ada Lovelace. She was quite the woman.
I remember looking up "quine" because of an XKCD strip. It's a program that produces it's entire usable source code as the output. When you think about it it would be difficult to do.
Beauty and intelligence. Some say she was the first programmer.Mmmmm, Ada Lovelace. She was quite the woman.
I'll say. Did you know theres a programming language based on her stuff, and named after her.
Yeh, its crazy. Genetic programming is equally as crazyI remember a video with a robot, where it has no idea what shape it is, and using an accelerometer in the middle it tests each motor repeatedly to find out what it's own construction looks like (very accurately!) and then the computer running it runs a series of simulations using an evolution-based system to simulate it walking and find the fastest way to walk across the table. So it's learning to walk, starting from the very beginning. I wish I could remember where it was, it was a little four-legged robot (so eight motors) with the sensor in the middle. It was walking with one foot pointed right at the goal so it wound up holding the two legs on the side up in the air (it didnt need them) and moving in a sort of smooth worm-like pattern rather than the sort of spidery walk you'd expect, because that's more efficient.
I disagree with 2-4, slightly.
2. It also existed before lambda--http://en.wikipedia.org/wiki/Ada_Lovelace
3. Alonzo Church & Stephen Cole Kleene only lay the foundations for programming. What about McCarthy who invented Lisp? Or Haskell Curry, who is behind the lambda and functional programming?! OR ALAN TURING?!!!! Or even Ada Lovelace who was rocking it back in the early 1800s.
4. Its a compiler. "A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language" - http://en.wikipedia.org/wiki/Compiler
Metaprogramming is slightly different. Its anything that produces, or modifies source code, at /run time/. Compilation happens before run time. A good example would be genetic programming or C macros: #define blah int blah = 10;
I disagree with 2-4, slightly.
2. It also existed before lambda--http://en.wikipedia.org/wiki/Ada_Lovelace
3. Alonzo Church & Stephen Cole Kleene only lay the foundations for programming. What about McCarthy who invented Lisp? Or Haskell Curry, who is behind the lambda and functional programming?! OR ALAN TURING?!!!! Or even Ada Lovelace who was rocking it back in the early 1800s.
4. Its a compiler. "A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language" - http://en.wikipedia.org/wiki/Compiler
Metaprogramming is slightly different. Its anything that produces, or modifies source code, at /run time/. Compilation happens before run time. A good example would be genetic programming or C macros: #define blah int blah = 10;
Well if it existed before Lambda then that wikipedia article I read was wrong.
But doesn't it transform the code into javascript, and then execute that? it's acting like the C macros, in that it translates all the code, and then compiles and runs javascript.
ah I see.
A macro would be if it changed its own source code, before it got converted to javascript. Compilation involves parsing and conversion to another language.
var myCanvas = CreateCanvas(SizeX, SizeY)
var myCanvas = GetMainCanvas()
AddCanvas(myCanvas)
SetCanvasZIndex(myCanvas, 10)
RemoveCanvas(myCanvas)
SetMainCanvas(myCanvas)
This sounds like a great plan to me! No need to change the names, keep calling them canvases. You should have a pre-defined variable called mainCanvas too so there is no need to declare "var myCanvas = GetMainCanvas()". It makes sense right?Function would be better. Cause I have to run some code when you set and get it.
Let me get this straight - On-screen canvases are always the size of the game screen. Off-screen canvases can be any size and you draw them onto the on-screen canvas like an image. On-screen canvases ALWAYS draw each time you change them. I'd assume they delete if you change their pointer, like any object.Actually, you can make them any size, on or off screen. To make them default size, call CreateCanvas() without specifying size. Yeah, you can draw canvases like images.
So all I have left to add is: allow us to toggle on-screen canvases on or off.Toggle? You mean make canvas on screen to off screen and vice versa?
Toggle? You mean make canvas on screen to off screen and vice versa?Say you don't want to see an on-screen canvas at the moment, but you don't want to lose what was in it? You might have to just draw it to an off-screen canvas (to keep the image) and temporarily remove it. Unless you could turn it on and off.
Just do AddCanvas(myCanvas) and RemoveCanvas(myCanvas).
Removing doesn't destroy the canvas. It just removes it from the screen.Toggle? You mean make canvas on screen to off screen and vice versa?Say you don't want to see an on-screen canvas at the moment, but you don't want to lose what was in it? You might have to just draw it to an off-screen canvas (to keep the image) and temporarily remove it. Unless you could turn it on and off.
Just do AddCanvas(myCanvas) and RemoveCanvas(myCanvas).
var myCanvas = GetMainCanvas()
//Just got the main canvas
RemoveCanvas(myCanvas)
//The canvas is no longer on screen/visible but it still exists, you can still draw to it
AddCanvas(myCanvas)
//Canvas is back on screen, all good.
AddCanvas(canvas)
Adds the canvas to the screen.
SetCanvasZIndex(canvas,Z)
Sets the Z index of the canvas. Can rearrange canvases so one can be in front of the other.
RemoveCanvas(canvas)
Removes the canvas from the screen.
SetMainCanvas(canvas)
Sets the drawing canvas. You'll draw to this canvas when you do a drawing command.
GetMainCanvas(canvas)
Gets the main canvas.
SetMediaLoadMethod(method)
Use this method to set the media load method. Meaning, the method you specify will be called whenever a media is loaded.
Ex:
SetMediaLoadMethod("MyMethod")
GetLoadedMediaName()
This pairs with the SetMediaLoadMethod(). This method returns the name of the last loaded media.
SetFont(font)
Sets the font of the current active canvas. Ex:
SetFont("60pt Calibri")
SetLineWidth(w)
Sets the width of the line for the main canvas.
SetLineCap(w)
Sets the cap of the line for the main canvas.
Ex: SetLineCap("square")
SetLineCap("round")
HideCursor()
Makes the cursor invisible.
ShowCursor()
Makes the cursor visible.
LeftArrowKey()
Returns the key code associated with the Left Arrow Key.
RightArrowKey()
Returns the key code associated with the Right Arrow Key.
UpArrowKey()
Returns the key code associated with the Up Arrow Key.
DownArrowKey()
Returns the key code associated with the Down Arrow Key.
returns the code? I'm sorry but what? do you mean it runs the function?Key code is a number associated with a key on the keyboard. The arrow key functions just return the number associated with that arrow key.
ooohhh a font setter that looks pretty nifty and simple,
I can't wait to try these out awesome update Gan
So.... say that it returns the Key Code. be at least a little bit specific.I do state that it returns the Key Code..
DownArrowKey()
Returns the key code associated with the Down Arrow Key.
returns the code? I'm sorry but what? do you mean it runs the function?Key code is a number associated with a key on the keyboard. The arrow key functions just return the number associated with that arrow key.
ooohhh a font setter that looks pretty nifty and simple,
I can't wait to try these out awesome update Gan
So you can type:
KeyIsPressed(DownArrowKey())
Instead of:
KeyIsPressed(40)
It's just a convenience thing.
Glad you're excited. ;D