Statistically-Unlikely-Games / Crimson-Rue

0 stars 0 forks source link

Change Map #1

Open noeinan opened 5 years ago

noeinan commented 5 years ago

pc_sprite interaction to change from one map to another map via doors or other interactables

noeinan commented 5 years ago

Added code, got error

    def change_map(denizen):
        #Transports player to new map
        renpy.show_screen("map_screen", tMap="forest_east")
noeinan commented 5 years ago

Added code, got error

    def change_map(denizen):
        #Transports player to new map
        renpy.hide_screen("map_screen")
        renpy.show_screen("map_screen", tMap="forest_east")
noeinan commented 5 years ago

Added code, got error

    def change_map(denizen):
        #Transports player to new map
        pc_farm.unoccupy("pc_sprite")
        renpy.hide_screen("map_screen")
        renpy.show_screen("map_screen", tMap="forest_east")
noeinan commented 5 years ago

Added code, got error

    def change_map(denizen):
        #Transports player to new map
        pc_farm.unoccupy("pc_sprite")
        renpy.hide_screen("map_screen")
        renpy.show_screen("map_screen", tMap="forest_east")
        tMap.center_x = 25
        tMap.center_y = 25
noeinan commented 5 years ago

Added code, no error but keybinds no longer work

    def change_map(denizen):
        #Transports player to new map
        renpy.call("forest_east")

` east_map = []

    for i in range(55):
        new_row = []
        for j in range(55):
            new_row.append(MapTile())
        east_map.append(new_row)

    forest_east = TestMap(east_map, "forest_east.png", 0, 25)
    **pc_sprite2** = MapDenizen(0, 25, "pc", 90, 180, no_op)
    forest_east.occupy(0, 25, **pc_sprite2**)`
label forest_east:
    show screen map_screen(forest_east)
    return
    key "K_UP" action [Function(tMap.moveDenizen, **pc_sprite**.x, **pc_sprite**.y, 0, -1), SetVariable("pc_dir", "back")]
    key "K_DOWN" action [Function(tMap.moveDenizen, **pc_sprite**.x, **pc_sprite**.y, 0, 1), SetVariable("pc_dir", "front")]
    key "K_LEFT" action [Function(tMap.moveDenizen, **pc_sprite**.x, **pc_sprite**.y, -1, 0), SetVariable("pc_dir", "left")]
    key "K_RIGHT" action [Function(tMap.moveDenizen, **pc_sprite**.x, **pc_sprite**.y, 1, 0), SetVariable("pc_dir", "right")]
    key "K_UP" action [Function(tMap.moveDenizen, **pc_sprite**.x, **pc_sprite**.y, 0, -1), SetVariable("pc_dir", "back")]
    key "K_RETURN" action Function(pcInteracts)
noeinan commented 5 years ago

Fixed! Needed to unoccupy old map after moving to the new map.

    def change_map(denizen):
        #Transports player to new map
        renpy.call("forest_east")
        pc_farm.unoccupy(pc_sprite)
        east_map = []

        for i in range(55):
            new_row = []
            for j in range(55):
                new_row.append(MapTile())
            east_map.append(new_row)

        forest_east = TestMap(east_map, "forest_east.png", 0, 25)
        pc_sprite = MapDenizen(0, 25, "pc", 90, 180, no_op)
        forest_east.occupy(0, 25, pc_sprite)
noeinan commented 5 years ago

This was working shortly before I uploaded a backup, but somehow does not work after backing up. Using the code posted above causes an "out of range" error.

I have found an almost working solution, which is to define the pc_sprite in the change_map function and then occupy the pc_sprite in the forest map definition. However, while this doesn't crash the game it sabotages MoveDenizen somehow, leaving the pc_sprite able to change facing but not actually move.

    def change_map(denizen):
        #Transports player to new map
        renpy.call("forest_east")
        pc_farm.unoccupy(pc_sprite.x, pc_sprite.y)
        pc_sprite = MapDenizen(0, 25, "pc", 90, 180, no_op)
        east_map = []

        for i in range(55):
            new_row = []
            for j in range(55):
                new_row.append(MapTile())
            east_map.append(new_row)

        forest_east = TestMap(east_map, "forest_east.png", 0, 25)
#        pc_sprite = MapDenizen(0, 25, "pc", 90, 180, no_op)
        forest_east.occupy(0, 25, pc_sprite)
noeinan commented 5 years ago

Okay, so it broke again and I managed to get it working again. Here's the code:

` label start:

$ current_map = etown
$ pc_sprite = MapDenizen(24, 23, "pc", 90, 180, no_op)
$ etown.occupy(24, 23, pc_sprite)

show screen map_screen(current_map)

`

` init python: etown_map = []

    for i in range(55):
        new_row = []
        for j in range(55):
            new_row.append(MapTile())
        etown_map.append(new_row)

    etown = TestMap(etown_map, "etown.png", 24, 23)

    weed01_sprite = MapDenizen(24, 24, "weed.png", 90, 90, pickup)
    etown.occupy(24, 24, weed01_sprite)

    eapot_door = MapDenizen(24, 22, "door.png", 90, 90, change_map)
    etown.occupy(24, 22, eapot_door)

`

` east_map = []

    for i in range(55):
        new_row = []
        for j in range(55):
            new_row.append(MapTile())
        east_map.append(new_row)

    forest_east = TestMap(east_map, "forest_east.png", 0, 25)

`

` def change_map(denizen):

Transports player to new map

    renpy.call("forest_east")

`

label forest_east: show screen map_screen(forest_east) $ current_map.unoccupy(pc_sprite.x, pc_sprite.y) $ current_map = forest_east $ pc_sprite = MapDenizen(0, 25, "pc", 90, 180, no_op) $ forest_east.occupy(0, 25, pc_sprite) return

noeinan commented 5 years ago

New bug where player sometimes isn't properly centered on the screen when going from one map to the next, where there are multiple "doors" leading to the new area. This is fixed by moving up or down one, so it seems like the game mistakenly thinks the pc is in another square, and when you step on that square it fixes itself.

Tried various things to fix this, but it looks like I'll need to make new labels for each exit and jump to that label. Should fix issue, will try and report back. (Ex. instead of label forest_east it would be label_forest_east_entrance1a)

noeinan commented 5 years ago

Tried with the new labels, but still having the same problem... wtf