How to Make a Game With GML In Game Maker
Auto Beauty Business Culture Dieting DIY Events Fashion Finance Food Freelancing Gardening Health Hobbies Home Internet Jobs Law Local Media Men's Health Mobile Nutrition Parenting Pets Pregnancy Products Psychology Real Estate Relationships Science Seniors Sports Technology Travel Wellness Women's Health

How to Make a Game With GML In Game Maker

GML is very easy to understand in this article. Once you read the following you will be able to understand it a lot better. Once you learn GML in game maker, it will be very easy to learn other programming languages. You can think of GML as the gateway to computer programming.

Before you read this article, this one may be of great help if you Have no experience with GML, Make A Game Maker Game With "GML" for Beginners. If you already know how to make basic movements e.g. x -= 5, which would mean move the object to the left at a speed of 5 pixels per second, then you're good.

First off, you need to have created a sprite spr_main, and an object obj_main. Knowing the basic movements is very helpful.

Create a new sprite. Change the name spr_wall, click edit sprite, click create a new sprite. Open image 0. Choose any color besides black on the right side of the new sprite window. Press F on your keyboard, click in the checkered square. Click the check mark, click it in the next screen, select center, and click OK.

Create a new object. Change the name to obj_wall. Choose solid, shown where it is in the picture here. Click OK, open object obj_main. Open the code in the left keyboard event. Change the code to; if place_empty(x-5,y) x-=5. This tells game maker to see if there is anything in the way for 10 pixels, if there isn't, the object this code is in will move to the left at a speed of 5 pixels per second. Save the game if you haven't recently. Now go to the up keyboard event, open the code and type if place_empty(x,y-5) y-=5. Next go to the right keyboard event, go in the execute code and type in if place_empty(x+5,y) x+=5. Last bit of code for movement right here: In the actions section of the down key event, open execute code, type in if place_empty(x,y+5) y+=5.

Create a room (if you haven't already). Go to the settings tab and name it room_main. Go back to the obects tab and click on the little button that looks like a list with a mouse pointer on it, select obj_main. Place obj_main anywhere in the room if you haven't already. Now choose obj_wall by clicking on that same button. Create a wall surrounding the outside of the room. A fast way of doing this is by holding shift while dragging your mouse around the room. When done, it should look a lot like this.

Remember to never add a period to the end of any code. The only time you use it is as a decimal e.g. vspeed = 4.5 which means vertical speed is 4.5 pixels per second. There will be more on that in another article. Save the game then run it by clicking the green arrow. obj_main should slide along the walls smoothly. If not, or if there are any other questions, leave them in the comment section below and I will answer them as soon as possible.

Need an answer?
Get insightful answers from community-recommended
experts
in Computer Programming & Languages on Knoji.
Would you recommend this author as an expert in Computer Programming & Languages?
You have 0 recommendations remaining to grant today.
Comments (1)

Almost all specialists write admission essay about their works and achivments in it. They share their knowledge with other. 

ARTICLE DETAILS
RELATED ARTICLES
RELATED CATEGORIES
ARTICLE KEYWORDS