Game Maker 7 Sprites
Originally posted by:There's no need to use a string as all sprites, objects, rooms, scripts, backgrounds and so on have their own storage variable of their own name.If you have a sprite 'playerup' then setting spriteindex = playerup will work.That's true, but what if I have many sprites with 'up' and 'down' variants and am trying to change them dynamically? In the RPG I'm making, I'm trying to make it so that the NPCs can turn towards me when I'm talking to them, however, I want to use just one NPC object who has a variable determining its type, that way when it's talked to from the right, for example, the code to turn them would be something like 'spriteindex = type + ' + direction', except to my knowledge there's nothing in GameMaker allowing for this kind of code to happen (except for executestring which, as I've already mentioned, has been removed).
Game Maker Logo Image from appindex.comFor this tutorial, we will be using Game Maker, a very powerful game engine that makes it possible to create games (essentially 2D) using drag and drop features. This software requires no programming skills, although you may, if you wish, use a built-in scripting language (GML) to harness more advanced features. Shortcut to create sprites.We will now create a corresponding object. An object is a container that you can move around the room and which appearance is defined by a sprite. As we will see later, the appearance of your object can change overtime, based, for example, on its movement (e.g., animated character). Creating your object. From the top menu, select: Resources Create Object.

A new window should appear. In the section labelled Name, type pacmanobj. Leave the box labelled Solid empty (we will use this feature at a later stage for walls).
In the section labelled Sprite, click on the text and select pacmanstandspr from the list. Click on the button labelled OK.
Shortcut to create objects Creating a room and adding the main characterAt this stage, we have an object with an associate sprite and we want to add it to the room, to possibly move it with the arrow keys. First, let’s add this object:. From the top menu, select: Resources Create Room. A new window should appear.
At the top of the window, enter the number 32 in both fields labelled SnapX and SnapY: this is because the sprites that we will be using in this room have a size of 32 by 32 pixels; so that they “snap” perfectly to the room tiles, we arrange the room accordingly. Creating a room. Click on the tab Settings. In the section labelled Name, enter the text Level1. We, could, however, call this room any other name.
Click on the tab labelled Objects: this tab is used to add/remove objects from the scene. In the new tab, click on the empty field below the label “ Object to add with the left mouse” and select the object pacmanobj, that you have created previously.
Game Maker Sprites 32x32
As you can see, this object is already displayed by default. Applying movement. Click on the button labelled OK. Repeat steps 2 to 9 to create movement to the left, up, and down. Test your game ( Run Run Normally). You should see Pac-Man moving in all four directions as you press the left, right, up, and down arrows.Stopping Pac-Man:At this stage, you should have a Pac-Man moving in all four directions.
However, you need to make sure that it stops when the keys are released; let’s modify our programme accordingly:. Double click on the pacmanobj object, this should open a window with the properties of this object. Click on the button Add Event located at the bottom of the window. In the new window, click on the button Release.
This events correspond to any key being released. So in our case, if any of right, left, up or down keys are released, this event will be triggered. From the “ Move” section of the window, drag the top left icon (red star; same a previously) and drop it in the “ Action” section; this should open a window called “ Move fixed”. In the new window, click on the middle square and set the speed to 0. Close the window for this object and test your room again.
Free Sprites For Game Maker
You should now notice that Pac-Man stops whenever a key is released.Last Step: Changing Pac-Man’s appearanceAt this stage, Pac-Man can navigate in all four directions and stop when a key has been released; however we could improve the appearance of the game by changing the sprite representing Pac-Man depending on its direction. Double click on the pacmanobj object (left-hand window). Select the event Press. Click on the tab called Main1 and drag and drop the icon Change Sprite the action window, as illustrated on the next figure. All Events and Actions The End (for now)That’s it. You have managed to move Pac-Man in all four directions and to stop its movement when the keys are released.
Game Maker Characters
You can, of course, apply these principles, to any other game object or type of game. The important principles to bear in mind here are as follows:. Actions are performed when an event occurs.
An event is defined for a particular object. Each object needs to be created and added to the room. Each object can be based on sprites that need to be created accordingly. The appearance of an object can change overtime by allocating different sprites.
Comments are closed.