RPG Overworld Engine

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
User avatar
Dragonstar89
Regular
Posts: 158
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: SenpaiJake Games/Paperviper
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: RPG Overworld Engine

#31 Post by Dragonstar89 » Sat May 18, 2019 3:56 pm

Hello! This script is great, and the examples in the source are pretty easy to follow with. The only thing I'm trying to find out, is how are buildings being specifically placed? I'm wanting to try and write around this script to handle multiple maps, and make different areas using custom tiles and such. I found the array of assets, where I added my skyscraper for example:

Code: Select all

["4", "cute_buildings/4", (258,320),None,False,"scinterior1"],
Script runs with no errors returned, but I have no clue how to actually draw in the image? I found this in overworld.rpy:

Code: Select all

                        for tile in tileList:
                            if col == tile[0]: #make buildings
                                self.buildings.append(OverworldDisplayable.Scenery(x,y, tile[1] + ".png", tile[2][0], tile[2][1], 2, tile[4], tile[5], tile[6]))
                                self.sceneryList.append(self.buildings[bldngCount])
                                self.NPCObstacles.append(self.buildings[bldngCount])
                                self.zList.append(self.buildings[bldngCount])
So, I might be staring at a snake I don't see, but I still don't have an idea of the actual placement of buildings here. Any ideas, or where the function is at? Thanks!
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

User avatar
Dragonstar89
Regular
Posts: 158
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: SenpaiJake Games/Paperviper
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: RPG Overworld Engine

#32 Post by Dragonstar89 » Sat May 18, 2019 4:08 pm

Of course I figured it out as soon as I posted my question.

For anyone who wants to know, here's how the map layout gets drawn:

1)Tiles get defined. Define your tiles with their signifier (used in the actual matrices that draw the map), file source path (minus the extension, currently it uses .png automatically), size (XxY, the actual photo dimensions), roof dimensions (same thing, but for the roof tile image if the building has one), has roof (True if you have a roof for the building), goToLabel (string to jump to, good for switching maps or scenes to the interior), and the action which can be a text string. Here's the example code, with my own custom skyscraper tile added as "4":

Code: Select all

    #TILESETS
      
    #signifier, base name, building size, roof size, has roof, goToLabel, actionLabel (used for descriptions)
    moordell_tiles = [
    ["1","cute_buildings/1", (256,216), (256,256),True,None,"building_locked"],
    ["2","cute_buildings/2", (256,216), (256, 256),True,None,"building_locked"],
    ["3","cute_buildings/3", (256,216), (256,256),True,None,"building_locked"],
    ["*","cute_buildings/inn", (342,216),(342,256),True, "inn","inn_desc"],
    ["n", "cute_buildings/wall", (128,128),None,False,None,None],
    ["e", "cute_buildings/wall", (128,128),None,False,None,None],
    ["w", "cute_buildings/wall", (128,128),None,False,None,None],
    ["s", "cute_buildings/wall", (128,128),None, False,None,None],
    ["4", "cute_buildings/4", (258,320),None,False,None,"inn_desc"],
    ["p", "dirt", (128,128),None, False, None,None],
    ["g", "grass", (128,128),None, False, None,None],
    ]
2)Next, the program uses the signifiers of sprites, objects, etc., in a matrix to layout the map. Here's my example one:

Code: Select all

    moordell_layout =[
    "nnnnnnnonnnnnnn",
    "w3oo*ooo4oo4ooe",
    "woooooo+ooooooe",
    "woooooooooooooe",
    "w3oooooo1oooooe",
    "woooooooooooooe",
    "woooooooooooooe",
    "w2o3ooooo1oo2oe",
    "woooooooooooooe",
    "woooooooooooooe",
    "w3ooo4o3o2oo1oe",
    "woooooooooooooe",
    "woooooooooooooe",
    "w1o2o2ooo3o4ooe",
    "woooooooooooooe",
    "woooooooooooooe",
    "sssssssssssssss",
    ]
Notice the number '4" in there. That's where my Skyscraper tile will be placed in the graph/map when it is drawn out. The same goes for the other buildings, and even the walls ("w" = west wall, "e" = east wall, "s" = south wall and so forth).

Hope it helps.
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

User avatar
Mole-chan
Veteran
Posts: 324
Joined: Thu Aug 27, 2009 12:46 am
Completed: DUAEL, Escape from Puzzlegate
Projects: A Bird with Gold-Mended Wings
Deviantart: mole-chan
Skype: mole-chan
Contact:

Re: RPG Overworld Engine

#33 Post by Mole-chan » Sat May 18, 2019 4:46 pm

Dragonstar89 wrote:
Sat May 18, 2019 4:08 pm
Of course I figured it out as soon as I posted my question.

For anyone who wants to know, here's how the map layout gets drawn:
<snip snip for brevity>
Haha, it's alright. Happens to the best of us.

I'm sure any visitors would appreciate the explanation, anyway. :wink:

User avatar
Dragonstar89
Regular
Posts: 158
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: SenpaiJake Games/Paperviper
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: RPG Overworld Engine

#34 Post by Dragonstar89 » Tue May 21, 2019 4:23 pm

I do have a question regarding roof tiles.

Are character sprites enabled to move through them? As in, behind them? I set one of my buildings to utilize the roof, but it still has collision as if it were a normal object, which is causing problems for making a city-themed map.

Any enlightening would be much obliged.
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

User avatar
Mole-chan
Veteran
Posts: 324
Joined: Thu Aug 27, 2009 12:46 am
Completed: DUAEL, Escape from Puzzlegate
Projects: A Bird with Gold-Mended Wings
Deviantart: mole-chan
Skype: mole-chan
Contact:

Re: RPG Overworld Engine

#35 Post by Mole-chan » Sat Jul 06, 2019 1:35 pm

Dragonstar89 wrote:
Tue May 21, 2019 4:23 pm
I do have a question regarding roof tiles.

Are character sprites enabled to move through them? As in, behind them? I set one of my buildings to utilize the roof, but it still has collision as if it were a normal object, which is causing problems for making a city-themed map.

Any enlightening would be much obliged.
Hello!
I'm so sorry I didn't see this earlier. I never even got an email, so I hope my answer is still useful after such a massive delay.

The roof tiles should not have any collision for either the player or NPC's, as long as hasRoof is set to true in the array, and the filename matches the building's file name with a "_roof" suffix. If those are both true, the roof will be set to its own collision group that neither the player or NPC's check against.

luat1995
Newbie
Posts: 17
Joined: Mon Nov 07, 2016 8:27 am
Completed: Home Alone
itch: https://luatsenpai.i
Location: vietnamese
Contact:

Re: RPG Overworld Engine

#36 Post by luat1995 » Sat Aug 17, 2019 3:49 am

When i try build and test in emulator, i get some error: Image
Full traceback:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 23, in script
    python:
  File "game/script.rpy", line 35, in <module>
    results = ui.interact(suppress_overlay=True, suppress_underlay= False)
  File "game/overworld.rpy", line 889, in event
    self.snapToGrid([self.player.rect.x,self.player.rect.y])
AttributeError: 'OverworldDisplayable' object has no attribute 'snapToGrid'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 23, in script
    python:
  File "D:\renpy-7.3.2-sdk\renpy\ast.py", line 912, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\renpy-7.3.2-sdk\renpy\python.py", line 2004, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 35, in <module>
    results = ui.interact(suppress_overlay=True, suppress_underlay= False)
  File "D:\renpy-7.3.2-sdk\renpy\ui.py", line 295, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\renpy-7.3.2-sdk\renpy\display\core.py", line 2699, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "D:\renpy-7.3.2-sdk\renpy\display\core.py", line 3510, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "D:\renpy-7.3.2-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\renpy-7.3.2-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\renpy-7.3.2-sdk\renpy\display\layout.py", line 998, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "game/overworld.rpy", line 889, in event
    self.snapToGrid([self.player.rect.x,self.player.rect.y])
AttributeError: 'OverworldDisplayable' object has no attribute 'snapToGrid'

Windows-7-6.1.7601-SP1
Ren'Py 7.3.2.320
rpg 1.0
Sat Aug 17 14:35:43 2019
how to fix it?
sorry my bad english

Post Reply

Who is online

Users browsing this forum: No registered users