Code broken. (or just i'm terrible at switching rooms(probably the second one)).

caviar

Member
my coding is, first of all, obviously wrong, that is why i am here. and i cant figure it out, also why i am here. in my game, when i enter my first room, everything is fine, but when i try to exit and go back to the original room, it just completely ignores the entrance object, as if it doesn't even exists, which it does. any help would be appreciated.
GML:
with(oplayer){
if (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance_2")), x, y)) or (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance")), x, y)) or (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance_3")), x, y))
{
    if (room = rvillage)
    {
        if (tilemap_get_at_pixel(layer_tilemap_get_id("Entrance"), x, y))
        {
            global.goto_rvillage = true;
            x = cave_xpos;
            y = cave_ypos;
            with (oblack)
            {
            if (image_alpha <= 1) or (global.down == true)
            {
                image_alpha -= .1
                room_goto(rcave)
            }
            else
            {
            image_alpha += .1
            }
            if (image_alpha <= 0) and (global.down == true)
            {
            global.down = false;
            }
            }
    }
    else{
    if (room == rcave)
    {
        if (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance")), x, y))
        {
            global.goto_rcave = true;
            x = village_xpos;
            y = village_ypos;
            with (oblack)
            {
             if (image_alpha <= 1) or (global.down == true)
            {
                image_alpha -= .1
                room_goto(rvillage)
            }
            else
            {
            image_alpha += .1
            }
            if (image_alpha <= 0) and (global.down == true)
            {
            global.down = false;
            }
            }
    }
    }
}
}
        teleported = true;
}
}
 

Nidoking

Member
How to ask better questions.

Aside from the code being a bit of a mess, it doesn't mean anything to anyone out of context. Nobody here knows what these objects are or what they're supposed to do when they're working. What do you want to happen that isn't happening? How have you confirmed that the thing you say exists actually exists? What event, in what object, is this code in? There's a lot of question missing here.
 

Reprom

Member
GML:
with(oplayer){
if (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance_2")), x, y)) or (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance")), x, y)) or (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance_3")), x, y))
{
    if (room = rvillage)
    {
        if (tilemap_get_at_pixel(layer_tilemap_get_id("Entrance"), x, y)) //-- I think you forgot to get layer id with layer_get_id()
        {
//...
Thats one thing I noticed.

Maybe this will be the only problem, maybe there are more.
One thing I will recomend is to get comfterable with debugger. It may seem scary, but the debugger is your friend. With debugger you can step line by line through you code and see exactly whats is happening.

 

caviar

Member
GML:
with(oplayer){
if (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance_2")), x, y)) or (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance")), x, y)) or (tilemap_get_at_pixel(layer_tilemap_get_id(layer_get_id("Entrance_3")), x, y))
{
    if (room = rvillage)
    {
        if (tilemap_get_at_pixel(layer_tilemap_get_id("Entrance"), x, y)) //-- I think you forgot to get layer id with layer_get_id()
        {
//...
Thats one thing I noticed.

Maybe this will be the only problem, maybe there are more.
One thing I will recomend is to get comfterable with debugger. It may seem scary, but the debugger is your friend. With debugger you can step line by line through you code and see exactly whats is happening.

alright thanks, i did that but it didn't really do much at all
 
Top