Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 18, 2024, 01:36:57 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsGame Maker Tuts
Pages: 1 ... 20 21 [22] 23 24
Print
Author Topic: Game Maker Tuts  (Read 355158 times)
toborprime
Level 1
*


You're luggage - *blam*


View Profile WWW
« Reply #420 on: March 10, 2013, 03:12:03 PM »

No problem! Feel free to share any methods you come up with - I'll be making the jump to Studio soon, lol.
Logged
sedna16
Level 0
**


View Profile
« Reply #421 on: April 01, 2013, 07:34:01 AM »

I managed to create a simple random dungeon creator on studio.

I'll be posting a tutorial soon, either here or on my blog.

Algo: same hall length, same room size

geen dot - starting point
red dot - end point

Screenshot
Logged
sedna16
Level 0
**


View Profile
« Reply #422 on: April 05, 2013, 01:24:47 AM »

I know theres a more easy way to generate dungeons, but this is the first generator that I've made.

Here it is -

obj_generator ->
Quote
//Initial Coords
x = 0;
y = 0;

grid_size = 16;  // must be even number
map_size = 400;  // must be even number

//center of the map
x = (map_size*grid_size) div 2;
y = (map_size*grid_size) div 2;

//make sure you are on aligned on grid
move_snap(grid_size,grid_size);


randomize(); // gamemaker isnt really random as you would think, so you need this

starting_room = choose(1,2,3);
scr_rooms(starting_room,grid_size);
instance_create(x,y,obj_start);
instance_create(0,0,obj_hud);
instance_create(x,y,obj_player);

// Random Number of Rooms
randomize();
room_num = choose((map_size/2)-20,(map_size/2));

//Start Creating Dungeon
//repeat(room_num)
for(room_i = 0; room_i <= room_num; room_i +=1)
{
    scr_hall();
    scr_hall();
   
    randomize();
    create_room = choose(1,2,3,4);
    if(room_i = room_num)
    {
        instance_create(x,y,obj_center);
        scr_rooms(4,grid_size);
    }
    else
    {
        instance_create(x,y,obj_center);
        scr_rooms(create_room,grid_size);
    }
}



view_follow[0] = obj_start;

scr_floor() ->

Quote
x_coord = argument0;
y_coord = argument1;

if(!position_meeting(x_coord,y_coord,obj_floor))
{
    instance_create(x_coord,y_coord,obj_floor);
}

scr_walls() ->
Quote
//  XXX
//  XoX
//  XXX


if(!instance_position(x-16,y-16,obj_wall) and !instance_position(x-16,y-16,obj_floor))
{
    instance_create(x-16,y-16,obj_wall);
}

if(!instance_position(x,y-16,obj_wall) and !instance_position(x,y-16,obj_floor))
{
    instance_create(x,y-16,obj_wall);
}

if(!instance_position(x+16,y-16,obj_wall) and !instance_position(x+16,y-16,obj_floor))
{
    instance_create(x+16,y-16,obj_wall);
}

if(!instance_position(x+16,y,obj_wall) and !instance_position(x+16,y,obj_floor))
{
    instance_create(x+16,y,obj_wall);
}

if(!instance_position(x+16,y+16,obj_wall) and !instance_position(x+16,y+16,obj_floor))
{
    instance_create(x+16,y+16,obj_wall);
}

if(!instance_position(x,y+16,obj_wall) and !instance_position(x,y+16,obj_floor))
{
    instance_create(x,y+16,obj_wall);
}

if(!instance_position(x-16,y+16,obj_wall) and !instance_position(x-16,y+16,obj_floor))
{
    instance_create(x-16,y+16,obj_wall);
}

if(!instance_position(x-16,y,obj_wall) and !instance_position(x-16,y,obj_floor))
{
    instance_create(x-16,y,obj_wall);
}


scr_rooms() ->

Quote
room_type = argument0;
grid_size = argument1;


if(room_type = 1)
{
    //3x3
    x_start = x-grid_size;
    y_start = y-grid_size;
   
    for(a=0; a<=2; a+=1)
    {
        for(b=0; b<=2; b+=1)
        {
            if(!position_meeting(x_start+(grid_size*a),y_start+(grid_size*b),obj_floor))
            {
                //instance_create(x_start+(grid_size*a),y_start+(grid_size*b),obj_floor);
                scr_floor(x_start+(grid_size*a),y_start+(grid_size*b));
               
            }
        }
    }
}
else if(room_type = 2)
{
    //3x4
    x_start = x-grid_size;
    y_start = y-grid_size;
   
    for(a=0; a<=2; a+=1)
    {
        for(b=0; b<=3; b+=1)
        {
            if(!position_meeting(x_start+(grid_size*a),y_start+(grid_size*b),obj_floor))
            {
                //instance_create(x_start+(grid_size*a),y_start+(grid_size*b),obj_floor);
                scr_floor(x_start+(grid_size*a),y_start+(grid_size*b));
               
            }
        }
    }
    randomize();
    new_coord = choose(1,2);
    y = y+(grid_size*new_coord);
}
else if(room_type = 3)
{
    //4x3
    x_start = x-grid_size;
    y_start = y-grid_size;
   
    for(a=0; a<=3; a+=1)
    {
        for(b=0; b<=2; b+=1)
        {
            if(!position_meeting(x_start+(grid_size*a),y_start+(grid_size*b),obj_floor))
            {
                //instance_create(x_start+(grid_size*a),y_start+(grid_size*b),obj_floor);
                scr_floor(x_start+(grid_size*a),y_start+(grid_size*b));
               
            }
        }
    }
    randomize();
    new_coord = choose(1,2);
    x = x+(grid_size*new_coord);
}
else if(room_type = 4)
{
    //5x5
    x_start = x-grid_size;
    y_start = y-grid_size;
   
    for(a=0; a<=4; a+=1)
    {
        for(b=0; b<=4; b+=1)
        {
            if(!position_meeting(x_start+(grid_size*a),y_start+(grid_size*b),obj_floor))
            {
                //instance_create(x_start+(grid_size*a),y_start+(grid_size*b),obj_floor);
                scr_floor(x_start+(grid_size*a),y_start+(grid_size*b));
               
            }
        }
    }
    randomize();
    new_dir = choose(0,1,2,3);
    switch(new_dir)
    {
        case 0:
        x = x+(grid_size*2)
        break;
       
        case 1:
        y = y+(grid_size*2)
        break;
       
        case 2:
        x = x-(grid_size*2)
        break;
       
        case 3:
        y = y-(grid_size*2)
        break;
    }
}

scr_hall() ->

Quote
randomize();
    choose_dir = choose(0,1,2,3);
    randomize();
    choose_dis = choose(4,7,7);
    switch(choose_dir)
    {
        case 0:
        repeat(choose_dis)
        {
            x = x+grid_size;
            scr_floor(x,y);
        }
        break;
       
        case 1:
        repeat(choose_dis)
        {
            y = y+grid_size;
            scr_floor(x,y);
        }
        break;
       
        case 2:
        repeat(choose_dis)
        {
            x = x-grid_size;
            scr_floor(x,y);
        }
        break;
       
        case 3:
        repeat(choose_dis)
        {
            y = y-grid_size;
            scr_floor(x,y);
        }
        break;
    }

Logged
Gradius
Level 0
*


View Profile
« Reply #423 on: April 13, 2013, 08:02:13 PM »

I know theres a more easy way to generate dungeons, but this is the first generator that I've made.

Here it is -
*snip*

A bit of directional math could shorten those scripts quite a bit (making them quicker to look through)...

Code:
scr_walls() becomes:
var xx, yy;
for(i=0; i=<8; i++)
{
        //Rounded up so it either returns 0 or 1, for those square corners
xx=ceil(lengthdir_x(1,i))*16;
yy=ceil(lengthdir_y(1,i))*16;
if(!instance_position(x-xx,y-yy,obj_wall) && !instance_position(x-xx,y-yy,obj_floor))
{
instance_create(x-xx,y-yy,obj_wall);
}
]


scr_hall() becomes
Code:
dir=round(random(4));
choose_dis=choose(4,7,7)
x=x+lengthdir_x(choose_dis*grid_size,dir);
y=y+lengthdir_y(choose_dis*grid_size,dir);
scr_floor(x,y);
Logged
Reggie02
Level 0
**


View Profile
« Reply #424 on: May 02, 2013, 05:08:06 PM »

Hey guys
I'm new to game maker and i'm working on an engine for a platformer. So far, I have variable jumping and movement. I wanted to implement ledge grabbing next but I just can't find any sort of help/tutorial explaining this so I was wondering if I could get help over here. My collision checking for my blocks in done like so (if anyone finds this relevant:
//When colliding with the object stop moving
move_contact_solid(direction,0)
if place_meeting(x,y+1,obj_block) then vspeed=0
if place_meeting(x,y-1,obj_block) then vspeed=0
if place_meeting(x+1,y,obj_block) then hspeed=0
if place_meeting(x-1,y,obj_block) then hspeed=0

Thanks in advance
btw I posted this in another thread but got no reply
Logged
TapeRecorder
Level 0
*


View Profile
« Reply #425 on: June 13, 2013, 06:22:57 AM »

I know theres a more easy way to generate dungeons, but this is the first generator that I've made.

Here it is -
*snip*

A bit of directional math could shorten those scripts quite a bit (making them quicker to look through)...

Code:
scr_walls() becomes:
var xx, yy;
for(i=0; i=<8; i++)
{
        //Rounded up so it either returns 0 or 1, for those square corners
xx=ceil(lengthdir_x(1,i))*16;
yy=ceil(lengthdir_y(1,i))*16;
if(!instance_position(x-xx,y-yy,obj_wall) && !instance_position(x-xx,y-yy,obj_floor))
{
instance_create(x-xx,y-yy,obj_wall);
}
]


scr_hall() becomes
Code:
dir=round(random(4));
choose_dis=choose(4,7,7)
x=x+lengthdir_x(choose_dis*grid_size,dir);
y=y+lengthdir_y(choose_dis*grid_size,dir);
scr_floor(x,y);

There's a great post on random dungeon generation on Vlambeer's website (from Wasteland Kings)
Logged
rubna
Level 0
**



View Profile
« Reply #426 on: June 18, 2013, 08:02:44 AM »

YOU ARE THE BESTEST MAN EVER THANK YOU A LOT :D
Logged
rubna
Level 0
**



View Profile
« Reply #427 on: June 19, 2013, 05:34:01 AM »

By the by, I expanded your code a bit, so you can set the resolution on-the-fly. Pretty simple stuff, but I thought I'd post it here too because there's a mean trick to it.

What you should do, is replace the screen_init code with this code:
Code:
// screen base(view_wview and view_hview)
screen_x = 0
screen_y = 0
screen_w = 200*global.r;
screen_h = 160*global.r;
screen_scale = global.r;


room_goto(room);
view_wview=(screen_w);
view_hview=(screen_h);
view_wport=(screen_w);
view_hport=(screen_h);

// 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();}

Then, in the create-event of the controller object, write this:
Code:
global.r=1; //fill in whatever resolution you want to start with
screen_init();

Finally, if you want to resize the game, you can set global.r to the value you want and then call screen_init() again.

Example, in a key-pressed event, type this:
Code:
global.r-=1;
if (global.r<=0) {global.r=2;}
screen_init();


You need the room_goto function in the screen_init script, because game maker won't let you resize your game-window in-game without scaling the image (and blurring it). Therefor, you'll need to reload the room.
This isn't a problem if you SET THE ROOM TO PERSISTENT.
It isn't the best solution, because the room HAS to be persistent, but it works OK when you use it in a menu or whatever.

Anyways, this was what I came up with. There's probably a better solution, but it works for me.
Have fun!

(P.S.: ChevyRay, feel free to add this to your original tutorial if you want to!)
Logged
toborprime
Level 1
*


You're luggage - *blam*


View Profile WWW
« Reply #428 on: June 29, 2013, 01:28:11 PM »

So many cool ideas concerning random dungeon/level generation.

I've been doing some experimenting with a prototype for random level generation for a 2D action platformer, though at the moment it does little else than choose and entrance for the room, then an exit, then create a random bunch of platforms between the entrance and the exit at random heights, so it is of little use except for maybe making a random cave system.

I'll post something here when I have something a bit more interesting to play with.
Logged
s0
o
Level 10
*****


eurovision winner 2014


View Profile
« Reply #429 on: June 29, 2013, 04:49:35 PM »

here's how i do it in my GM8 roguelike if anyone is interested

http://forums.tigsource.com/index.php?topic=26781.msg868548#msg868548

from a GM specific perspective it's worth noting that i handle all the layout generation via ds_lists and ds_grids and then use those to generate the actual objects. way faster than using the internal collision functions for levelgen.
Logged
Jandy
Level 0
***



View Profile WWW
« Reply #430 on: August 26, 2013, 04:27:44 PM »

When I try to scale my game, it scales up TOO much.  All my rooms are 320x240, viewports are 640x480, I've followed the tutorial verbatim but the scale is going up by at least a factor of 3 or 4.  Any ideas where I might be going wrong?
Logged

azurezero
Level 0
**


View Profile
« Reply #431 on: September 15, 2013, 08:08:29 PM »

if you want your game maker game to be playable on windows8, be sure to remove all possibility of 2 sounds triggering at the same time, as this causes the game to crash

in my case it only occured once in the Hentai game i released, when the boss appears destroying the remaining mooks on screen, they had a sound playing in their destroy event

changed it so they changed into invisible objects (that dealt with their death particles) and had the boss make the destruction noise instead :3
Logged
toborprime
Level 1
*


You're luggage - *blam*


View Profile WWW
« Reply #432 on: September 16, 2013, 12:56:03 AM »

if you want your game maker game to be playable on windows8, be sure to remove all possibility of 2 sounds triggering at the same time, as this causes the game to crash

in my case it only occured once in the Hentai game i released, when the boss appears destroying the remaining mooks on screen, they had a sound playing in their destroy event

changed it so they changed into invisible objects (that dealt with their death particles) and had the boss make the destruction noise instead :3

Whoa, ok, good to know. What version of Game Maker did you use to make your game? And if it's Studio, were you using the older sound system, or Studio's newer audio system?
Thanks for sharing this!
Logged
azurezero
Level 0
**


View Profile
« Reply #433 on: September 17, 2013, 05:52:24 PM »

8, though i've since found a script that would work also

http://forums.mfgg.net/viewtopic.php?f=10&t=13729

still waiting to see if the script works
Logged
Jrap
Level 0
***


Always be the best dressed in the room.


View Profile WWW
« Reply #434 on: September 30, 2013, 10:33:16 PM »

Having issues with the 'screen_refresh' function

In the script editor for 'screen_begin' it says
Quote
ERROR at line 7 pos 2: Unknown function or script: screen_refresh

and upon running the game I get about the same in a dialog box.

Does this function no longer work? has it's name been changed?
Logged

toborprime
Level 1
*


You're luggage - *blam*


View Profile WWW
« Reply #435 on: September 30, 2013, 10:47:21 PM »

If you are using Game Maker: Studio, then yeah, this function is obsolete and no longer works.
Logged
Jrap
Level 0
***


Always be the best dressed in the room.


View Profile WWW
« Reply #436 on: October 01, 2013, 12:36:19 AM »

If you are using Game Maker: Studio, then yeah, this function is obsolete and no longer works.

Gah! Waaagh! Is there seriously no other way to do it?
Logged

rubna
Level 0
**



View Profile
« Reply #437 on: November 27, 2013, 10:43:07 AM »

I'm having the same problem as Jrap. Does anyone have a alternative to screen_refresh?
Logged
toborprime
Level 1
*


You're luggage - *blam*


View Profile WWW
« Reply #438 on: November 27, 2013, 01:38:03 PM »

Check out the Surfaces tutorial packaged with Game Maker: Studio - This is one way I have gone about including a pause game function in my game that "freezes" the screen. Can do a lot of other fun things with surfaces, too Smiley
Logged
Landshark RAWR
Level 10
*****



View Profile
« Reply #439 on: January 01, 2014, 10:21:44 PM »

In game maker: studio I'm trying to add a drop shadow effect to my aeroplanes by having each flying object create an instance of a shadow object with a lower depth, but none of the created shadow objects get paired with the ship that created them

here is my GML:
this creates each instance
Code:
var giveParent = instance_nearest(x,y,self);
var shadow;
shadow = instance_create(self.x,self.y,oShadow);
with (shadow)
{
    parent = giveParent;
}
show_message(giveParent)
show_message(self)

this is the code on the created instance
Code:
draw_sprite_ext( parent.sprite_index , parent.image_index , parent.x+40 , parent.y+70 , 0.65 , 0.65 , parent.direction - 90 , c_black , 0.4)

the outputs of giveParent in both instances is: -4
and self outputs: -1
Logged

Pages: 1 ... 20 21 [22] 23 24
Print
Jump to:  

Theme orange-lt created by panic