| Beginner TUT 1; Beginner? heres the starting place! | |
|---|---|
| Tweet Topic Started: Dec 23 2010, 12:34 AM (58 Views) | |
| 10kman | Dec 23 2010, 12:34 AM Post #1 |
|
Administrator
|
In this tutorial I will go over the very basics of coding in gml. I will cover variables and simple actions. 1. What is gml? gml stands for Game Maker Language it is the coding language that goes along with Mike Overmars' Game Maker 2. Variables A variable is a letter or word that holds a value. a simple variable would be X (you know? like in algebra class!) In most cases X is the axis that goes left and right. (like on a graph) here is an example of a variable: apple = 1 orange = 2 sum = apple+orange sum would equal 3 right? this is not the actual use of variables though. 3. Some more on variables and operators To begin gml you have to know some things there are basic variables that already have stored values. here are some of them: image_alpha image_index sprite_index image_number there are also operators that cannot be used as variables. here are some examples: if then && and or return The uses of these will be covered later. Object names cannot be used nor can sprite names. 5 actions To review some actions you could go here: http://www.blackratstudios.com/games/DD_to_GML_7/Drag%20and%20Drop%20Icons%20and%20their%20GML%20Equals_Ver%207.html Now to put those actions to use you would have to use some operators. most basic of operators is "if" to use this you need a question like im i at a point less then 52 (wich is the X axis),100 (y axis)? now to check I would ask if object.x < 52 && object.y < 100 { action to perform } I am going to have to explain this cause i thew some new stuff in there. see the && symbol? this means check if both statements are true. so check if object.x is less then 52 AND check if object.y is less then 100. Also you see after the if statement there is a {. This is the start of the actions to perform, and MUST be closed with }. now lets put that same code to use! so lets say if the object is less then 52 X and less than 100 Y he will begin moving with a speed 5 if object.x < 52 && object.y < 100 { motion_set(180, 5) } in the motion_set event the first argument or in this case number, in the parentheses is the direction he will move. 180 would be left, 0 would be right, 90 would be up, 270 would be down. To be continued |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Tutorial · Next Topic » |






2:34 PM Jul 11