Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

998143 Posts in 39142 Topics- by 30548 Members - Latest Member: EditinLuv

April 17, 2014, 06:59:35 PM
TIGSource ForumsDeveloperTutorialsGame Maker Tuts
Pages: [1] 2 3 ... 30
Print
Author Topic: Game Maker Tuts  (Read 172464 times)
ChevyRay
Guest
« on: October 06, 2008, 04:15:51 PM »

Note: Most of the tutorials linked in this post were written for older versions of Game Maker and might not work in GM Studio. If a particular piece of code is returning an error message, check Yoyo Games' official list of obsolete functions first.



Alright Game Maker users! Here I try to keep updated with the latest Game Maker related tutorials and links handy around TIG.



Game Maker For Beginners: I
Game Maker For Beginners: II
Game Maker For Beginners: III
Game Maker For Beginners: IV

Quote from: Derek
Having played with Game Maker for awhile, I have to say, I'm pretty impressed.  I can see why so many people use it!  And I'd like to see more.  I think it's a great way to make games and to learn how to make games.  It puts you in the right frame of mind to move on to "real programming" if you ever wanted to.

That said, the official tutorials for Game Maker aren't very good.  So let's try to make a better one!



Seamless View-Scaling in GM (*OBSOLETE*)

Quote from: ChevyRay
This is a tutorial how to get around using GM's built-in screen-scaling, which has an often undesired blur-effect when scaling up. An alternate method was to scale the view-port dimensions to scale the view. The problem with the view-port method is that it causes ugly seams to appear in your graphics when displayed on certain machines.



Surfaces in Game Maker Tutorial

Quote from: ChevyRay
I wrote a Game Maker tutorial awhile back that explained how to use Game Maker's Surfaces to scale the view without getting blurry results or strange tiling problems. Since then, I've probably gotten an email every week from somebody who has run into issues and errors using the scripts. I've come to realize that this is because a general lack of knowledge on how Surfaces work in Game Maker, and what is actually happening when you use them. So I'm writing this tutorial to clear these things up!



Speed Optimizations

Quote from: Derek
Since I'm a pretty mediocre programmer, I often go for an easy solution to my coding problems rather than an efficient one.  Game Maker is kind of notorious for being slow anyway, so it didn't take long for me to hit its limits.  But with a little research, and some good advice from experienced GM users, I started to make some optimizations to my game that significantly increased its speed.  And now I pass that knowledge down to you!



Grandma: GM Platformer Engine

Quote from: Matt Thorson
So I decided to finally start doing something about all the emails I receive asking how to make a platformer engine in Game Maker.



Fix for Room-Change Keyboard State Bug

Quote from: Christoffer
First, how do I get the engine to recheck keys when I'm starting a new room. Because as it is right now it takes a while before it actually reacts to keys that are being held in between rooms.



Walking Behind/In Front of Obstacles

Quote from: Dr.Salt
This is probably a really simple fix, but it couldn't hurt to ask.
I'm having trouble with depth. This little picture should illustrate the problem.




Displaying Numbers With 0s

Quote from: JasonPickering
Okay so hear is a question I have. How do I make it so a number is displayed as 0003 instead of 3.



Bare-Bones Typewriter Text

Quote from: caiys
After wanting some typewriter text for my game (so the text gradually appears one letter at a time) I did some searching for a tutorial and quickly found every example I came across was encased in a bunch of RPG 'extras' such as dialogue boxes and multiple answers. All I wanted was the bare-bones and after a bit of trial and error it turns out it's pretty damn easy.



Object-Based Parallax Scrolling

Quote from: caiys
What's the best way to do parallax scrolling in a platformer made in Gamemaker?
« Last Edit: March 08, 2014, 03:03:36 AM by C.A. Sinner » Logged
ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #1 on: October 06, 2008, 04:42:42 PM »

Wow, coincidentally we were just talking about that topic in one of the secret forums. Weird.
Logged

Xion
Pixelhead
Level 10
******


xionight@live.com Chimera+Gryphon
View Profile WWW Email
« Reply #2 on: October 06, 2008, 06:22:52 PM »

I look very forward to this  Grin
Logged

ChevyRay
Guest
« Reply #3 on: October 06, 2008, 07:01:23 PM »

Seamless Screen-Scaling
Game Maker


This is a tutorial how to get around using GM's built-in screen-scaling, which has an often undesired blur-effect when scaling up. An alternate method was to scale the view-port dimensions to scale the view. The problem with the view-port method is that it causes ugly seams to appear in your graphics when displayed on certain machines.

Thus, we're going to use the surface-method. The good thing about this method is you can apply it to your game easily, because none of your drawing events or anything need to be changed. You just have to make one persistent object at the beginning of the game, be consistent with your scaling, and you're set.

With this method, we will be changing the view-ports as well. This is a sure-fire method, because if the graphics card doesn't support surfaces, it'll automatically revert to using the view-port method, which is better than nothing, right?

So here we go.

STEP 1: Choose the scale you want. Use a view for every room and have the port W and port H scaled appropriately. So, for example, if you were using a scale of 2... it would look like this, in GM's room editor.



It is important that this is consistent for all rooms. If you have lots of rooms, it might be easier to do this via code*. I prefer to do it that way, because then the values aren't constant and I can support multiple different scales.

STEP 2: Create 3 scripts, screen_init, screen_begin, and screen_end. Here is what goes in each of the scripts...

Quote from: screen_init
// screen base(view_wview and view_hview)
screen_x = 0;
screen_y = 0;
screen_w = 320;
screen_h = 240;
screen_scale = 2;

// create a surface for the whole screen to be drawn on
screen = surface_create(screen_w,screen_h);

// this will destroy the screen object if surfaces are not supported on the graphics card, reverting to the viewport method
if screen = -1{instance_destroy();}

Quote from: screen_begin
// this draws the surface on the screen
surface_reset_target();
draw_clear(0);
draw_set_blend_mode_ext(bm_one, bm_zero);
draw_surface_stretched(screen,screen_x,screen_y,screen_w*screen_scale,screen_h*screen_scale);
draw_set_blend_mode(bm_normal);
screen_refresh();

Quote from: screen_end
// this sets surface 'screen' as the drawing target for everything in the game, so all drawing will be done on this surface and not on the game screen
surface_set_target(screen);

STEP 3: Now we have are scripts, but where do they go? Create an object. Like, obj_screen, objScreen, o_screen, or whatever, and do the following:

A) place the screen_initscript in the Create event.
B) place the screen_begin script in the Begin Step event.
C) place the screen_end script in the End Step event.

And place that object in the first and foremost room of your game, mark it persistent, and make sure there are no duplicates of it.

 You're done, and now have nice, crisp scaling Smiley



TIPS:

*Here's how I defined all my rooms in Skullpogo. Instead of going through every room in the game and setting its view dimensions, I just defined it all here in one neat little piece of code at the beginning of the game (right after the screen_init script, actually, because you need to use variables defined in it).

Quote
var w,h;
w=240*screen_scale;
h=320*screen_scale;
room_set_view(rmSplash,0,true,0,0,240,320,0,0,w,h,0,0,0,0,noone);
room_set_view(rmIntro,0,true,0,320,240,320,0,0,w,h,0,0,0,0,noone);
room_set_view(rmGame,0,true,0,0,240,320,0,0,w,h,0,0,0,0,noone);
room_set_view(rmHelp,0,true,0,0,240,320,0,0,w,h,0,0,0,0,noone);
room_set_view(rmScore,0,true,0,0,240,320,0,0,w,h,0,0,0,0,noone);
room_set_view(rmEnd,0,true,0,0,240,320,0,0,w,h,0,0,0,0,noone);

Things to note about doing it this way:

1) Advantage: because if you decide to change your game's scale, you can do it by just changing the screen_scale value. One little number change and its all done.

2) Foresight: what if you want to have the user choose between multiple game scales? Well, you could have the player choose the scale value at the beginning of the game, and then call this script to set all the rooms. Actually that's exactly what I did in Skullpogo.

3) WARNING: You'll notice that I used room_set_view because it can change the view settings in other rooms. Don't change the view port for the room you're in, the results won't be pleasant. I did this all from an INIT room at the beginning of the game, the room itself which doesn't have any view specifications. So make sure this isn't called from any of the rooms that are being altered.

4) Possibilities! Now your whole screen is drawn on a single surface, which can be moved, rotated, stretched, cut up, or manipulated as you please. The latest I made was an effect where the screen spins away into the background, and I took out the draw_blank(0) for the effect, so the screen leaves behind images as it whirls away in the transition. You can also change the color of the screen, save it to external files, darken/lighten it, or even apply screen filters (which I've also covered with my Retro Remakes project).

~*~

So if you got that working, here's a side project for you. Notice that in screen_init, I defined variables for screen_x and screen_y. But so far, they've just sat at zero and don't do anything. With this, you could create a little function that "jumps" that x and y value around a bit, giving the screen a "shaking" effect, and at the end of the effect snapping them back to zero. Or, you could have the screen slide off one side of the screen as a sort of transition.

~*~

Anyhow, enjoy folks. I'm currently working on an advanced GML library/extension called DeftScreen which will be used to handle a bunch of screen, scaling, and view effects and functions with ease. So that'll go here when it's done, too.

Questions can be PMed to me, posted here, or emailed to me ([email protected]). I'm always glad to help.

ChevyRay
« Last Edit: October 26, 2010, 11:08:18 AM by ChevyRay » Logged
Hideous
That's cool.
Level 10
*****


3D models are the best


View Profile WWW Email
« Reply #4 on: October 07, 2008, 12:14:17 AM »

How about a basic game maker tutorial? I've always hated the ones on yoyogames, and they don't really help me understand anything.
Logged

narasu
Level 10
*****


wehed milie hier, wehed milie daar


View Profile WWW Email
« Reply #5 on: October 07, 2008, 01:26:25 AM »

This helped me out. So much.
Logged

Ronin Narasu - Musician, philosopher, petty thief

http://soundcloud.com/ronin-narasu
Melly
Level 10
*****


This is how being from "da hood" is like, right?


View Profile
« Reply #6 on: October 07, 2008, 04:27:38 AM »

How about a basic game maker tutorial? I've always hated the ones on yoyogames, and they don't really help me understand anything.

I would do it if I could use Game Maker anymore.
Logged

Feel free to disregard the above.
Games: Minus / Action Escape Kitty
xerus
Vice President of Marketing, Romeo Pie Software
Level 10
*


kpulv

Storm+X+MH
View Profile WWW
« Reply #7 on: October 07, 2008, 06:40:50 AM »

Make a tutorial that doesn't make the lower left pixel of every sprite the transparent color.  Sad
Logged

narasu
Level 10
*****


wehed milie hier, wehed milie daar


View Profile WWW Email
« Reply #8 on: October 07, 2008, 07:33:56 AM »

Make a tutorial that doesn't make the lower left pixel of every sprite the transparent color.  Sad
There isn't a short or easy way to do it; you're going to have to use alpha masks for that.

sprite_set_alpha_from_sprite(sprite,mask)
Logged

Ronin Narasu - Musician, philosopher, petty thief

http://soundcloud.com/ronin-narasu
xerus
Vice President of Marketing, Romeo Pie Software
Level 10
*


kpulv

Storm+X+MH
View Profile WWW
« Reply #9 on: October 07, 2008, 08:10:25 AM »

Make a tutorial that doesn't make the lower left pixel of every sprite the transparent color.  Sad
There isn't a short or easy way to do it; you're going to have to use alpha masks for that.

sprite_set_alpha_from_sprite(sprite,mask)

You're an alpha mask.

I mean... thanks.
Logged

ChevyRay
Guest
« Reply #10 on: October 07, 2008, 11:40:54 AM »

Yeah, it's strange that GM does its own transparency handling, and can't use transparency inherent in an image. Unless they're external, though, then I think it can actually pick up transparency values (just from PNG, though? Not sure.)

In The Courts of CandleBre, everything is antialiased, so I created sprite masks for everything, i load them all up, set the transparency from the mask, and then free the masks from memory. Works alright, if you really don't mind the extra work. And external images.

But yeah.
Logged
moi
Level 10
*****


DILF SANTA


View Profile WWW
« Reply #11 on: October 07, 2008, 11:47:11 AM »

GM can't use alpha?
Logged

subsystems   subsystems   subsystems
Hideous
That's cool.
Level 10
*****


3D models are the best


View Profile WWW Email
« Reply #12 on: October 07, 2008, 11:56:57 AM »

Registered version can, partly.
Logged

TeeGee
Level 10
*****


Huh?

tomek_grochowiak@op.pl
View Profile WWW Email
« Reply #13 on: October 07, 2008, 11:59:14 AM »

It does use alpha from .pngs or separate alpha masks. You just can't contain .pngs within the executable (and I don't know why would you ever want to do it anyway).
Logged

Tom Grochowiak
MoaCubeBlog | Twitter | Facebook
Derek
Bastich
Administrator
Level 10
******



View Profile WWW Email
« Reply #14 on: October 07, 2008, 02:31:09 PM »

Thanks, Chevy!  This is a good tut! Beer!

One other possible solution to the seam problem is to add

Code:
x = ceil(x);
y = ceil(y);

in the End Step of every object that is showing seams.  Maybe Carnivac can confirm this method, since he was the one who suggested this on YoYoGames!
Logged
Pages: [1] 2 3 ... 30
Print
Jump to:  

Theme orange-lt created by panic