Fun tutorials...

Posted by Radial543 on July 14, 2007, 10:20 p.m.

Flashback says: There are only three dots in ellipses points.

Here are some useful examples that someone could have alot of fun with:

———————————————————————————————————

Desktop as background:

Sooner or later you're probably going to give in to peer pressure and make a game where you do stuff to your desktop. Now you can copy the desktop without the hassle!

First things first, we need to make a background. Lets just call it bac1. Now we make an object and in the create event, we put in this code:

registry_set_root(0)

global.desktop_image=registry_read_string_ext("Control PanelDesktop","Wallpaper")

background_replace(argument0,string(global.desktop_image),argument1, argument2,argument3)

Lets explain the arguements. Argument0 is the background to replace. In this case, bac1 from earlier. Arguement1 is whether or not to make the background transparent. Argument2 is whether or not to make the background smooth. Argument3 is whether or not to make it fit the room. So here is an example call:

registry_set_root(0)

global.desktop_image=registry_read_string_ext("Control PanelDesktop","Wallpaper")

background_replace(bac1,string(global.desktop_image),false,false,true)

Voila! Now you just add that object in your room, set the background of that room to bac1, and hit play, note you need to have registed Game Maker 6 or 7 !

———————————————————————————————————

Laser Beam:

The physical finesse with a laser beam is that it always goes absolutely straight. It can't cut through everything though, and finally it must come to stop against other objects. This is how to draw a line that should imitate a laser beam and stop when it hit something.

draw_set_color(c_red);

//This is for horizontal laser beam - reverse for vertical

if (collision_line(x,y,room_width,y,all,false,true)>0) {

inst = (collision_line(x,y+sprite_height/2,room_width,y+sprite_height/2,

all,false,true))

draw_line(x,y+sprite_height/2,inst.x,y+sprite_height/2);

}

else {

draw_line(x,y+sprite_height/2,room_width,y+sprite_height/2);

}

draw_sprite(sprite_index,0,x,y);

}

———————————————————————————————————

Slow Motion (REEALY easy):

Open up a room and go to the settings tab.. You there see something called "room speed", default set to 30. This indicates how many steps is taken each second. There is a variable the corresponds to this value, called room_speed. It can be altered during game play. If you take less steps per second then everything will automatically be slower; for an example a bullet moving with speed five when room_speed equals 30 will move 150 pixels per second, but if you decrease room speed to 15 it will only move 15*5=75 pixels a second, half the number. This is what can create a slow motion effect.

room_speed /= 3; //Slow-motion

room_speed *= 3; //Restore

Play around a little with the values, and hopefully you will find what you are looking for.

———————————————————————————————————

Mini Map:

mm_yu = 5 //This is the upper y position

mm_xl = 5 // This is leftmost position

mm_yd = 105 //The second y position

mm_xr = 105 //right x position

//Which objects to draw

nr_obj = 3; //How many objects

obj_d[0] = object0;

obj_d[1] = object1;

obj_d[2] = object2;

obj_d[3] = object3;

//In which color - use the index number of the array above

obj_c[0] = c_blue;

obj_c[1] = c_red;

obj_c[2] = c_gray;

obj_c[3] = c_lime

The script above should be called suggestively in the create event as an initialization of all the variables. As you can see there are two arrays (rather than one two-dimensional) that keeps information about which objects to draw and in what colour. It would also be possible to create a third array which could keep information about other stuff, such that if you want to draw a specific sprite or so for specific objects.

i = 0;

d = 0;

draw_background_stretched(background_index,mm_xl,mm_yu,

mm_xr-mm_xl,mm_yd-mm_yu);

while(i<instance_number(obj_d[d])) {

//Selecting information

x_id = (instance_find(obj_d[d],i).x/room_width)*92;

y_id = (instance_find(obj_d[d],i).y/room_height)*92;

draw_point_color(mm_xl+x_id,mm_yu+y_id,obj_c[d]);

i +=1;

if (i==instance_number(obj_d[d])) {

d += 1;

i = 0;

}

}

Draw background strectched, background index, that gives a cool kind of feeling. Especially if you got a cool background, imagine a battlefield for an example; it gives a kind of map feeling. Although if you rather would like a one-colour background you might just delete that piece of code, maybe replace it with a rectangle.

The condition of that first while statement might be confusing since it only seems to run through one array of obj_d, but as you can see later in the code it changes to d+1 and i is reset. That's like placing the while loop inside another while loop which would say while(d

And finally, as you can see, I am using draw_point for drawing, this is highly selectable. You might change it anyway you like!

———————————————————————————————————

Well, that is all for today [:)], hope you enjoy the tutorials, I'd like to hear your feedback, more coming soon……..

Comments

s 17 years, 5 months ago

Shocking,someone actually did a GMrelated thing

Where I'd use it,I don't know…but I suppose some would have fun with this

Radial543 17 years, 5 months ago

ya, whats cool about the desktop background arrangement of code is that it doesent matter what computer desktop you have or even your arrangement of icons, cause' it harmlessly copies one of your backup files in your system shell, from your computer [:)].

RetroVortex 17 years, 5 months ago

Interesting tutorials…

They could be helpful for me in the future…

(don't need any of them now though..)

noshenim 17 years, 5 months ago

the slow-mo would just make you game seem to become laggy.

wazu 17 years, 5 months ago

That slowmo effect is blugh.

Just put "with all {speed/=global.slowmo; image_speed/=global.slowmo);"

It's not all stuttery and shitty.

Radial543 17 years, 5 months ago

Thanks, wazu, i will use that

Cyber Pirate 17 years, 5 months ago

Hmm, the minimap is great, but the slomo is crap [:(]

Jolt the Hedgehog 17 years, 5 months ago

I use slow motion like that. "Time Break!" as Sonic would say.

stampede 17 years, 5 months ago

"Lag motion"

Radial543 17 years, 5 months ago

lol